Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPS-52321 Add tests to verify that Bobo browser does not admit null sort fields #29

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/

package com.liferay.portal.search.lucene;

import com.liferay.portal.kernel.search.Hits;
import com.liferay.portal.kernel.search.Query;
import com.liferay.portal.kernel.search.SearchContext;
import com.liferay.portal.kernel.search.Sort;
import com.liferay.portal.kernel.test.AggregateTestRule;
import com.liferay.portal.test.LiferayIntegrationTestRule;
import com.liferay.portal.test.MainServletTestRule;

import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;

/**
* @author Manuel de la Peña
*/
public class LuceneIndexSearcherTest {

@ClassRule
@Rule
public static final AggregateTestRule aggregateTestRule =
new AggregateTestRule(
new LiferayIntegrationTestRule(), MainServletTestRule.INSTANCE);

@Test
public void testSearchWithEmptySort() throws Exception {
LuceneIndexSearcher luceneIndexSearcher = new LuceneIndexSearcher();

SearchContext searchContext = new SearchContext();

searchContext.setSorts(new Sort[] {});

Query query = new BooleanQueryImpl();

Hits hits = luceneIndexSearcher.search(searchContext, query);

Assert.assertEquals(0, hits.getLength());
}

@Test
public void testSearchWithNullSort() throws Exception {
LuceneIndexSearcher luceneIndexSearcher = new LuceneIndexSearcher();

SearchContext searchContext = new SearchContext();

searchContext.setSorts(null);

Query query = new BooleanQueryImpl();

Hits hits = luceneIndexSearcher.search(searchContext, query);

Assert.assertEquals(0, hits.getLength());
}

@Test
public void testSearchWithNullSorts() throws Exception {
LuceneIndexSearcher luceneIndexSearcher = new LuceneIndexSearcher();

SearchContext searchContext = new SearchContext();

searchContext.setSorts(new Sort[]{ null });

Query query = new BooleanQueryImpl();

Hits hits = luceneIndexSearcher.search(searchContext, query);

Assert.assertEquals(0, hits.getLength());
}

}