Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2010-01-07 20:01:17 +0000
committerChris Goldthorpe2010-01-07 20:01:17 +0000
commit04d48e65e383124d2009902256d0a623b8710ea2 (patch)
tree4b6f196d8484a653ed26166db32f469c8771fa59 /org.eclipse.ua.tests
parent63b7537ecfefa9018a5971141eca7b23fdb529ab (diff)
downloadeclipse.platform.ua-04d48e65e383124d2009902256d0a623b8710ea2.tar.gz
eclipse.platform.ua-04d48e65e383124d2009902256d0a623b8710ea2.tar.xz
eclipse.platform.ua-04d48e65e383124d2009902256d0a623b8710ea2.zip
Group labels were not added to search index
Diffstat (limited to 'org.eclipse.ua.tests')
-rw-r--r--org.eclipse.ua.tests/data/help/search/participant_xml_1.xml22
-rw-r--r--org.eclipse.ua.tests/data/help/search/participant_xml_2.xml23
-rw-r--r--org.eclipse.ua.tests/data/intro/search/samplesExtensionContent.xml22
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java2
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipant.java48
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipantXML.java64
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchIntro.java64
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java70
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantXMLTest.java70
-rw-r--r--org.eclipse.ua.tests/plugin.xml20
10 files changed, 405 insertions, 0 deletions
diff --git a/org.eclipse.ua.tests/data/help/search/participant_xml_1.xml b/org.eclipse.ua.tests/data/help/search/participant_xml_1.xml
new file mode 100644
index 000000000..74d095c4a
--- /dev/null
+++ b/org.eclipse.ua.tests/data/help/search/participant_xml_1.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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
+ -->
+
+<participant title = "Participant XML 1">
+ <text title="ignored title" summary = "Summary for">
+ search word jfplepdl
+ </text>
+ <text summary = "file Participant XML1">
+ search word memdjkemd
+ </text>
+</participant>
+
diff --git a/org.eclipse.ua.tests/data/help/search/participant_xml_2.xml b/org.eclipse.ua.tests/data/help/search/participant_xml_2.xml
new file mode 100644
index 000000000..fea9fc6ae
--- /dev/null
+++ b/org.eclipse.ua.tests/data/help/search/participant_xml_2.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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
+ -->
+
+<outer>
+<participant title = "Participant XML 2 - tests nesting">
+ <text title="ignored title" summary = "Summary for">
+ search word odoeofoedo
+ <text summary = "file Participant XML2">
+ search word odkeofkeks
+ </text>
+ </text>
+</participant>
+</outer>
diff --git a/org.eclipse.ua.tests/data/intro/search/samplesExtensionContent.xml b/org.eclipse.ua.tests/data/intro/search/samplesExtensionContent.xml
new file mode 100644
index 000000000..b54f18346
--- /dev/null
+++ b/org.eclipse.ua.tests/data/intro/search/samplesExtensionContent.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" ?> <!--
+ 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
+ -->
+
+<introContent>
+ <!-- Extension to the SDK Samples Page. -->
+ <extensionContent id="org.eclipse.ua.tests.search" name="UA contribution from samples" alt-style="css/swt.properties" style="css/samples.css" path="samples/@">
+ <group label="UA Search Test with searchable word ifirifjrnfj" id="jdt" style-id="content-group">
+ <text style-id="group-description">Description with searchable word nenfhhdhhed</text>
+ <link label="Label containing searchable word hydefefed" url="http://org.eclipse.ui.intro/runAction?pluginId=org.eclipse.pde.ui&amp;class=org.eclipse.pde.internal.ui.samples.ShowSampleAction&amp;id=org.eclipse.sdk.samples.javaeditor" id="java-editor" style-id="content-link">
+ <text>Test containing searchable word hfuejfujduj</text>
+ </link>
+ </group>
+ </extensionContent>
+</introContent>
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 67be066b8..fa661e6cc 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
@@ -37,6 +37,8 @@ public class AllSearchTests extends TestSuite {
addTest(SearchCheatsheet.suite());
addTest(EncodedCharacterSearch.suite());
addTest(MetaKeywords.suite());
+ addTest(SearchParticipantTest.suite());
+ addTest(SearchParticipantXMLTest.suite());
addTest(LuceneParticipantTest.suite());
addTest(LuceneXMLParticipantTest.suite());
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipant.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipant.java
new file mode 100644
index 000000000..bbd340ab3
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipant.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.help.search.IHelpSearchIndex;
+import org.eclipse.help.search.ISearchDocument;
+import org.eclipse.help.search.SearchParticipant;
+
+public class MockSearchParticipant extends SearchParticipant {
+
+ private static final String DOC_1 = "/org.eclipse.ua.tests/participant1.xml";
+ private static final String DOC_2 = "/org.eclipse.ua.tests/participant2.xml";
+
+ public Set getAllDocuments(String locale) {
+ HashSet set = new HashSet();
+ set.add(DOC_1);
+ set.add(DOC_2);
+ return set;
+ }
+
+ public IStatus addDocument(IHelpSearchIndex index, String pluginId,
+ String name, URL url, String id, ISearchDocument doc) {
+ boolean isDoc1 = url.getPath().equals(DOC_1) ;
+ String title = isDoc1 ? "Title1" : "Title2";
+ String summary = isDoc1? "Summary1" : "Summary2";
+ String contents = isDoc1? "jkijkijkk frgeded" : "olhoykk lgktihku";
+ doc.addTitle(title);
+ doc.addSummary(summary);
+ doc.addContents(contents);
+ return Status.OK_STATUS;
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipantXML.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipantXML.java
new file mode 100644
index 000000000..1f45b4797
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipantXML.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.help.search.SearchParticipantXML;
+import org.xml.sax.Attributes;
+
+public class MockSearchParticipantXML extends SearchParticipantXML {
+
+ public static final String DOC_1 = "/org.eclipse.ua.tests/data/help/search/participant_xml_1.xml";
+ public static final String DOC_2 = "/org.eclipse.ua.tests/data/help/search/participant_xml_2.xml";
+
+ public Set getAllDocuments(String locale) {
+ HashSet set = new HashSet();
+ set.add(DOC_1 + "?id=xml1" + "?id=xml2");
+ set.add(DOC_2);
+ return set;
+ }
+
+ public Set getContributingPlugins() {
+ Set result = new HashSet();
+ result.add("org.eclipse.ua.tests");
+ return result;
+ }
+
+ protected void handleStartElement(String name, Attributes attributes,
+ IParsedXMLContent data) {
+ if ("participant".equalsIgnoreCase(name)) {
+ data.setTitle(attributes.getValue("title"));
+ }
+ String summary = attributes.getValue("summary");
+ if (summary != null) {
+ data.addToSummary(summary);
+ }
+ }
+
+ protected void handleEndElement(String name, IParsedXMLContent data) {
+ }
+
+ protected void handleText(String text, IParsedXMLContent data) {
+ String top = getTopElement();
+ if ("text".equalsIgnoreCase(top)) {
+ data.addText(text);
+ }
+ }
+
+ public boolean open(String id) {
+ System.out.println("Open " + id);
+ return true;
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchIntro.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchIntro.java
new file mode 100644
index 000000000..c2b7f4ff4
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchIntro.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.util.ArrayList;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.help.internal.base.BaseHelpSystem;
+import org.eclipse.help.internal.search.ISearchQuery;
+import org.eclipse.help.internal.search.SearchHit;
+import org.eclipse.help.internal.search.SearchQuery;
+import org.eclipse.help.internal.search.SearchResults;
+
+public class SearchIntro extends TestCase {
+
+ /*
+ * Returns an instance of this Test.
+ */
+ public static Test suite() {
+ return new TestSuite(SearchIntro.class);
+ }
+
+ public SearchHit[] findHits(String searchWord) {
+ ISearchQuery query = new SearchQuery(searchWord, false, new ArrayList(), Platform.getNL());
+ SearchResults collector = new SearchResults(null, 10, Platform.getNL());
+ BaseHelpSystem.getSearchManager().search(query, collector, new NullProgressMonitor());
+ return collector.getSearchHits();
+ }
+
+ public void testSearchIntroGroupLabel() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("ifirifjrnfj", "en");
+ assertEquals(1, hits.length);
+ }
+
+ public void testSearchIntroGroupText() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("nenfhhdhhed", "en");
+ assertEquals(1, hits.length);
+ }
+
+ public void testSearchIntroLinkLabel() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("hydefefed", "en");
+ assertEquals(1, hits.length);
+ }
+
+ public void testSearchIntroLinkText() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("hfuejfujduj", "en");
+ assertEquals(1, hits.length);
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java
new file mode 100644
index 000000000..223e42a99
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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 org.eclipse.help.internal.search.SearchHit;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+public class SearchParticipantTest extends TestCase {
+
+ /*
+ * Returns an instance of this Test.
+ */
+ public static Test suite() {
+ return new TestSuite(SearchParticipantTest.class);
+ }
+
+ public void testSearchFirstWordInFirstDoc() {
+ SearchTestUtils.searchAllLocales("jkijkijkk", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
+ }
+
+ public void testSearchLastWordInFirstDoc() {
+ SearchTestUtils.searchAllLocales("frgeded", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
+ }
+
+ public void testSearchUsingAndInFirstDoc() {
+ SearchTestUtils.searchAllLocales("jkijkijkk AND frgeded", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
+ }
+
+ public void testSearchUsingAndInSeparateDocs() {
+ SearchTestUtils.searchAllLocales("jduehdye and olhoykk", new String[0]);
+ }
+
+ public void testSearchExactMatch() {
+ SearchTestUtils.searchAllLocales("\"jkijkijkk frgeded\"", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
+ }
+
+ public void testSearchExactMatchNotFound() {
+ SearchTestUtils.searchAllLocales("\"frgeded jkijkijkk\"", new String[0]);
+ }
+
+ public void testSearchWordInSecondDoc() {
+ SearchTestUtils.searchAllLocales("olhoykk", new String[] { "/org.eclipse.ua.tests/participant2.xml" });
+ }
+
+ public void testReturnedTitle() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("jkijkijkk", "en");
+ assertEquals(hits.length,1);
+ assertEquals("Title1", hits[0].getLabel());
+ }
+
+ public void testReturnedSummary() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("jkijkijkk", "en");
+ assertEquals(hits.length,1);
+ assertEquals("Summary1", hits[0].getSummary());
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantXMLTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantXMLTest.java
new file mode 100644
index 000000000..181c3644e
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantXMLTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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 org.eclipse.help.internal.search.SearchHit;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+public class SearchParticipantXMLTest extends TestCase {
+
+ /*
+ * Returns an instance of this Test.
+ */
+ public static Test suite() {
+ return new TestSuite(SearchParticipantXMLTest.class);
+ }
+
+ public void testSearchFirstWordInFirstDoc() {
+ SearchTestUtils.searchAllLocales("jfplepdl", new String[] { MockSearchParticipantXML.DOC_1 });
+ }
+
+ public void testSearchLastWordInFirstDoc() {
+ SearchTestUtils.searchAllLocales("memdjkemd", new String[] { MockSearchParticipantXML.DOC_1 });
+ }
+
+ public void testSearchWordFromOuterElement() {
+ SearchTestUtils.searchAllLocales("odoeofoedo", new String[] { MockSearchParticipantXML.DOC_2 });
+ }
+
+ public void testSearchWordFromNestedElement() {
+ SearchTestUtils.searchAllLocales("odkeofkeks", new String[] { MockSearchParticipantXML.DOC_2 });
+ }
+
+ public void testReturnedTitle() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("jfplepdl", "en");
+ assertEquals(hits.length,1);
+ assertEquals("Participant XML 1", hits[0].getLabel());
+ }
+
+ public void testReturnedSummary() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("jfplepdl", "en");
+ assertEquals(hits.length,1);
+ assertEquals("Summary for file Participant XML1", hits[0].getSummary());
+ }
+
+ public void testReturnedTitleNestedCase() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("odoeofoedo", "en");
+ assertEquals(hits.length,1);
+ assertEquals("Participant XML 2 - tests nesting", hits[0].getLabel());
+ }
+
+ public void testReturnedSummaryNestedCase() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("odoeofoedo", "en");
+ assertEquals(hits.length,1);
+ assertEquals("Summary for file Participant XML2", hits[0].getSummary());
+ }
+
+}
diff --git a/org.eclipse.ua.tests/plugin.xml b/org.eclipse.ua.tests/plugin.xml
index 830069de2..936209c2d 100644
--- a/org.eclipse.ua.tests/plugin.xml
+++ b/org.eclipse.ua.tests/plugin.xml
@@ -389,6 +389,9 @@
content="data/intro/anchors/extn6.xml"
configId="org.eclipse.ua.tests.intro.config.anchors">
</configExtension>
+ <configExtension
+ configId="org.eclipse.ui.intro.universalConfig"
+ content="data/intro/search/samplesExtensionContent.xml"/>
<!-- 3.2 welcome content used for open welcome performance test -->
<!-- filtered unless running test -->
@@ -618,5 +621,22 @@
participant="org.eclipse.ua.tests.help.search.MockLuceneXMLParticipant">
</searchParticipant>
</extension>
+ <extension
+ point="org.eclipse.help.base.searchParticipant">
+ <searchParticipant
+ headless="false"
+ icon="icons/sample4.gif"
+ id="org.eclipse.ua.tests.searchParticipant"
+ name="Mock Search Participant"
+ participant="org.eclipse.ua.tests.help.search.MockSearchParticipant">
+ </searchParticipant>
+ <searchParticipant
+ headless="false"
+ icon="icons/sample4.gif"
+ id="org.eclipse.ua.tests.searchParticipantXml"
+ name="Mock Search Participant for XML"
+ participant="org.eclipse.ua.tests.help.search.MockSearchParticipantXML">
+ </searchParticipant>
+ </extension>
</plugin>

Back to the top