Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSopot Cela2016-11-09 12:43:26 +0000
committerSopot Cela2016-11-09 12:43:26 +0000
commitad603c7e425e44239148f16c15da24e13bab153b (patch)
treeedc070d262d069b51938268fe3b72234fa18aab3 /org.eclipse.ua.tests/help/org/eclipse/ua
parent5bf6a6d33bac1e234a0d3b153d59d3c0d6229a42 (diff)
downloadeclipse.platform.ua-ad603c7e425e44239148f16c15da24e13bab153b.tar.gz
eclipse.platform.ua-ad603c7e425e44239148f16c15da24e13bab153b.tar.xz
eclipse.platform.ua-ad603c7e425e44239148f16c15da24e13bab153b.zip
Note that for exact analyzer use (wildcard and exact searches using quotes) the number of results will not match because of a bug in the old code. The files added under folders .../indexXYZ are needed for compatibility tests which I added. See PrebuiltIndexCompatibility.java changes. Change-Id: Id18cdb387ada7f2c30eecbe59b726d3bf6dd00c1 Signed-off-by: Sopot Cela <scela@redhat.com>
Diffstat (limited to 'org.eclipse.ua.tests/help/org/eclipse/ua')
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java82
1 files changed, 63 insertions, 19 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java
index 37f5b1025..fccaecec9 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java
@@ -23,7 +23,8 @@ import java.net.URL;
import java.util.ArrayList;
import org.apache.lucene.index.CorruptIndexException;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexFormatTooOldException;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TopDocs;
@@ -58,26 +59,42 @@ public class PrebuiltIndexCompatibility {
/**
* Test index built with Lucene 1.9.1
*/
- @Test
- public void test1_9_1_IndexReadable() throws Exception {
+ @Test(expected = IndexFormatTooOldException.class)
+ public void test1_9_1_IndexUnReadable() throws Exception {
checkReadable("data/help/searchindex/index191");
}
/**
* Test index built with Lucene 2.9.1
*/
- @Test
- public void test2_9_1_IndexReadable() throws Exception {
+ @Test(expected = IndexFormatTooOldException.class)
+ public void test2_9_1_IndexUnReadable() throws Exception {
checkReadable("data/help/searchindex/index291");
}
/**
+ * Test index built with Lucene 3.5.0
+ */
+ @Test(expected = IndexFormatTooOldException.class)
+ public void test3_5_0_IndexUnReadable() throws Exception {
+ checkReadable("data/help/searchindex/index350");
+ }
+
+ /**
+ * Test index built with Lucene 6.1.0
+ */
+ @Test
+ public void test6_1_0_IndexReadable() throws Exception {
+ checkReadable("data/help/searchindex/index610");
+ }
+
+ /**
** Test compatibility of Lucene 1.9.1 index with current Lucene
*/
@Test
public void test1_9_1Compatible()
{
- checkCompatible("data/help/searchindex/index191", true);
+ checkCompatible("data/help/searchindex/index191", false);
}
/**
@@ -86,13 +103,29 @@ public class PrebuiltIndexCompatibility {
@Test
public void test2_9_1Compatible()
{
- checkCompatible("data/help/searchindex/index291", true);
+ checkCompatible("data/help/searchindex/index291", false);
+ }
+
+ /**
+ ** Test compatibility of Lucene 3.5.0 index with current Lucene
+ */
+ @Test
+ public void test3_5_0Compatible() {
+ checkCompatible("data/help/searchindex/index350", false);
+ }
+
+ /**
+ ** Test compatibility of Lucene 6.1.0 index with current Lucene
+ */
+ @Test
+ public void test6_1_0Compatible() {
+ checkCompatible("data/help/searchindex/index610", true);
}
@Test
public void test1_9_1LuceneCompatible()
{
- checkLuceneCompatible("1.9.1", true);
+ checkLuceneCompatible("1.9.1", false);
}
@Test
@@ -104,12 +137,22 @@ public class PrebuiltIndexCompatibility {
@Test
public void test2_9_1LuceneCompatible()
{
- checkLuceneCompatible("2.9.1", true);
+ checkLuceneCompatible("2.9.1", false);
+ }
+
+ @Test
+ public void test3_5_0LuceneCompatible() {
+ checkLuceneCompatible("3.5.0", false);
+ }
+
+ @Test
+ public void test6_1_0LuceneCompatible() {
+ checkLuceneCompatible("6.1.0", true);
}
@Test
public void testPluginIndexEqualToItself() {
- PluginIndex index = createPluginIndex("data/help/searchindex/index191");
+ PluginIndex index = createPluginIndex("data/help/searchindex/index610");
assertTrue(index.equals(index));
}
@@ -118,8 +161,8 @@ public class PrebuiltIndexCompatibility {
*/
@Test
public void testPluginIndexEquality() {
- PluginIndex index1a = createPluginIndex("data/help/searchindex/index191");
- PluginIndex index1b = createPluginIndex("data/help/searchindex/index191");
+ PluginIndex index1a = createPluginIndex("data/help/searchindex/index610");
+ PluginIndex index1b = createPluginIndex("data/help/searchindex/index610");
assertTrue(index1a.equals(index1b));
}
@@ -128,8 +171,8 @@ public class PrebuiltIndexCompatibility {
*/
@Test
public void testPluginIndexHash() {
- PluginIndex index1a = createPluginIndex("data/help/searchindex/index191");
- PluginIndex index1b = createPluginIndex("data/help/searchindex/index191");
+ PluginIndex index1a = createPluginIndex("data/help/searchindex/index610");
+ PluginIndex index1b = createPluginIndex("data/help/searchindex/index610");
assertEquals(index1a.hashCode(), index1b.hashCode());
}
@@ -138,8 +181,8 @@ public class PrebuiltIndexCompatibility {
*/
@Test
public void testPluginIndexInequality() {
- PluginIndex index1 = createPluginIndex("data/help/searchindex/index191");
- PluginIndex index2 = createPluginIndex("data/help/searchindex/index291");
+ PluginIndex index1 = createPluginIndex("data/help/searchindex/index610");
+ PluginIndex index2 = createPluginIndex("data/help/searchindex/index350");
assertFalse(index1.equals(index2));
}
@@ -156,10 +199,11 @@ public class PrebuiltIndexCompatibility {
String filePath = resolved.getFile();
QueryBuilder queryBuilder = new QueryBuilder("eclipse", new AnalyzerDescriptor("en-us"));
Query luceneQuery = queryBuilder.getLuceneQuery(new ArrayList<String>() , false);
- try (Directory luceneDirectory = new NIOFSDirectory(new File(filePath));
- IndexSearcher searcher = new IndexSearcher(IndexReader.open(luceneDirectory, true))) {
+ IndexSearcher searcher;
+ try (Directory luceneDirectory = new NIOFSDirectory(new File(filePath).toPath())) {
+ searcher = new IndexSearcher(DirectoryReader.open(luceneDirectory));
TopDocs hits = searcher.search(luceneQuery, 500);
- assertEquals(hits.totalHits, 1);
+ assertTrue(hits.totalHits >= 1);
}
} else {
fail("Cannot resolve to file protocol");

Back to the top