Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2016-01-19 10:59:13 +0000
committerAlexander Kurtakov2016-01-19 11:07:54 +0000
commit3df5ff10606f1db64a3e649a82ea111ce8c3bbd6 (patch)
tree3f10658fc2526128a5bdafe75b49d0241e39af3e /org.eclipse.ua.tests/help
parent66a90973834fd0a527a8b4c6d75cab82ec3ca1fb (diff)
downloadeclipse.platform.ua-3df5ff10606f1db64a3e649a82ea111ce8c3bbd6.tar.gz
eclipse.platform.ua-3df5ff10606f1db64a3e649a82ea111ce8c3bbd6.tar.xz
eclipse.platform.ua-3df5ff10606f1db64a3e649a82ea111ce8c3bbd6.zip
Bug 485918 - Convert org.eclipse.ua.tests to JUnit 4I20160119-0800
Migrate AllSearchTests. Change-Id: Ib45af1a5c4f4e05be2726f83186f587e7dcd8618 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'org.eclipse.ua.tests/help')
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AnalyzerTest.java50
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/BasicTest.java48
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/EncodedCharacterSearch.java32
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/ExtraDirTest.java54
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/InfocenterWorkingSetManagerTest.java86
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LocaleTest.java80
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LockTest.java20
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MetaKeywords.java30
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java45
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchCheatsheet.java35
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchIntro.java19
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java31
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantXMLTest.java24
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchRanking.java29
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/WildcardTest.java29
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/WorkingSetManagerTest.java96
16 files changed, 441 insertions, 267 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AnalyzerTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AnalyzerTest.java
index 04f621309..69de81259 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AnalyzerTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AnalyzerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2015 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 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
@@ -10,82 +10,100 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.search;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
import org.eclipse.help.internal.search.AnalyzerDescriptor;
+import org.junit.Test;
-import junit.framework.TestCase;
+public class AnalyzerTest {
-public class AnalyzerTest extends TestCase {
-
private final String[] supportedLanguages = { "en", "pt", "ja", "zh", "cs", "de", "el", "fr", "nl", "ru", "ar" };
-
+
+ @Test
public void testEnglishAnalyzer() {
checkAnalyzer("en", "en");
}
+ @Test
public void testEnglishUsAnalyzer() {
checkAnalyzer("en_us", "en");
}
+ @Test
public void testGermanAnalyzer_de() {
checkAnalyzer("de", "de");
}
-
+
+ @Test
public void testGermanAnalyzer_de_DE() {
checkAnalyzer("de_DE", "de");
- }
+ }
+ @Test
public void testJapaneseAnalyzer() {
checkAnalyzer("ja", "ja");
}
-
+
+ @Test
public void testFrenchAnalyzer() {
checkAnalyzer("fr", "fr");
}
-
+
+ @Test
public void testChineseAnalyzer() {
checkAnalyzer("zh", "zh");
}
// Korean and japanese share an analyzer
+ @Test
public void testKoreanAnalyzer() {
checkAnalyzer("ko", "ja");
}
+ @Test
public void testRussianAnalyzer() {
checkAnalyzer("ru", "ru");
}
+ @Test
public void testGreekAnalyzer() {
checkAnalyzer("el", "el");
}
-
+
// Uses default
+ @Test
public void testSpanishAnalyzer() {
checkAnalyzer("es", "ar");
}
+ @Test
public void testPortugueseAnalyzer() {
checkAnalyzer("pt", "pt");
}
-
+
+ @Test
public void testDutchAnalyzer() {
checkAnalyzer("nl", "nl");
}
-
+
+ @Test
public void testCzechAnalyzer() {
checkAnalyzer("cs", "cs");
}
// Uses default
+ @Test
public void testArabicAnalyzer() {
checkAnalyzer("ar", "ar");
}
-
+
// Use default
+ @Test
public void testHebrewAnalyzer() {
checkAnalyzer("il", "ar");
}
-
+
private void checkAnalyzer(String language, String analyzerKind) {
AnalyzerDescriptor an = new AnalyzerDescriptor(language);
@@ -96,10 +114,10 @@ public class AnalyzerTest extends TestCase {
assertEquals("Comparing " + nextLocale + " to " + language, analyzerClassName, an.getAnalyzerClassName());
} else {
assertFalse("Both " + nextLocale + " and " + language + " have value of " + analyzerClassName, analyzerClassName.equals(an.getAnalyzerClassName()));
-
+
}
}
-
+
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/BasicTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/BasicTest.java
index 0453280c4..18744a16d 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/BasicTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/BasicTest.java
@@ -10,100 +10,116 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.search;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-
-public class BasicTest extends TestCase {
-
+public class BasicTest {
+ @Test
public void testSearchUnfiltered() {
SearchTestUtils.searchAllLocales("jehcyqpfjs", new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml" });
}
-
+
// appears in both filtered and unfiltered parts of test1.xhtml
+ @Test
public void testSearchFilteredAndUnfiltered() {
SearchTestUtils.searchAllLocales ("vkrhjewiwh", new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml"});
}
// try OR'ing with a word that does't exist.. should find same result
+ @Test
public void testSearchOrWithNonexistent() {
SearchTestUtils.searchAllLocales("vkrhjewiwh OR this_string_shouldnt_exist_in_any_doc", new String[] {"/org.eclipse.ua.tests/data/help/search/test1.xhtml" }) ;
}
-
+
// try OR'ing with a string from another doc.. should find both
+ @Test
public void testSearchOrBothExist() {
SearchTestUtils.searchAllLocales("vkrhjewiwh OR rugnwjfyqj", new String[] {"/org.eclipse.ua.tests/data/help/search/test1.xhtml", "/org.eclipse.ua.tests/data/help/search/test2.xhtml" });
}
-
+
// these two words only appear next to each other in a paragraph that's filtered out - search should still find it
+ @Test
public void testSearchInFiltered() {
SearchTestUtils.searchAllLocales("\"vkrhjewiwh riehguanil\"", new String[] {"/org.eclipse.ua.tests/data/help/search/test1.xhtml" } );
}
-
+
// first one should be found, but second one only exists in a paragraph that's filtered out - search should still find
+ @Test
public void testSearchAndWithFilter() {
SearchTestUtils.searchAllLocales("vkrhjewiwh AND riehguanil", new String[] {"/org.eclipse.ua.tests/data/help/search/test1.xhtml" });
}
-
+
// only exists in paragraph that's filtered out - search should find
+ @Test
public void testSearchInFilteredOut() {
SearchTestUtils.searchAllLocales("gsdduvfqnh", new String[] {"/org.eclipse.ua.tests/data/help/search/test1.xhtml" });
}
-
+
// word is in test3.xhtml and also included by test4.xhtml, contributed
// into test5.xhtml as an extension, and replaces a paragraph in test6.xhtml.
+ @Test
public void testSearchInclusionAndExtension() {
SearchTestUtils.searchAllLocales("fuejnghqjs", new String[] {"/org.eclipse.ua.tests/data/help/search/test3.xhtml", "/org.eclipse.ua.tests/data/help/search/test4.xhtml", "/org.eclipse.ua.tests/data/help/search/test5.xhtml", "/org.eclipse.ua.tests/data/help/search/test6.xhtml" });
}
-
+
// only exists in paragraph in test6.xhtml that's replaced by another one
+ @Test
public void testSearchInReplacedOut() {
SearchTestUtils.searchAllLocales("bheufnjefa", new String[0] /* no hits*/ );
}
// Test replacement using ExtensionProvider
+ @Test
public void testSearchInReplaceOutUsingProvider() {
SearchTestUtils.searchAllLocales("ausjduehf", new String[] {"/org.eclipse.ua.tests/data/help/search/test6.xhtml" } );
}
-
+
// Test replacement using ExtensionProvider
+ @Test
public void testSearchInReplacemenTextUsingProvider() {
SearchTestUtils.searchAllLocales("bheufnjefb", new String[0] /* no hits*/ );
}
// sanity test to make sure it finds things in XHTML content in .html file
+ @Test
public void testSearchXhtmlInHtml() {
SearchTestUtils.searchAllLocales("kejehrgaqm", new String[] {"/org.eclipse.ua.tests/data/help/search/test7.html" });
}
// same as above, but in a section that should never be filtered
+ @Test
public void testSearchXhtmlNeverFiltered() {
SearchTestUtils.searchAllLocales("opqmenhfjs", new String[] {"/org.eclipse.ua.tests/data/help/search/test7.html" });
}
// only exists in a paragraph in test7.html that should be filtered out
// make sure this works for XHTML content inside .html file
+ @Test
public void testSearchFilteredXhtmlInHtml() {
SearchTestUtils.searchAllLocales("hugftnhdtg", new String[] {"/org.eclipse.ua.tests/data/help/search/test7.html" });
}
-
+
// this doc is listed in TOC several times, using slightly different paths
+ @Test
public void testSearchMultipleTocReference() {
SearchTestUtils.searchAllLocales("rqfedajhtg", new String[] {"/org.eclipse.ua.tests/data/help/search/test9.htm" });
}
+ @Test
public void testSearchMultipleNonadjacentWords() {
SearchTestUtils.searchAllLocales("gsdduvfqnh riehguanil", new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml" } );
}
+ @Test
public void testSearchMultipleNonadjacentExactMatch() {
SearchTestUtils.searchAllLocales("\"gsdduvfqnh riehguanil\"", new String[0]);
}
-
+
+ @Test
public void testSearchMultipleAdjacentExactMatch() {
SearchTestUtils.searchAllLocales("\"vkrhjewiwh riehguanil\"", new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml"});
}
-
+
+ @Test
public void testSearchContentProducer() {
SearchTestUtils.searchAllLocales("egrology", new String[] { "/org.eclipse.ua.tests/generated/Generated+Parent/Parent+page+with+searchable+word+egrology+.html"});
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/EncodedCharacterSearch.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/EncodedCharacterSearch.java
index cc6555a42..0e9e85c45 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/EncodedCharacterSearch.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/EncodedCharacterSearch.java
@@ -10,32 +10,34 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.search;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-
-public class EncodedCharacterSearch extends TestCase {
-
+public class EncodedCharacterSearch {
+ @Test
public void testIso8859() {
- SearchTestUtils.searchOneLocale("\u00E1guilaxaxcs", new String[] {"/org.eclipse.ua.tests/data/help/search/testnl8859.htm" }, "en");
+ SearchTestUtils.searchOneLocale("\u00E1guilaxaxcs", new String[] {"/org.eclipse.ua.tests/data/help/search/testnl8859.htm" }, "en");
}
-
+
+ @Test
public void testIso8859AccentNotIgnored() {
- SearchTestUtils.searchOneLocale("aguilaxaxcs", new String[0], "en");
+ SearchTestUtils.searchOneLocale("aguilaxaxcs", new String[0], "en");
}
+ @Test
public void testUtf8Accented() {
- SearchTestUtils.searchOneLocale("acfele\u00F3n", new String[] {"/org.eclipse.ua.tests/data/help/search/testnlUTF8.htm" }, "en");
+ SearchTestUtils.searchOneLocale("acfele\u00F3n", new String[] {"/org.eclipse.ua.tests/data/help/search/testnlUTF8.htm" }, "en");
}
+ @Test
public void testUtf8Chinese() {
- SearchTestUtils.searchOneLocale("\u8FB2\u66C6\u65B0\u5E74", new String[] {"/org.eclipse.ua.tests/data/help/search/testnlUTF8.htm" }, "en");
+ SearchTestUtils.searchOneLocale("\u8FB2\u66C6\u65B0\u5E74", new String[] {"/org.eclipse.ua.tests/data/help/search/testnlUTF8.htm" }, "en");
}
-
+
+ @Test
public void testUtf8Hebrew() {
- SearchTestUtils.searchOneLocale("\u05D0\u05B7\u05E1\u05B0\u05D8\u05B0\u05E8\u05D5\u05B9\u05E0\u05D5\u05B9\u05DE"
- + "\u05B0\u05D9\u05B8\u05D4) \u05DC\u05B4\u05E7\u05BC\u05D5\u05BC\u05D9 (\u05D9\u05E8\u05D7 \u05D0\u05D5 \u05E9\u05DE\u05E9", new String[] {"/org.eclipse.ua.tests/data/help/search/testnlUTF8.htm" }, "en");
+ SearchTestUtils.searchOneLocale("\u05D0\u05B7\u05E1\u05B0\u05D8\u05B0\u05E8\u05D5\u05B9\u05E0\u05D5\u05B9\u05DE"
+ + "\u05B0\u05D9\u05B8\u05D4) \u05DC\u05B4\u05E7\u05BC\u05D5\u05BC\u05D9 (\u05D9\u05E8\u05D7 \u05D0\u05D5 \u05E9\u05DE\u05E9", new String[] {"/org.eclipse.ua.tests/data/help/search/testnlUTF8.htm" }, "en");
}
-
-
+
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/ExtraDirTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/ExtraDirTest.java
index 3d1cc4de1..b29a227eb 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/ExtraDirTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/ExtraDirTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2015 IBM Corporation and others.
+ * Copyright (c) 2006, 2016 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
@@ -29,85 +29,97 @@ import org.eclipse.help.internal.workingset.AdaptableToc;
import org.eclipse.help.internal.workingset.WorkingSet;
import org.eclipse.help.internal.workingset.WorkingSetManager;
import org.junit.Assert;
+import org.junit.Test;
-import junit.framework.TestCase;
+public class ExtraDirTest {
-public class ExtraDirTest extends TestCase {
-
// try without search scope
- public void testNoScope()
+ @Test
+ public void testNoScope()
{
performSearch("iusazemhdv", null, "/org.eclipse.ua.tests/data/help/search/test8.htm");
}
-
+
// try with containing toc's search scope
- public void testContainingScope()
+ @Test
+ public void testContainingScope()
{
performSearch("iusazemhdv", "/org.eclipse.ua.tests/data/help/toc/root.xml", "/org.eclipse.ua.tests/data/help/search/test8.htm" );
}
-
+
// try with another toc's search scope; shouldn't find it
- public void testNonContainingScope()
+ @Test
+ public void testNonContainingScope()
{
performSearch("iusazemhdv", "/org.eclipse.platform.doc.user/toc.xml", null );
}
// extradir doc, no search scope
- public void testExtradirNoScope()
+ @Test
+ public void testExtradirNoScope()
{
performSearch("xzopsujjae", null, "/org.eclipse.ua.tests/data/help/search/extraDir/extraDoc1.htm" );
}
// extradir doc, with correct search scope
- public void testExtradirCorrectScope()
+ @Test
+ public void testExtradirCorrectScope()
{
performSearch("xzopsujjae", "/org.eclipse.ua.tests/data/help/toc/root.xml", "/org.eclipse.ua.tests/data/help/search/extraDir/extraDoc1.htm" );
}
// extradir doc, with incorrect search scope
- public void testExtradirIncorrectScope()
+ @Test
+ public void testExtradirIncorrectScope()
{
performSearch("xzopsujjae", "/org.eclipse.platform.doc.user/toc.xml", null );
}
// extradir doc (in subdir), no search scope
- public void testExtradirSubdirNoScope()
+ @Test
+ public void testExtradirSubdirNoScope()
{
performSearch("mrendiqwja", null, "/org.eclipse.ua.tests/data/help/search/extraDir/subDir/extraDoc2.htm" );
}
// extradir doc (in subdir), with correct search scope
- public void testExtradirSubDirInScope()
+ @Test
+ public void testExtradirSubDirInScope()
{
performSearch("mrendiqwja", "/org.eclipse.ua.tests/data/help/toc/root.xml", "/org.eclipse.ua.tests/data/help/search/extraDir/subDir/extraDoc2.htm" );
}
// extradir doc (in subdir), with incorrect search scope
- public void testExtradirSubDirOutOfScope()
+ @Test
+ public void testExtradirSubDirOutOfScope()
{
performSearch("mrendiqwja", "/org.eclipse.platform.doc.user/toc.xml", null );
}
// extradir doc link_to'ed from another toc (toc3.xml), with incorrect scope
- public void testExtradirLinkedOutOfScope()
+ @Test
+ public void testExtradirLinkedOutOfScope()
{
performSearch("kleoiujfpn", "/org.eclipse.platform.doc.user/toc.xml", null );
}
// extradir doc linked into toc2.xml from toc4.xml, no scope
- public void testExtradirLinkedNoScope()
+ @Test
+ public void testExtradirLinkedNoScope()
{
performSearch("fuqnejwmfh", null, "/org.eclipse.ua.tests/data/help/search/extraDir3/extraDoc.htm" );
}
// extradir doc linked into toc2.xml from toc4.xml, correct scope
- public void testExtradirLinkedInScope()
+ @Test
+ public void testExtradirLinkedInScope()
{
performSearch("fuqnejwmfh", "/org.eclipse.ua.tests/data/help/toc/root.xml", "/org.eclipse.ua.tests/data/help/search/extraDir3/extraDoc.htm" );
}
// extradir doc linked into toc2.xml from toc4.xml, incorrect scope
- public void testExtradirLinkedWrongScope()
+ @Test
+ public void testExtradirLinkedWrongScope()
{
performSearch("fuqnejwmfh", "/org.eclipse.platform.doc.user/toc.xml", null );
}
@@ -124,7 +136,7 @@ public class ExtraDirTest extends TestCase {
}
workingSets = new WorkingSet[] { wsm.createWorkingSet("testWorkingSet", tocs.toArray(new AdaptableHelpResource[tocs.size()])) };
}
-
+
// expected hits
final Set<String> hrefsToFind = new HashSet<String>();
if (expectedResults != null) {
@@ -154,7 +166,7 @@ public class ExtraDirTest extends TestCase {
unexpectedHrefs.add(href);
}
}
-
+
if (!hrefsToFind.isEmpty() || !unexpectedHrefs.isEmpty()) {
StringBuffer buf = new StringBuffer();
buf.append("While searching for: " + searchWord + ",\n");
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/InfocenterWorkingSetManagerTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/InfocenterWorkingSetManagerTest.java
index f2f2d4a2a..ecfccd455 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/InfocenterWorkingSetManagerTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/InfocenterWorkingSetManagerTest.java
@@ -1,24 +1,27 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 IBM Corporation and others.
+ * Copyright (c) 2010, 2016 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import javax.servlet.http.Cookie;
-import junit.framework.TestCase;
-
import org.eclipse.help.internal.criteria.CriterionResource;
import org.eclipse.help.internal.webapp.servlet.InfocenterWorkingSetManager;
import org.eclipse.help.internal.workingset.AdaptableHelpResource;
@@ -27,9 +30,10 @@ import org.eclipse.help.internal.workingset.AdaptableTopic;
import org.eclipse.help.internal.workingset.WorkingSet;
import org.eclipse.ua.tests.help.webapp.MockServletRequest;
import org.eclipse.ua.tests.help.webapp.MockServletResponse;
+import org.junit.Test;
-public class InfocenterWorkingSetManagerTest extends TestCase {
-
+public class InfocenterWorkingSetManagerTest {
+ @Test
public void testIWSMWithToc() throws IOException {
InfocenterWorkingSetManager mgr = new InfocenterWorkingSetManager
(new MockServletRequest(), new MockServletResponse(), "en");
@@ -45,6 +49,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
assertTrue(resources[0].equals(toc));
};
+ @Test
public void testSaveRestoreIWSMWithToc() throws IOException {
MockServletRequest req = new MockServletRequest();
MockServletResponse resp = new MockServletResponse();
@@ -66,6 +71,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
checkCookies(resp2);
};
+ @Test
public void testIWSMWithOneTopic() throws IOException {
MockServletRequest req = new MockServletRequest();
MockServletResponse resp = new MockServletResponse();
@@ -85,6 +91,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
checkCookies(resp);
};
+ @Test
public void testIWSMWithTwoTopics() throws IOException {
MockServletRequest req = new MockServletRequest();
MockServletResponse resp = new MockServletResponse();
@@ -107,7 +114,8 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
assertTrue(topics.contains(resources[1]));
checkCookies(resp);
};
-
+
+ @Test
public void testIWSMWithThreeTopics() throws IOException {
MockServletRequest req = new MockServletRequest();
MockServletResponse resp = new MockServletResponse();
@@ -121,7 +129,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
assertNotNull(topic5);
wset.setElements(new AdaptableHelpResource[] { topic1, topic3, topic5 });
mgr.addWorkingSet(wset);
-
+
WorkingSet[] readWsets = mgr.getWorkingSets();
assertEquals(1, readWsets.length);
AdaptableHelpResource[] resources = readWsets[0].getElements();
@@ -135,7 +143,8 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
assertTrue(topics.contains(resources[2]));
checkCookies(resp);
};
-
+
+ @Test
public void testSaveRestoreIWSMWithOneTopic() throws IOException {
MockServletRequest req = new MockServletRequest();
MockServletResponse resp = new MockServletResponse();
@@ -145,7 +154,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
assertNotNull(topic1);
wset.setElements(new AdaptableHelpResource[] { topic1 });
mgr.addWorkingSet(wset);
-
+
MockServletRequest req2 = new MockServletRequest();
MockServletResponse resp2 = new MockServletResponse();
req2.setCookies(resp.getCookies());
@@ -162,6 +171,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
checkCookies(resp2);
};
+ @Test
public void testSaveRestoreIWSMWithTwoTopics() throws IOException {
MockServletRequest req = new MockServletRequest();
MockServletResponse resp = new MockServletResponse();
@@ -173,7 +183,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
assertNotNull(topic3);
wset.setElements(new AdaptableHelpResource[] { topic1, topic3 });
mgr.addWorkingSet(wset);
-
+
MockServletRequest req2 = new MockServletRequest();
MockServletResponse resp2 = new MockServletResponse();
req2.setCookies(resp.getCookies());
@@ -190,7 +200,8 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
checkCookies(resp);
checkCookies(resp2);
};
-
+
+ @Test
public void testSaveRestoreIWSMWithThreeTopics() throws IOException {
MockServletRequest req = new MockServletRequest();
MockServletResponse resp = new MockServletResponse();
@@ -204,7 +215,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
assertNotNull(topic5);
wset.setElements(new AdaptableHelpResource[] { topic1, topic3, topic5 });
mgr.addWorkingSet(wset);
-
+
MockServletRequest req2 = new MockServletRequest();
MockServletResponse resp2 = new MockServletResponse();
req2.setCookies(resp.getCookies());
@@ -224,6 +235,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
checkCookies(resp2);
};
+ @Test
public void testIWSMWithMultipleWsets() throws IOException {
MockServletRequest req = new MockServletRequest();
MockServletResponse resp = new MockServletResponse();
@@ -240,19 +252,20 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
mgr.addWorkingSet(wset2);
WorkingSet[] readWsets = mgr.getWorkingSets();
assertEquals(2, readWsets.length);
- AdaptableHelpResource[] resourcesT3 = mgr.getWorkingSet("test3").getElements();
+ AdaptableHelpResource[] resourcesT3 = mgr.getWorkingSet("test3").getElements();
assertEquals(1, resourcesT3.length);
assertEquals(topic1, resourcesT3[0]);
- AdaptableHelpResource[] resourcesT4 = mgr.getWorkingSet("test4").getElements();
+ AdaptableHelpResource[] resourcesT4 = mgr.getWorkingSet("test4").getElements();
assertEquals(1, resourcesT4.length);
assertEquals(topic3, resourcesT4[0]);
checkCookies(resp);
};
-
+
/**
* Verify that adding a second topic in the same toc only adds 4 more bytes to the cookie size
* @throws IOException
*/
+ @Test
public void testCookieSizeOptimization() throws IOException {
MockServletRequest req1 = new MockServletRequest();
MockServletResponse resp1 = new MockServletResponse();
@@ -275,7 +288,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
checkCookies(resp1);
checkCookies(resp2);
};
-
+
private int cookieLength(Cookie[] cookies) {
int total = 0;
for (Cookie cookie : cookies) {
@@ -283,7 +296,8 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
}
return total;
}
-
+
+ @Test
public void testSaveRestoreIWSMWithMultipleWsets() throws IOException {
MockServletRequest req = new MockServletRequest();
MockServletResponse resp = new MockServletResponse();
@@ -298,24 +312,25 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
wset2.setElements(new AdaptableHelpResource[] { topic3 });
mgr.addWorkingSet(wset1);
mgr.addWorkingSet(wset2);
-
+
MockServletRequest req2 = new MockServletRequest();
MockServletResponse resp2 = new MockServletResponse();
req2.setCookies(resp.getCookies());
InfocenterWorkingSetManager mgr2 = new InfocenterWorkingSetManager(req2, resp2, "en");
WorkingSet[] readWsets = mgr2.getWorkingSets();
-
+
assertEquals(2, readWsets.length);
- AdaptableHelpResource[] resourcesT3 = mgr2.getWorkingSet("test3").getElements();
+ AdaptableHelpResource[] resourcesT3 = mgr2.getWorkingSet("test3").getElements();
assertEquals(1, resourcesT3.length);
assertEquals(topic1, resourcesT3[0]);
- AdaptableHelpResource[] resourcesT4 = mgr2.getWorkingSet("test4").getElements();
+ AdaptableHelpResource[] resourcesT4 = mgr2.getWorkingSet("test4").getElements();
assertEquals(1, resourcesT4.length);
assertEquals(topic3, resourcesT4[0]);
checkCookies(resp);
checkCookies(resp2);
};
+ @Test
public void testIWSMWithCriteria() throws IOException {
MockServletRequest req = new MockServletRequest();
MockServletResponse resp = new MockServletResponse();
@@ -325,7 +340,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
assertNotNull(toc);
wset.setElements(new AdaptableHelpResource[] { toc });
CriterionResource[] criteria = { new CriterionResource("version") };
- criteria[0].addCriterionValue("1.0");
+ criteria[0].addCriterionValue("1.0");
wset.setCriteria(criteria);
mgr.addWorkingSet(wset);
WorkingSet[] readWsets = mgr.getWorkingSets();
@@ -334,7 +349,8 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
assertEquals(1, readResources.length);
checkCookies(resp);
};
-
+
+ @Test
public void testSaveRestoreIWSMWithMCriteria() throws IOException {
MockServletRequest req = new MockServletRequest();
MockServletResponse resp = new MockServletResponse();
@@ -344,16 +360,16 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
assertNotNull(toc);
wset.setElements(new AdaptableHelpResource[] { toc });
CriterionResource[] criteria = { new CriterionResource("version") };
- criteria[0].addCriterionValue("1.0");
+ criteria[0].addCriterionValue("1.0");
wset.setCriteria(criteria);
mgr.addWorkingSet(wset);
-
+
MockServletRequest req2 = new MockServletRequest();
MockServletResponse resp2 = new MockServletResponse();
req2.setCookies(resp.getCookies());
InfocenterWorkingSetManager mgr2 = new InfocenterWorkingSetManager(req2, resp2, "en");
WorkingSet[] readWsets = mgr2.getWorkingSets();
-
+
assertEquals(1, readWsets.length);
CriterionResource[] readResources = readWsets[0].getCriteria();
assertEquals(1, readResources.length);
@@ -361,6 +377,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
checkCookies(resp2);
};
+ @Test
public void testIWSMWithMultipleCriteria() throws IOException {
MockServletRequest req = new MockServletRequest();
MockServletResponse resp = new MockServletResponse();
@@ -370,9 +387,9 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
assertNotNull(toc);
wset.setElements(new AdaptableHelpResource[] { toc });
CriterionResource[] criteria = { new CriterionResource("version"), new CriterionResource("platform") };
- criteria[0].addCriterionValue("1.0");
- criteria[1].addCriterionValue("linux");
- criteria[1].addCriterionValue("MacOS");
+ criteria[0].addCriterionValue("1.0");
+ criteria[1].addCriterionValue("linux");
+ criteria[1].addCriterionValue("MacOS");
wset.setCriteria(criteria);
mgr.addWorkingSet(wset);
WorkingSet[] readWsets = mgr.getWorkingSets();
@@ -382,6 +399,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
checkCookies(resp);
};
+ @Test
public void testSaveRestoreIWSMWithMultipleCriteria() throws IOException {
MockServletRequest req = new MockServletRequest();
MockServletResponse resp = new MockServletResponse();
@@ -390,7 +408,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
AdaptableToc toc = mgr.getAdaptableToc("/org.eclipse.ua.tests/data/help/toc/root.xml");
assertNotNull(toc);
wset.setElements(new AdaptableHelpResource[] { toc });
- CriterionResource[] criteria = createResourceWithTwoCriteria();
+ CriterionResource[] criteria = createResourceWithTwoCriteria();
wset.setCriteria(criteria);
mgr.addWorkingSet(wset);
MockServletRequest req2 = new MockServletRequest();
@@ -398,7 +416,7 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
req2.setCookies(resp.getCookies());
InfocenterWorkingSetManager mgr2 = new InfocenterWorkingSetManager(req2, resp2, "en");
WorkingSet[] readWsets = mgr2.getWorkingSets();
-
+
assertEquals(1, readWsets.length);
CriterionResource[] readResources = readWsets[0].getCriteria();
checkResourceWithTwoChildren(readResources);
@@ -432,11 +450,11 @@ public class InfocenterWorkingSetManagerTest extends TestCase {
criteria[0] = new CriterionResource("version");
criteria[0].addCriterionValue("1.0");
criteria[1] = new CriterionResource("platform");
- criteria[1].addCriterionValue("linux");
+ criteria[1].addCriterionValue("linux");
criteria[1].addCriterionValue("MacOS");
return criteria;
};
-
+
private void checkCookies(MockServletResponse resp) {
String illegalChars = resp.getIllegalCharatersFound();
if (illegalChars.equals("") || illegalChars.equals("<")) {
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LocaleTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LocaleTest.java
index ff572793a..76a23dccb 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LocaleTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LocaleTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 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
@@ -11,104 +11,118 @@
package org.eclipse.ua.tests.help.search;
-import junit.framework.TestCase;
+import org.junit.Test;
-public class LocaleTest extends TestCase {
-
+public class LocaleTest {
+ @Test
public void testSearchWordInDefaultOnly() {
SearchTestUtils.searchOneLocale("duejrnfjudshebn", new String[] { "/org.eclipse.ua.tests/data/help/search/testnl1.xhtml"}, "en");
SearchTestUtils.searchOneLocale("duejrnfjudshebn", new String[0], "de");
- }
-
+ }
+
+ @Test
public void testSearchWordInNonDefaultOnly() {
SearchTestUtils.searchOneLocale("dkdskadksak", new String[] { "/org.eclipse.ua.tests/data/help/search/testnl1.xhtml"}, "de");
SearchTestUtils.searchOneLocale("dkdskadksak", new String[0], "en");
}
-
+
+ @Test
public void testSearchExactMatchInDefaultOnly() {
SearchTestUtils.searchOneLocale("\"fesaggresgf duejrnfjudshebn\"", new String[] { "/org.eclipse.ua.tests/data/help/search/testnl1.xhtml"}, "en");
SearchTestUtils.searchOneLocale("\"fesaggresgf duejrnfjudshebn\"", new String[0], "de");
- }
-
+ }
+
+ @Test
public void testSearchExactMatchInNonDefaultOnly() {
SearchTestUtils.searchOneLocale("\"dkdskadksak redfrewfdsa\"", new String[] { "/org.eclipse.ua.tests/data/help/search/testnl1.xhtml"}, "de");
SearchTestUtils.searchOneLocale("\"dkdskadksak redfrewfdsa\"", new String[0], "en");
- }
-
+ }
+
+ @Test
public void testSearchWithWildcardInDefaultOnly() {
SearchTestUtils.searchOneLocale("duejrnf?udshebn", new String[] { "/org.eclipse.ua.tests/data/help/search/testnl1.xhtml"}, "en");
SearchTestUtils.searchOneLocale("duejrnf?udshebn", new String[0], "de");
- }
-
+ }
+
+ @Test
public void testSearchWithWildcardInNonDefaultOnly() {
SearchTestUtils.searchOneLocale("dkd?kadksak", new String[] { "/org.eclipse.ua.tests/data/help/search/testnl1.xhtml"}, "de");
SearchTestUtils.searchOneLocale("dkd?kadksak", new String[0], "en");
}
+ @Test
public void testSearchPageNotInTocForLocale() {
SearchTestUtils.searchOneLocale("undefgfdsgfds", new String[0], "de");
SearchTestUtils.searchOneLocale("undefgfdsgfds", new String[0], "en");
}
-
+
+ @Test
public void testSearchPageOnlyInDefaultToc() {
SearchTestUtils.searchOneLocale("idskrekfuej", new String[0], "de");
SearchTestUtils.searchOneLocale("idskrekfuej", new String[] { "/org.eclipse.ua.tests/data/help/search/test_en.html"}, "en");
- }
-
+ }
+
+ @Test
public void testSearchPageOnlyInLocalToc() {
SearchTestUtils.searchOneLocale("deuufjfu", new String[0], "en");
SearchTestUtils.searchOneLocale("deuufjfu", new String[] { "/org.eclipse.ua.tests/data/help/search/test_de.html"}, "de");
}
+ @Test
public void testSearchEnglishStemming_ed() {
SearchTestUtils.searchOneLocale("udjerufdjd", new String[0], "de");
- SearchTestUtils.searchOneLocale("udjerufdjd", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml"}, "en");
+ SearchTestUtils.searchOneLocale("udjerufdjd", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml"}, "en");
}
-
+
+ @Test
public void testSearchEnglishStemming_ing() {
SearchTestUtils.searchOneLocale("kjfdskajdfska", new String[0], "de");
- SearchTestUtils.searchOneLocale("kjfdskajdfska", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml"}, "en");
- }
-
+ SearchTestUtils.searchOneLocale("kjfdskajdfska", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml"}, "en");
+ }
+
// Prefixes are not matched by stemming
+ @Test
public void testSearchEnglishStemming_re() {
SearchTestUtils.searchOneLocale("dhdsahkdshakjd", new String[0], "de");
- SearchTestUtils.searchOneLocale("dhdsahkdshakjd", new String[0], "en");
- }
-
+ SearchTestUtils.searchOneLocale("dhdsahkdshakjd", new String[0], "en");
+ }
+
/**
* Tests that the stemmer properly removes the German "e" suffix.
*/
+ @Test
public void testSearchGermanStemming_e() {
- SearchTestUtils.searchOneLocale("dfskajkfsafaisch", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml"}, "de");
- }
-
+ SearchTestUtils.searchOneLocale("dfskajkfsafaisch", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml"}, "de");
+ }
+
/**
* Tests that the stemmer properly removes the German "en" suffix.
*/
+ @Test
public void testSearchGermanStemming_en() {
- SearchTestUtils.searchOneLocale("kirch", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml"}, "de");
+ SearchTestUtils.searchOneLocale("kirch", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml"}, "de");
SearchTestUtils.searchOneLocale("kirch", new String[0], "en");
}
+ @Test
public void testSearchQualifiedNames_en() {
- SearchTestUtils.searchOneLocale("usjenfdj.udjeudj.uejdhehj", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml" },
+ SearchTestUtils.searchOneLocale("usjenfdj.udjeudj.uejdhehj", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml" },
"en" );
- SearchTestUtils.searchOneLocale("uejdhehj", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml" },
+ SearchTestUtils.searchOneLocale("uejdhehj", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml" },
"en" );
}
/*
* FAILS - see bug Bug 219928
public void testSearchQualifiedNames_de() {
- SearchTestUtils.searchOneLocale("usjenfdj.udjeudj.uejdhehj", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml" },
+ SearchTestUtils.searchOneLocale("usjenfdj.udjeudj.uejdhehj", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml" },
"de" );
- SearchTestUtils.searchOneLocale("uejdhehj", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml" },
+ SearchTestUtils.searchOneLocale("uejdhehj", new String[] { "/org.eclipse.ua.tests/data/help/search/test10.xhtml" },
"de" );
}
*/
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LockTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LockTest.java
index 944eee32d..faa75d1e4 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LockTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LockTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2011, 2016 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
@@ -11,17 +11,20 @@
package org.eclipse.ua.tests.help.search;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.nio.channels.OverlappingFileLockException;
import org.eclipse.help.internal.search.SearchIndex;
-
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Test locking of search index
*/
-public class LockTest extends TestCase {
-
+public class LockTest {
+ @Test
public void testSingleLock() {
SearchIndex index1 = new SearchIndex(null, null, null);
try {
@@ -32,7 +35,8 @@ public class LockTest extends TestCase {
}
index1.releaseLock();
}
-
+
+ @Test
public void testCompetingLocks() {
SearchIndex index1 = new SearchIndex(null, null, null);
try {
@@ -51,8 +55,8 @@ public class LockTest extends TestCase {
index1.releaseLock();
index2.releaseLock();
}
-
+ @Test
public void testNonCompetingLocks() {
SearchIndex index1 = new SearchIndex(null, null, null);
try {
@@ -71,5 +75,5 @@ public class LockTest extends TestCase {
}
index2.releaseLock();
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MetaKeywords.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MetaKeywords.java
index 74f9ae08c..21ea83930 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MetaKeywords.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MetaKeywords.java
@@ -11,6 +11,8 @@
package org.eclipse.ua.tests.help.search;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -19,46 +21,50 @@ 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;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-
-public class MetaKeywords extends TestCase {
+public class MetaKeywords {
+ @Test
public void testKeywordInHtml() {
SearchTestUtils.searchAllLocales("ydhaedrsc", new String[] { "/org.eclipse.ua.tests/data/help/search/testMeta.htm" });
}
-
+
+ @Test
public void testKeywordInXhtml() {
SearchTestUtils.searchAllLocales("olfrgkjrifjd", new String[] { "/org.eclipse.ua.tests/data/help/search/testMeta.xhtml" });
}
+ @Test
public void testDescriptionInHtml() {
SearchHit[] hits = getResultDescriptions("ydhaedrsc", "en");
assertEquals(hits.length, 1);
assertEquals("HTML Meta description", hits[0].getDescription());
}
-
+
+ @Test
public void testDescriptionInXhtml() {
SearchHit[] hits = getResultDescriptions("olfrgkjrifjd", "en");
assertEquals(hits.length, 1);
assertEquals("XHTML Meta description", hits[0].getDescription());
}
-
+
+ @Test
public void testSearchDescriptionInHtml() {
SearchTestUtils.searchAllLocales("basbanba", new String[] { "/org.eclipse.ua.tests/data/help/search/extraDir/testMeta2.htm" });
}
-
+
+ @Test
public void testSearchDescriptionInXhtml() {
SearchTestUtils.searchAllLocales("mfjrudjesm", new String[] { "/org.eclipse.ua.tests/data/help/search/extraDir/testMeta2.xhtml" });
}
-
- private SearchHit[] getResultDescriptions(String searchWord, String nl) {
+
+ private SearchHit[] getResultDescriptions(String searchWord, String nl) {
ISearchQuery query = new SearchQuery(searchWord, false, new ArrayList<String>(), nl);
SearchResults collector = new SearchResults(null, 500, nl);
BaseHelpSystem.getSearchManager().search(query, collector, new NullProgressMonitor());
return collector.getSearchHits();
}
-
-
+
+
}
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 706a0816f..6082293ab 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
@@ -12,6 +12,11 @@
package org.eclipse.ua.tests.help.search;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.File;
import java.io.IOException;
import java.net.URL;
@@ -33,14 +38,13 @@ import org.eclipse.help.internal.search.PluginIndex;
import org.eclipse.help.internal.search.QueryBuilder;
import org.eclipse.help.internal.search.SearchIndexWithIndexingProgress;
import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
+import org.junit.Test;
import org.osgi.framework.Bundle;
-import junit.framework.TestCase;
-
/**
* Verify that older versions of the index can be read by this
- * version of Eclipse.
- *
+ * version of Eclipse.
+ *
* How to maintain this test - if when upgrading to a new version
* of Lucene one of the IndexReadable tests fails you need to
* make the following changes:
@@ -49,53 +53,61 @@ import junit.framework.TestCase;
* 3. Change the help system to recognize that version of Lucene as being incompatible
*/
-public class PrebuiltIndexCompatibility extends TestCase {
+public class PrebuiltIndexCompatibility {
/**
* Test index built with Lucene 1.9.1
*/
+ @Test
public void test1_9_1_IndexReadable() throws Exception {
checkReadable("data/help/searchindex/index191");
}
-
+
/**
* Test index built with Lucene 2.9.1
*/
+ @Test
public void test2_9_1_IndexReadable() throws Exception {
checkReadable("data/help/searchindex/index291");
}
-
+
/**
** Test compatibility of Lucene 1.9.1 index with current Lucene
*/
+ @Test
public void test1_9_1Compatible()
{
checkCompatible("data/help/searchindex/index191", true);
}
-
+
/**
** Test compatibility of Lucene 2.9.1 index with current Lucene
*/
+ @Test
public void test2_9_1Compatible()
{
checkCompatible("data/help/searchindex/index291", true);
}
+ @Test
public void test1_9_1LuceneCompatible()
{
checkLuceneCompatible("1.9.1", true);
}
+ @Test
public void test1_4_103NotLuceneCompatible()
{
checkLuceneCompatible("1.4.103", false);
}
+ @Test
public void test2_9_1LuceneCompatible()
{
checkLuceneCompatible("2.9.1", true);
}
+ @Test
public void testPluginIndexEqualToItself() {
PluginIndex index = createPluginIndex("data/help/searchindex/index191");
assertTrue(index.equals(index));
@@ -104,24 +116,27 @@ public class PrebuiltIndexCompatibility extends TestCase {
/**
* Verify that if the paths and plugins are the same two PluginIndex objects are equal
*/
+ @Test
public void testPluginIndexEquality() {
PluginIndex index1a = createPluginIndex("data/help/searchindex/index191");
PluginIndex index1b = createPluginIndex("data/help/searchindex/index191");
assertTrue(index1a.equals(index1b));
}
-
+
/**
* Verify that if the paths and plugins are the same two PluginIndex objects are equal
*/
+ @Test
public void testPluginIndexHash() {
PluginIndex index1a = createPluginIndex("data/help/searchindex/index191");
PluginIndex index1b = createPluginIndex("data/help/searchindex/index191");
assertEquals(index1a.hashCode(), index1b.hashCode());
}
-
+
/**
* Verify that if the paths are different two PluginIndex objects are not equal
*/
+ @Test
public void testPluginIndexInequality() {
PluginIndex index1 = createPluginIndex("data/help/searchindex/index191");
PluginIndex index2 = createPluginIndex("data/help/searchindex/index291");
@@ -134,7 +149,7 @@ public class PrebuiltIndexCompatibility extends TestCase {
private void checkReadable(String indexPath) throws IOException,
CorruptIndexException {
Path path = new Path(indexPath);
- Bundle bundle = UserAssistanceTestPlugin.getDefault().getBundle();
+ Bundle bundle = UserAssistanceTestPlugin.getDefault().getBundle();
URL url = FileLocator.find(bundle, path, null);
URL resolved = FileLocator.resolve(url);
if ("file".equals(resolved.getProtocol())) { //$NON-NLS-1$
@@ -161,7 +176,7 @@ public class PrebuiltIndexCompatibility extends TestCase {
fail("Cannot resolve to file protocol");
}
}
-
+
/*
* Tests the isCompatible method in PluginIndex
*/
@@ -180,9 +195,9 @@ public class PrebuiltIndexCompatibility extends TestCase {
pluginIndex = new PluginIndex("org.eclipse.ua.tests", "data/help/searchindex/" + versionDirectory, index);
return pluginIndex;
}
-
+
/*
- * Tests the isLuceneCompatible method in SearchIndex
+ * Tests the isLuceneCompatible method in SearchIndex
*/
private void checkLuceneCompatible(String version, boolean expected) {
SearchIndexWithIndexingProgress index = BaseHelpSystem.getLocalSearchManager().getIndex("en_us".toString());
@@ -191,5 +206,5 @@ public class PrebuiltIndexCompatibility extends TestCase {
index);
assertEquals(expected, index.isLuceneCompatible(version));
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchCheatsheet.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchCheatsheet.java
index db1a47d99..10f00acbf 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchCheatsheet.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchCheatsheet.java
@@ -11,6 +11,9 @@
package org.eclipse.ua.tests.help.search;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -20,11 +23,10 @@ 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;
+import org.junit.Test;
-import junit.framework.TestCase;
+public class SearchCheatsheet {
-public class SearchCheatsheet extends TestCase {
-
public SearchHit[] findHits(String searchWord) {
ISearchQuery query = new SearchQuery(searchWord, false, new ArrayList<String>(), Platform.getNL());
SearchResults collector = new SearchResults(null, 10, Platform.getNL());
@@ -32,16 +34,19 @@ public class SearchCheatsheet extends TestCase {
return collector.getSearchHits();
}
+ @Test
public void testCheatSheetTitleSearch() {
SearchHit[] hits = findHits("CSTitle_AhB4U8");
checkForCheatSheetMatch(hits);
}
+ @Test
public void testCheatSheetIntroSearch() {
SearchHit[] hits = findHits("CSIntro_AhB4U8");
checkForCheatSheetMatch(hits);
}
-
+
+ @Test
public void testCheatSheetItemSearch() {
SearchHit[] hits = findHits("CSItem_AhB4U8");
checkForCheatSheetMatch(hits);
@@ -50,21 +55,24 @@ public class SearchCheatsheet extends TestCase {
hits = findHits("CSItemCompletion_AhB4U8");
checkForCheatSheetMatch(hits);
}
-
+
+ @Test
public void testCheatSheetSubitemSearch() {
SearchHit[] hits = findHits("SubItem1_AhB4U8");
checkForCheatSheetMatch(hits);
hits = findHits("SubItem2_AhB4U8");
checkForCheatSheetMatch(hits);
hits = findHits("ConditionalSubItem_AhB4U8");
- checkForCheatSheetMatch(hits);
+ checkForCheatSheetMatch(hits);
}
+ @Test
public void testCompositeTitleSearch() {
SearchHit[] hits = findHits("CompositeName_AhB4U8");
checkForCompositeMatch(hits);
}
+ @Test
public void testCompositeTaskSearch() {
SearchHit[] hits = findHits("TaskName_AhB4U8");
checkForCompositeMatch(hits);
@@ -76,7 +84,8 @@ public class SearchCheatsheet extends TestCase {
hits = findHits("TaskId_AhB4U8");
assertEquals(0, hits.length);
}
-
+
+ @Test
public void testCompositeTaskGroupSearch() {
SearchHit[] hits = findHits("TaskGroup_AhB4U8");
checkForCompositeMatch(hits);
@@ -87,22 +96,22 @@ public class SearchCheatsheet extends TestCase {
}
/*
- * Chech that there was one match, the
+ * Chech that there was one match, the
*/
private void checkForCheatSheetMatch(SearchHit[] hits) {
assertEquals(1, hits.length);
- assertEquals("/org.eclipse.ua.tests/data/cheatsheet/search/CSSearchTest.xml",
+ assertEquals("/org.eclipse.ua.tests/data/cheatsheet/search/CSSearchTest.xml",
ignoreQuery(hits[0].getHref()));
assertTrue(hits[0].getDescription().startsWith("CSIntro_AhB4U8 This cheat sheet is used to test search."));
assertEquals("org.eclipse.ui.cheatsheets/org.eclipse.ua.tests.cheatsheet.searchTest", hits[0].getId());
}
-
+
private void checkForCompositeMatch(SearchHit[] hits) {
assertEquals(1, hits.length);
- assertEquals("/org.eclipse.ua.tests/data/cheatsheet/search/CompositeSearchTest.xml",
+ assertEquals("/org.eclipse.ua.tests/data/cheatsheet/search/CompositeSearchTest.xml",
ignoreQuery(hits[0].getHref()));
assertTrue(hits[0].getDescription().startsWith("Intro text TaskGroupIntro_AhB4U8"));
- assertEquals("org.eclipse.ui.cheatsheets/org.eclipse.ua.tests.composite.searchTest",
+ assertEquals("org.eclipse.ui.cheatsheets/org.eclipse.ua.tests.composite.searchTest",
hits[0].getId());
}
@@ -113,5 +122,5 @@ public class SearchCheatsheet extends TestCase {
}
return href;
}
-
+
}
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
index 091b6c72b..945ad281a 100644
--- 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
@@ -11,6 +11,8 @@
package org.eclipse.ua.tests.help.search;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -20,11 +22,10 @@ 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;
+import org.junit.Test;
-import junit.framework.TestCase;
+public class SearchIntro {
-public class SearchIntro extends TestCase {
-
public SearchHit[] findHits(String searchWord) {
ISearchQuery query = new SearchQuery(searchWord, false, new ArrayList<String>(), Platform.getNL());
SearchResults collector = new SearchResults(null, 10, Platform.getNL());
@@ -32,24 +33,28 @@ public class SearchIntro extends TestCase {
return collector.getSearchHits();
}
+ @Test
public void testSearchIntroGroupLabel() {
SearchHit[] hits = SearchTestUtils.getSearchHits("ifirifjrnfj", "en");
assertEquals(1, hits.length);
}
-
+
+ @Test
public void testSearchIntroGroupText() {
SearchHit[] hits = SearchTestUtils.getSearchHits("nenfhhdhhed", "en");
assertEquals(1, hits.length);
}
-
+
+ @Test
public void testSearchIntroLinkLabel() {
SearchHit[] hits = SearchTestUtils.getSearchHits("hydefefed", "en");
assertEquals(1, hits.length);
}
-
+
+ @Test
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
index 7d9d45789..c6f8ce691 100644
--- 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
@@ -11,51 +11,60 @@
package org.eclipse.ua.tests.help.search;
-import org.eclipse.help.internal.search.SearchHit;
-
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import org.eclipse.help.internal.search.SearchHit;
+import org.junit.Test;
-public class SearchParticipantTest extends TestCase {
+public class SearchParticipantTest {
+ @Test
public void testSearchFirstWordInFirstDoc() {
SearchTestUtils.searchAllLocales("jkijkijkk", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
}
+ @Test
public void testSearchLastWordInFirstDoc() {
SearchTestUtils.searchAllLocales("frgeded", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
}
+ @Test
public void testSearchUsingAndInFirstDoc() {
SearchTestUtils.searchAllLocales("jkijkijkk AND frgeded", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
- }
+ }
+ @Test
public void testSearchUsingAndInSeparateDocs() {
SearchTestUtils.searchAllLocales("jduehdye and olhoykk", new String[0]);
- }
+ }
+ @Test
public void testSearchExactMatch() {
SearchTestUtils.searchAllLocales("\"jkijkijkk frgeded\"", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
}
-
+
+ @Test
public void testSearchExactMatchNotFound() {
SearchTestUtils.searchAllLocales("\"frgeded jkijkijkk\"", new String[0]);
- }
-
+ }
+
+ @Test
public void testSearchWordInSecondDoc() {
SearchTestUtils.searchAllLocales("olhoykk", new String[] { "/org.eclipse.ua.tests/participant2.xml" });
}
+ @Test
public void testReturnedTitle() {
SearchHit[] hits = SearchTestUtils.getSearchHits("jkijkijkk", "en");
assertEquals(hits.length,1);
assertEquals("Title1", hits[0].getLabel());
}
-
+
+ @Test
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
index db2c6561c..cfdc92a12 100644
--- 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
@@ -11,51 +11,59 @@
package org.eclipse.ua.tests.help.search;
-import org.eclipse.help.internal.search.SearchHit;
+import static org.junit.Assert.assertEquals;
-import junit.framework.TestCase;
+import org.eclipse.help.internal.search.SearchHit;
+import org.junit.Test;
-public class SearchParticipantXMLTest extends TestCase {
-
+public class SearchParticipantXMLTest {
+ @Test
public void testSearchFirstWordInFirstDoc() {
SearchTestUtils.searchAllLocales("jfplepdl", new String[] { MockSearchParticipantXML.DOC_1 });
}
+ @Test
public void testSearchLastWordInFirstDoc() {
SearchTestUtils.searchAllLocales("memdjkemd", new String[] { MockSearchParticipantXML.DOC_1 });
}
+ @Test
public void testSearchWordFromOuterElement() {
SearchTestUtils.searchAllLocales("odoeofoedo", new String[] { MockSearchParticipantXML.DOC_2 });
}
-
+
+ @Test
public void testSearchWordFromNestedElement() {
SearchTestUtils.searchAllLocales("odkeofkeks", new String[] { MockSearchParticipantXML.DOC_2 });
}
+ @Test
public void testReturnedTitle() {
SearchHit[] hits = SearchTestUtils.getSearchHits("jfplepdl", "en");
assertEquals(hits.length,1);
assertEquals("Participant XML 1", hits[0].getLabel());
}
-
+
+ @Test
public void testReturnedSummary() {
SearchHit[] hits = SearchTestUtils.getSearchHits("jfplepdl", "en");
assertEquals(hits.length,1);
assertEquals("Summary for file Participant XML1", hits[0].getSummary());
}
+ @Test
public void testReturnedTitleNestedCase() {
SearchHit[] hits = SearchTestUtils.getSearchHits("odoeofoedo", "en");
assertEquals(hits.length,1);
assertEquals("Participant XML 2 - tests nesting", hits[0].getLabel());
}
-
+
+ @Test
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/help/org/eclipse/ua/tests/help/search/SearchRanking.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchRanking.java
index a2c3a76d7..248239f5b 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchRanking.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchRanking.java
@@ -11,6 +11,8 @@
package org.eclipse.ua.tests.help.search;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.Arrays;
@@ -21,11 +23,10 @@ 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;
+import org.junit.Test;
-import junit.framework.TestCase;
+public class SearchRanking {
-public class SearchRanking extends TestCase {
-
public SearchHit[] findHits(String searchWord) {
ISearchQuery query = new SearchQuery(searchWord, false, new ArrayList<String>(), Platform.getNL());
SearchResults collector = new SearchResults(null, 10, Platform.getNL());
@@ -36,6 +37,7 @@ public class SearchRanking extends TestCase {
/**
* Verify that a match in a title has more weight than a match in the body
*/
+ @Test
public void testTitleBoost1() {
SearchHit[] hits = SearchTestUtils.getSearchHits("mjuhgt", "en");
Arrays.sort(hits);
@@ -43,7 +45,8 @@ public class SearchRanking extends TestCase {
assertEquals("/org.eclipse.ua.tests/data/help/search/extraDir/ranking/ranktest1b.htm", getPath(hits[0]));
assertEquals("/org.eclipse.ua.tests/data/help/search/extraDir/ranking/ranktest1a.htm", getPath(hits[1]));
}
-
+
+ @Test
public void testTitleBoost2() {
SearchHit[] hits = SearchTestUtils.getSearchHits("odrgtb", "en");
Arrays.sort(hits);
@@ -51,35 +54,37 @@ public class SearchRanking extends TestCase {
assertEquals("/org.eclipse.ua.tests/data/help/search/extraDir/ranking/ranktest1a.htm", getPath(hits[0]));
assertEquals("/org.eclipse.ua.tests/data/help/search/extraDir/ranking/ranktest1b.htm", getPath(hits[1]));
}
-
+
/**
* Verify that consecutive words raise the weight
*/
+ @Test
public void testConsecutiveWords1() {
SearchHit[] hits = SearchTestUtils.getSearchHits("iduhnf xaqsdab", "en");
Arrays.sort(hits);
assertEquals(2, hits.length);
assertEquals("/org.eclipse.ua.tests/data/help/search/extraDir/ranking/ranktest2b.htm",
getPath(hits[0]));
- assertEquals("/org.eclipse.ua.tests/data/help/search/extraDir/ranking/ranktest2a.htm",
+ assertEquals("/org.eclipse.ua.tests/data/help/search/extraDir/ranking/ranktest2a.htm",
getPath(hits[1]));
}
-
+
+ @Test
public void testConsecutiveWords2() {
SearchHit[] hits = SearchTestUtils.getSearchHits("xaqsdab iduhnf", "en");
Arrays.sort(hits);
assertEquals(2, hits.length);
- assertEquals("/org.eclipse.ua.tests/data/help/search/extraDir/ranking/ranktest2a.htm",
+ assertEquals("/org.eclipse.ua.tests/data/help/search/extraDir/ranking/ranktest2a.htm",
getPath(hits[0]));
- assertEquals("/org.eclipse.ua.tests/data/help/search/extraDir/ranking/ranktest2b.htm",
+ assertEquals("/org.eclipse.ua.tests/data/help/search/extraDir/ranking/ranktest2b.htm",
getPath(hits[1]));
}
-
-
+
+
private String getPath(SearchHit hit) {
String href = hit.getHref();
int query = href.indexOf('?');
return query < 0 ? href : href.substring(0, query);
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/WildcardTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/WildcardTest.java
index e081399f9..868e599d1 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/WildcardTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/WildcardTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 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
@@ -10,49 +10,56 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.search;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-
-public class WildcardTest extends TestCase {
-
+public class WildcardTest {
+ @Test
public void testSearchWithStar() {
SearchTestUtils.searchAllLocales("jehc*qpfjs", new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml" });
}
-
+
+ @Test
public void testSearchWithTwoStars() {
SearchTestUtils.searchAllLocales("jehc*qp*js", new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml" });
}
-
+
+ @Test
public void testSearchWithStarReplacingThreeChars() {
SearchTestUtils.searchAllLocales("jehc*fjs", new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml" });
- }
-
+ }
+
// Test that a star does not match spaces
+ @Test
public void testSearchWithStarReplacingSpace() {
SearchTestUtils.searchAllLocales("jehcyqpfjs*vkrhjewiwh", new String[0]);
}
+ @Test
public void testSearchWithQuestionMark() {
SearchTestUtils.searchAllLocales("jehc?qpfjs", new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml" });
}
+ @Test
public void testSearchWithTwoQuestionMarks() {
SearchTestUtils.searchAllLocales("j?hc?qpfjs", new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml" });
}
+ @Test
public void testSearchQuestionMarkCannotReplaceTwoChars() {
SearchTestUtils.searchAllLocales("jehc?pfjs", new String[0] );
}
+ @Test
public void testSearchSuccessiveQuestionMarks() {
SearchTestUtils.searchAllLocales("jehc??pfjs", new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml" } );
}
+ @Test
public void testSearchLeadingStar() {
SearchTestUtils.searchAllLocales("*hcyqpfjs", new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml" });
}
-
+
+ @Test
public void testSearchLeadingQuestionMark() {
SearchTestUtils.searchAllLocales("?ehcyqpfjs", new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml" });
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/WorkingSetManagerTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/WorkingSetManagerTest.java
index 0ef61cb33..52e540c08 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/WorkingSetManagerTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/WorkingSetManagerTest.java
@@ -1,21 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 IBM Corporation and others.
+ * Copyright (c) 2010, 2016 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
-import junit.framework.TestCase;
-
import org.eclipse.core.runtime.Platform;
import org.eclipse.help.ITopic;
import org.eclipse.help.internal.HelpPlugin;
@@ -27,13 +31,16 @@ import org.eclipse.help.internal.workingset.AdaptableToc;
import org.eclipse.help.internal.workingset.AdaptableTopic;
import org.eclipse.help.internal.workingset.WorkingSet;
import org.eclipse.help.internal.workingset.WorkingSetManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class WorkingSetManagerTest {
-public class WorkingSetManagerTest extends TestCase {
-
private WorkingSet[] workingSets;
-
- @Override
- protected void setUp() throws Exception {
+
+ @Before
+ public void setUp() throws Exception {
WorkingSetManager manager = new WorkingSetManager();
manager.restoreState();
workingSets = manager.getWorkingSets();
@@ -43,8 +50,8 @@ public class WorkingSetManagerTest extends TestCase {
manager.saveState();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
WorkingSetManager manager = new WorkingSetManager();
WorkingSet[] wsetsToRemove = manager.getWorkingSets();
for (WorkingSet element : wsetsToRemove) {
@@ -56,6 +63,7 @@ public class WorkingSetManagerTest extends TestCase {
manager.saveState();
}
+ @Test
public void testNewWSM() {
WorkingSetManager mgr = new WorkingSetManager();
assertEquals(0, mgr.getWorkingSets().length);
@@ -64,6 +72,7 @@ public class WorkingSetManagerTest extends TestCase {
assertEquals(mgr.hashCode(), mgr2.hashCode());
}
+ @Test
public void testWSMWithToc() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset = new WorkingSet("test");
@@ -78,6 +87,7 @@ public class WorkingSetManagerTest extends TestCase {
assertTrue(resources[0].equals(toc));
};
+ @Test
public void testWSMWithTocContainsThatToc() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset = new WorkingSet("test");
@@ -89,7 +99,8 @@ public class WorkingSetManagerTest extends TestCase {
WorkingSetScope scope = new WorkingSetScope("test", mgr, "scope");
assertTrue(scope.inScope(tocs[0]));
};
-
+
+ @Test
public void testWSMWithTocContainsNoOtherToc() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset = new WorkingSet("test");
@@ -104,6 +115,7 @@ public class WorkingSetManagerTest extends TestCase {
}
};
+ @Test
public void testWSMWithTocContainsThatTocsTopics() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset = new WorkingSet("test");
@@ -120,7 +132,8 @@ public class WorkingSetManagerTest extends TestCase {
}
}
};
-
+
+ @Test
public void testWSMWithTocContainsNoOtherTocsTopics() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset = new WorkingSet("test");
@@ -135,7 +148,8 @@ public class WorkingSetManagerTest extends TestCase {
assertTrue(scope.inScope(topic));
}
};
-
+
+ @Test
public void testSaveRestoreWSMWithToc() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset = new WorkingSet("test");
@@ -151,7 +165,8 @@ public class WorkingSetManagerTest extends TestCase {
assertEquals(1, resources.length);
assertTrue(resources[0].equals(toc));
};
-
+
+ @Test
public void testSaveRestoreWSMWithAllTocs() {
WorkingSetManager mgr = new WorkingSetManager();
createWsetWithAllTocs(mgr, "test");
@@ -164,6 +179,7 @@ public class WorkingSetManagerTest extends TestCase {
assertEquals(tocs.length, resources.length);
}
+ @Test
public void testTocInScopeWithAllTocs() {
WorkingSetManager mgr = new WorkingSetManager();
createWsetWithAllTocs(mgr, "test1");
@@ -175,6 +191,7 @@ public class WorkingSetManagerTest extends TestCase {
}
}
+ @Test
public void testTopLevelTopicsInScopeWithAllTocs() {
WorkingSetManager mgr = new WorkingSetManager();
createWsetWithAllTocs(mgr, "test1a");
@@ -187,7 +204,8 @@ public class WorkingSetManagerTest extends TestCase {
}
}
}
-
+
+ @Test
public void testSecondLevelTopicsInScopeWithAllTocs() {
WorkingSetManager mgr = new WorkingSetManager();
createWsetWithAllTocs(mgr, "test1b");
@@ -215,6 +233,7 @@ public class WorkingSetManagerTest extends TestCase {
mgr.addWorkingSet(wset);
};
+ @Test
public void testWSMWithTopics() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset = new WorkingSet("test2");
@@ -238,6 +257,7 @@ public class WorkingSetManagerTest extends TestCase {
}
};
+ @Test
public void testSaveRestoreWSMWithTopics() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset = new WorkingSet("test2");
@@ -263,6 +283,7 @@ public class WorkingSetManagerTest extends TestCase {
}
};
+ @Test
public void testWSMWithMultipleWsets() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset1 = new WorkingSet("test3");
@@ -277,14 +298,15 @@ public class WorkingSetManagerTest extends TestCase {
mgr.addWorkingSet(wset2);
WorkingSet[] readWsets = mgr.getWorkingSets();
assertEquals(2, readWsets.length);
- AdaptableHelpResource[] resourcesT3 = mgr.getWorkingSet("test3").getElements();
+ AdaptableHelpResource[] resourcesT3 = mgr.getWorkingSet("test3").getElements();
assertEquals(1, resourcesT3.length);
assertEquals(topic1, resourcesT3[0]);
- AdaptableHelpResource[] resourcesT4 = mgr.getWorkingSet("test4").getElements();
+ AdaptableHelpResource[] resourcesT4 = mgr.getWorkingSet("test4").getElements();
assertEquals(1, resourcesT4.length);
assertEquals(topic3, resourcesT4[0]);
};
-
+
+ @Test
public void testSaveRestoreWSMWithMultipleWsets() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset1 = new WorkingSet("test3");
@@ -297,19 +319,20 @@ public class WorkingSetManagerTest extends TestCase {
wset2.setElements(new AdaptableHelpResource[] { topic3 });
mgr.addWorkingSet(wset1);
mgr.addWorkingSet(wset2);
-
+
WorkingSetManager mgr2 = new WorkingSetManager();
WorkingSet[] readWsets = mgr2.getWorkingSets();
-
+
assertEquals(2, readWsets.length);
- AdaptableHelpResource[] resourcesT3 = mgr2.getWorkingSet("test3").getElements();
+ AdaptableHelpResource[] resourcesT3 = mgr2.getWorkingSet("test3").getElements();
assertEquals(1, resourcesT3.length);
assertEquals(topic1, resourcesT3[0]);
- AdaptableHelpResource[] resourcesT4 = mgr2.getWorkingSet("test4").getElements();
+ AdaptableHelpResource[] resourcesT4 = mgr2.getWorkingSet("test4").getElements();
assertEquals(1, resourcesT4.length);
assertEquals(topic3, resourcesT4[0]);
};
+ @Test
public void testWSMWithCriteria() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset = new WorkingSet("test5");
@@ -317,7 +340,7 @@ public class WorkingSetManagerTest extends TestCase {
assertNotNull(toc);
wset.setElements(new AdaptableHelpResource[] { toc });
CriterionResource[] criteria = { new CriterionResource("version") };
- criteria[0].addCriterionValue("1.0");
+ criteria[0].addCriterionValue("1.0");
wset.setCriteria(criteria);
mgr.addWorkingSet(wset);
WorkingSet[] readWsets = mgr.getWorkingSets();
@@ -325,7 +348,8 @@ public class WorkingSetManagerTest extends TestCase {
CriterionResource[] readResources = readWsets[0].getCriteria();
assertEquals(1, readResources.length);
};
-
+
+ @Test
public void testSaveRestoreWSMWithMCriteria() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset = new WorkingSet("test6");
@@ -333,19 +357,20 @@ public class WorkingSetManagerTest extends TestCase {
assertNotNull(toc);
wset.setElements(new AdaptableHelpResource[] { toc });
CriterionResource[] criteria = { new CriterionResource("version") };
- criteria[0].addCriterionValue("1.0");
+ criteria[0].addCriterionValue("1.0");
wset.setCriteria(criteria);
mgr.addWorkingSet(wset);
mgr.saveState();
-
+
WorkingSetManager mgr2 = new WorkingSetManager();
WorkingSet[] readWsets = mgr2.getWorkingSets();
-
+
assertEquals(1, readWsets.length);
CriterionResource[] readResources = readWsets[0].getCriteria();
assertEquals(1, readResources.length);
};
+ @Test
public void testWSMWithMultipleCriteria() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset = new WorkingSet("test7");
@@ -353,9 +378,9 @@ public class WorkingSetManagerTest extends TestCase {
assertNotNull(toc);
wset.setElements(new AdaptableHelpResource[] { toc });
CriterionResource[] criteria = { new CriterionResource("version"), new CriterionResource("platform") };
- criteria[0].addCriterionValue("1.0");
- criteria[1].addCriterionValue("linux");
- criteria[1].addCriterionValue("MacOS");
+ criteria[0].addCriterionValue("1.0");
+ criteria[1].addCriterionValue("linux");
+ criteria[1].addCriterionValue("MacOS");
wset.setCriteria(criteria);
mgr.addWorkingSet(wset);
WorkingSet[] readWsets = mgr.getWorkingSets();
@@ -364,20 +389,21 @@ public class WorkingSetManagerTest extends TestCase {
checkResourceWithTwoChildren(readResources);
};
+ @Test
public void testSaveRestoreWSMWithMultipleCriteria() {
WorkingSetManager mgr = new WorkingSetManager();
WorkingSet wset = new WorkingSet("test8");
AdaptableToc toc = mgr.getAdaptableToc("/org.eclipse.ua.tests/data/help/toc/root.xml");
assertNotNull(toc);
wset.setElements(new AdaptableHelpResource[] { toc });
- CriterionResource[] criteria = createResourceWithTwoCriteria();
+ CriterionResource[] criteria = createResourceWithTwoCriteria();
wset.setCriteria(criteria);
mgr.addWorkingSet(wset);
mgr.saveState();
-
+
WorkingSetManager mgr2 = new WorkingSetManager();
WorkingSet[] readWsets = mgr2.getWorkingSets();
-
+
assertEquals(1, readWsets.length);
CriterionResource[] readResources = readWsets[0].getCriteria();
checkResourceWithTwoChildren(readResources);
@@ -409,7 +435,7 @@ public class WorkingSetManagerTest extends TestCase {
criteria[0] = new CriterionResource("version");
criteria[0].addCriterionValue("1.0");
criteria[1] = new CriterionResource("platform");
- criteria[1].addCriterionValue("linux");
+ criteria[1].addCriterionValue("linux");
criteria[1].addCriterionValue("MacOS");
return criteria;
};

Back to the top