Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2010-01-05 21:53:36 +0000
committerChris Goldthorpe2010-01-05 21:53:36 +0000
commit8f342f72fccffec70e9a21309daac05914b5d959 (patch)
treeea9c287b2d35f623ea4c7ef801a12a333699e36a
parent8cedff70f5ea346872bcea905ce4d1c3d6f0965a (diff)
downloadeclipse.platform.ua-8f342f72fccffec70e9a21309daac05914b5d959.tar.gz
eclipse.platform.ua-8f342f72fccffec70e9a21309daac05914b5d959.tar.xz
eclipse.platform.ua-8f342f72fccffec70e9a21309daac05914b5d959.zip
Add tests for Lucene Search Participant
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java3
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LuceneParticipantTest.java56
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockLuceneParticipant.java51
-rw-r--r--org.eclipse.ua.tests/icons/sample4.gifbin0 -> 166 bytes
-rw-r--r--org.eclipse.ua.tests/plugin.xml10
5 files changed, 119 insertions, 1 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java
index fb316b3d0..5c07135c7 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -37,5 +37,6 @@ public class AllSearchTests extends TestSuite {
addTest(SearchCheatsheet.suite());
addTest(EncodedCharacterSearch.suite());
addTest(MetaKeywords.suite());
+ addTest(LuceneParticipantTest.suite());
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LuceneParticipantTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LuceneParticipantTest.java
new file mode 100644
index 000000000..7daf87dc7
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LuceneParticipantTest.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ua.tests.help.search;
+
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+public class LuceneParticipantTest extends TestCase {
+
+ /*
+ * Returns an instance of this Test.
+ */
+ public static Test suite() {
+ return new TestSuite(LuceneParticipantTest.class);
+ }
+
+ public void testSearchFirstWordInFirstDoc() {
+ SearchTestUtils.searchAllLocales("sehdtegd", new String[] { "/org.eclipse.help.base/lucene1.xml" });
+ }
+
+ public void testSearchLastWordInFirstDoc() {
+ SearchTestUtils.searchAllLocales("jduehdye", new String[] { "/org.eclipse.help.base/lucene1.xml" });
+ }
+
+ public void testSearchUsingAndInFirstDoc() {
+ SearchTestUtils.searchAllLocales("jduehdye AND sehdtegd", new String[] { "/org.eclipse.help.base/lucene1.xml" });
+ }
+
+ public void testSearchUsingAndInSeparateDocs() {
+ SearchTestUtils.searchAllLocales("jduehdye and nhduehrf", new String[0]);
+ }
+
+ public void testSearchExactMatch() {
+ SearchTestUtils.searchAllLocales("\"sehdtegd jduehdye\"", new String[] { "/org.eclipse.help.base/lucene1.xml" });
+ }
+
+ public void testSearchExactMatchNotFound() {
+ SearchTestUtils.searchAllLocales("\"jduehdye sehdtegd\"", new String[0]);
+ }
+
+ public void testSearchWordInSecondDoc() {
+ SearchTestUtils.searchAllLocales("nhduehrf", new String[] { "/org.eclipse.help.base/lucene2.xml" });
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockLuceneParticipant.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockLuceneParticipant.java
new file mode 100644
index 000000000..ff11a1810
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockLuceneParticipant.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ua.tests.help.search;
+
+import java.io.StringReader;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.help.search.ISearchIndex;
+import org.eclipse.help.search.LuceneSearchParticipant;
+
+public class MockLuceneParticipant extends LuceneSearchParticipant {
+
+ private static final String DOC_1 = "/org.eclipse.help.base/lucene1.xml";
+ private static final String DOC_2 = "/org.eclipse.help.base/lucene2.xml";
+
+ public IStatus addDocument(ISearchIndex index, String pluginId,
+ String name, URL url, String id, Document doc) {
+ boolean isDoc1 = url.getPath().equals(DOC_1) ;
+ String title = isDoc1 ? "Title1" : "Title2";
+ String summary = isDoc1? "Summary1" : "Summary2";
+ String contents = isDoc1? "sehdtegd jduehdye" : "nhduehrf ldoekfij";
+ addTitle(title, doc);
+ doc.add(new Field("summary", summary, Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$
+ doc.add(new Field("contents", new StringReader(contents))); //$NON-NLS-1$
+ doc.add(new Field("exact_contents", new StringReader(contents))); //$NON-NLS-1$
+ return Status.OK_STATUS;
+ }
+
+ public Set getAllDocuments(String locale) {
+ HashSet set = new HashSet();
+ set.add(DOC_1);
+ set.add(DOC_2);
+ return set;
+ }
+
+}
diff --git a/org.eclipse.ua.tests/icons/sample4.gif b/org.eclipse.ua.tests/icons/sample4.gif
new file mode 100644
index 000000000..bba3dbc69
--- /dev/null
+++ b/org.eclipse.ua.tests/icons/sample4.gif
Binary files differ
diff --git a/org.eclipse.ua.tests/plugin.xml b/org.eclipse.ua.tests/plugin.xml
index 1b7d5b57d..a817ff874 100644
--- a/org.eclipse.ua.tests/plugin.xml
+++ b/org.eclipse.ua.tests/plugin.xml
@@ -601,5 +601,15 @@
filter="(other.info=org.eclipse.ua.tests)">
</serviceSelector>
</extension>
+ <extension
+ point="org.eclipse.help.base.luceneSearchParticipants">
+ <searchParticipant
+ headless="false"
+ icon="icons/sample4.gif"
+ id="org.eclipse.ua.tests.luceneTestParticipant"
+ name="Lucene Search Participant Test"
+ participant="org.eclipse.ua.tests.help.search.MockLuceneParticipant">
+ </searchParticipant>
+ </extension>
</plugin>

Back to the top