forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LPS-52321 Add tests to verify that Bobo browser does not admit null s…
…ort fields I sent Bobo mantainer a pull request to fix it: senseidb/bobo#21
- Loading branch information
1 parent
f6e6328
commit 0b9fed2
Showing
1 changed file
with
86 additions
and
0 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
portal-impl/test/integration/com/liferay/portal/search/lucene/LuceneIndexSearcherTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
} |