Skip to content

Commit

Permalink
LPS-52321 Add tests to verify that Bobo browser does not admit null s…
Browse files Browse the repository at this point in the history
…ort fields

I sent Bobo mantainer a pull request to fix it: senseidb/bobo#21
  • Loading branch information
mdelapenya committed Dec 22, 2014
1 parent f6e6328 commit 0b9fed2
Showing 1 changed file with 86 additions and 0 deletions.
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());
}

}

0 comments on commit 0b9fed2

Please sign in to comment.