Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2016-01-21 08:21:37 +0000
committerAlexander Kurtakov2016-01-21 08:21:37 +0000
commit8cb7a932dab598e3292773d6e25cc3ccead352aa (patch)
treee4183397e3088d788e48c5a29f80498991a3b390
parent3329f0475beca6bba6d0d07aad4db13706b4e174 (diff)
downloadeclipse.platform.ua-8cb7a932dab598e3292773d6e25cc3ccead352aa.tar.gz
eclipse.platform.ua-8cb7a932dab598e3292773d6e25cc3ccead352aa.tar.xz
eclipse.platform.ua-8cb7a932dab598e3292773d6e25cc3ccead352aa.zip
Bug 485918 - Convert org.eclipse.ua.tests to JUnit 4
Migrate help remote, webapp/service, index and scope Change-Id: Ie3373d6819f7c2371ee1bf04d59184576eadb4a1 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/index/IndexAssemblerTest.java28
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContentServletTest.java54
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java45
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/GetContextUsingRemoteHelp.java33
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java50
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadIndexUsingRemoteHelp.java27
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadTocUsingRemoteHelp.java28
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchServletTest.java50
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchUsingRemote.java31
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/RemotePreferenceTest.java48
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchIndexCreation.java31
-rwxr-xr-xorg.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java43
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchUsingRemoteHelp.java52
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocManagerTest.java57
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java48
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/UnionTest.java28
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/AdvancedSearchServiceTest.java26
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContentServiceTest.java24
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContextServiceTest.java19
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java15
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/SearchServiceTest.java26
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java17
22 files changed, 464 insertions, 316 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/index/IndexAssemblerTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/index/IndexAssemblerTest.java
index 5f6857c20..3021a074a 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/index/IndexAssemblerTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/index/IndexAssemblerTest.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.index;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -31,27 +34,27 @@ import org.eclipse.help.internal.index.IndexFile;
import org.eclipse.help.internal.index.IndexFileParser;
import org.eclipse.help.internal.index.IndexSee;
import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-public class IndexAssemblerTest extends TestCase {
-
+public class IndexAssemblerTest {
+ @Test
public void testAssemble() throws Exception {
IndexFileParser parser = new IndexFileParser();
IndexContribution a = parser.parse(new IndexFile(UserAssistanceTestPlugin.getPluginId(), "data/help/index/assembler/a.xml", "en"));
IndexContribution b = parser.parse(new IndexFile(UserAssistanceTestPlugin.getPluginId(), "data/help/index/assembler/b.xml", "en"));
IndexContribution c = parser.parse(new IndexFile(UserAssistanceTestPlugin.getPluginId(), "data/help/index/assembler/c.xml", "en"));
IndexContribution result_a_b_c = parser.parse(new IndexFile(UserAssistanceTestPlugin.getPluginId(), "data/help/index/assembler/result_a_b_c.xml", "en"));
-
+
IndexAssembler assembler = new IndexAssembler();
List<IndexContribution> contributions = new ArrayList<IndexContribution>(Arrays.asList(a, b, c));
Index assembled = assembler.assemble(contributions, Platform.getNL());
-
+
String expected = serialize((UAElement)result_a_b_c.getIndex());
String actual = serialize(assembled);
assertEquals(trimWhiteSpace(expected), trimWhiteSpace(actual));
}
-
+
+ @Test
public void testAssembleWithSeeAlso() throws Exception {
IndexFileParser parser = new IndexFileParser();
IndexContribution contrib = parser.parse(new IndexFile(UserAssistanceTestPlugin.getPluginId(), "data/help/index/assembler/d.xml", "en"));
@@ -78,10 +81,11 @@ public class IndexAssemblerTest extends TestCase {
assertEquals(1, heliosSees.length);
assertEquals("eclipse", heliosSees[0].getKeyword());
}
-
+
+ @Test
public void testTitle() throws Exception{
IndexFileParser parser = new IndexFileParser();
- IndexContribution contrib = parser.parse(new IndexFile(UserAssistanceTestPlugin.getPluginId(), "data/help/index/assembler/hasTitle.xml", "en"));
+ IndexContribution contrib = parser.parse(new IndexFile(UserAssistanceTestPlugin.getPluginId(), "data/help/index/assembler/hasTitle.xml", "en"));
IndexAssembler assembler = new IndexAssembler();
List<IndexContribution> contributions = new ArrayList<IndexContribution>(Arrays.asList(contrib));
Index index = assembler.assemble(contributions, Platform.getNL());
@@ -94,9 +98,9 @@ public class IndexAssemblerTest extends TestCase {
assertEquals("topic1", topics[1].getLabel());
assertEquals("topic2", topics[2].getLabel());
}
-
+
// Replaces white space between ">" and "<" by a single newline
-
+
private String trimWhiteSpace(String input) {
StringBuffer result = new StringBuffer();
boolean betweenElements = false;
@@ -108,7 +112,7 @@ public class IndexAssemblerTest extends TestCase {
if (next == '<') {
betweenElements = false;
}
- }
+ }
} else {
result.append(next);
if (next == '>') {
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContentServletTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContentServletTest.java
index 7772a9ea0..b448d9e18 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContentServletTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContentServletTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 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,68 +10,72 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.remote;
-import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
-import junit.framework.TestCase;
+import java.io.IOException;
import org.eclipse.help.internal.base.BaseHelpSystem;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ContentServletTest {
-public class ContentServletTest extends TestCase {
-
private static final String UA_TESTS = "org.eclipse.ua.tests";
private int mode;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
BaseHelpSystem.ensureWebappRunning();
mode = BaseHelpSystem.getMode();
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
BaseHelpSystem.setMode(mode);
}
+ @Test
public void testSimpleContent() throws Exception {
final String path = "/data/help/index/topic1.html";
String remoteContent = RemoteTestUtils.getRemoteContent(UA_TESTS, path, "en");
- String localContent = RemoteTestUtils.getLocalContent(UA_TESTS, path);
+ String localContent = RemoteTestUtils.getLocalContent(UA_TESTS, path);
assertEquals(remoteContent, localContent);
}
+ @Test
public void testFilteredContent() throws Exception {
final String path = "/data/help/manual/filter.xhtml";
String remoteContent = RemoteTestUtils.getRemoteContent(UA_TESTS, path, "en");
- String localContent = RemoteTestUtils.getLocalContent(UA_TESTS, path);
+ String localContent = RemoteTestUtils.getLocalContent(UA_TESTS, path);
assertEquals(remoteContent, localContent);
}
+ @Test
public void testContentInEnLocale() throws Exception {
final String path = "/data/help/search/testnl1.xhtml";
String remoteContent = RemoteTestUtils.getRemoteContent(UA_TESTS, path, "en");
- String localContent = RemoteTestUtils.getLocalContent(UA_TESTS, path);
+ String localContent = RemoteTestUtils.getLocalContent(UA_TESTS, path);
assertEquals(remoteContent, localContent);
}
-
+
+ @Test
public void testContentInDeLocale() throws Exception {
final String path = "/data/help/search/testnl1.xhtml";
String remoteContent = RemoteTestUtils.getRemoteContent(UA_TESTS, path, "de");
- String enLocalContent = RemoteTestUtils.getLocalContent(UA_TESTS, path);
- String deLocalContent = RemoteTestUtils.getLocalContent(UA_TESTS, "/nl/de" + path);
+ String enLocalContent = RemoteTestUtils.getLocalContent(UA_TESTS, path);
+ String deLocalContent = RemoteTestUtils.getLocalContent(UA_TESTS, "/nl/de" + path);
assertEquals(remoteContent, deLocalContent);
assertFalse(remoteContent.equals(enLocalContent));
}
-
+
+ @Test(expected = IOException.class)
public void testRemoteContentNotFound() throws Exception {
- try {
- RemoteTestUtils.getRemoteContent(UA_TESTS, "/no/such/path.html", "en");
- fail("No exception thrown");
- } catch (IOException e) {
- // Exception caught as expected
- }
+ RemoteTestUtils.getRemoteContent(UA_TESTS, "/no/such/path.html", "en");
}
-
-
+
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java
index b9c540c2d..612969cb6 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 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,6 +11,8 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.remote;
+import static org.junit.Assert.assertEquals;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -23,11 +25,12 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
-import junit.framework.TestCase;
-
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.entityresolver.LocalEntityResolver;
import org.eclipse.help.internal.server.WebappManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -35,42 +38,40 @@ import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-public class ContextServletTest extends TestCase {
-
+public class ContextServletTest {
+
private int mode;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
BaseHelpSystem.ensureWebappRunning();
mode = BaseHelpSystem.getMode();
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
BaseHelpSystem.setMode(mode);
}
+ @Test
public void testRemoteContextFound() throws Exception {
Element[] topics = getContextsFromServlet("org.eclipse.ua.tests.test_cheatsheets");
assertEquals(1, topics.length);
- assertEquals("abcdefg", topics[0].getAttribute("label"));
+ assertEquals("abcdefg", topics[0].getAttribute("label"));
}
-
+
+ @Test
public void testRemoteContextFoundDe() throws Exception {
Element[] topics = getContextsUsingLocale
("org.eclipse.ua.tests.test_cheatsheets", "de");
assertEquals(1, topics.length);
- assertEquals("German Context", topics[0].getAttribute("label"));
+ assertEquals("German Context", topics[0].getAttribute("label"));
}
-
+
+ @Test(expected = IOException.class)
public void testRemoteContextNotFound() throws Exception {
- try {
- getContextsFromServlet("org.eclipse.ua.tests.no_such_context");
- fail("No exception thrown");
- } catch (IOException e) {
- // IO exception caught as expected
- }
+ getContextsFromServlet("org.eclipse.ua.tests.no_such_context");
}
protected Element[] getContextsFromServlet(String phrase)
@@ -79,7 +80,7 @@ public class ContextServletTest extends TestCase {
URL url = new URL("http", "localhost", port, "/help/context?id=" + URLEncoder.encode(phrase, "UTF-8"));
return makeServletCall(url);
}
-
+
protected Element[] getContextsUsingLocale(String phrase, String locale)
throws Exception {
int port = WebappManager.getPort();
@@ -110,5 +111,5 @@ public class ContextServletTest extends TestCase {
}
return topics.toArray(new Element[topics.size()]);
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/GetContextUsingRemoteHelp.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/GetContextUsingRemoteHelp.java
index 9e3cbd4b2..8bd227fc0 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/GetContextUsingRemoteHelp.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/GetContextUsingRemoteHelp.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 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,32 +11,38 @@
package org.eclipse.ua.tests.help.remote;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import org.eclipse.help.IContext;
import org.eclipse.help.IContext3;
import org.eclipse.help.IHelpResource;
import org.eclipse.help.internal.HelpPlugin;
import org.eclipse.help.internal.base.BaseHelpSystem;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class GetContextUsingRemoteHelp {
-public class GetContextUsingRemoteHelp extends TestCase {
-
private int mode;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
RemotePreferenceStore.savePreferences();
mode = BaseHelpSystem.getMode();
RemotePreferenceStore.setMockRemoteServer();
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
RemotePreferenceStore.restorePreferences();
BaseHelpSystem.setMode(mode);
}
+ @Test
public void testContextDefaultLocale() throws Exception {
IContext context = HelpPlugin.getContextManager().getContext("org.eclipse.ua.tests.test_one", "en");
assertNotNull(context);
@@ -50,7 +56,8 @@ public class GetContextUsingRemoteHelp extends TestCase {
context = HelpPlugin.getContextManager().getContext("org.eclipse.ua.tests.test_one", "en");
assertNull(context);
}
-
+
+ @Test
public void testLocalContextBeatsRemote() throws Exception {
IContext context = HelpPlugin.getContextManager().getContext("org.eclipse.ua.tests.test_cheatsheets", "en");
assertNotNull(context);
@@ -59,12 +66,14 @@ public class GetContextUsingRemoteHelp extends TestCase {
String topicLabel = relatedTopics[0].getLabel();
assertEquals("abcdefg", topicLabel);
}
-
+
+ @Test
public void testContextDeLocale() throws Exception {
IContext context = HelpPlugin.getContextManager().getContext("org.eclipse.ua.tests.test_one", "de");
assertEquals("context_one_de", ((IContext3)context).getTitle());
}
-
+
+ @Test
public void testContextNotFound() throws Exception {
IContext context = HelpPlugin.getContextManager().getContext("org.eclipse.ua.tests.no_such_ctx", "en");
assertNull(context);
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java
index 0bb81fff5..e2e2f3c80 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 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,6 +11,8 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.remote;
+import static org.junit.Assert.assertEquals;
+
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
@@ -19,90 +21,104 @@ import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import junit.framework.TestCase;
-
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.entityresolver.LocalEntityResolver;
import org.eclipse.help.internal.server.WebappManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
-public class IndexServletTest extends TestCase {
-
+public class IndexServletTest {
+
private int mode;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
BaseHelpSystem.ensureWebappRunning();
mode = BaseHelpSystem.getMode();
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
BaseHelpSystem.setMode(mode);
}
+ @Test
public void testIndexServletContainsSimpleWord() throws Exception {
Node root = getIndexContributions("en");
Element[] UARoot = findEntryInAllContributions(root, "xyz");
assertEquals(1, UARoot.length);
}
-
+
+ @Test
public void testIndexServletContainsWordWithAccent() throws Exception {
Node root = getIndexContributions("en");
Element[] UARoot = findEntryInAllContributions(root, "\u00E1mbito");
assertEquals(1, UARoot.length);
}
+ @Test
public void testIndexServletContainsWordWithGt() throws Exception {
Node root = getIndexContributions("en");
Element[] UARoot = findEntryInAllContributions(root, "character >");
assertEquals(1, UARoot.length);
}
+ @Test
public void testIndexServletContainsWordWithLt() throws Exception {
Node root = getIndexContributions("en");
Element[] UARoot = findEntryInAllContributions(root, "character <");
assertEquals(1, UARoot.length);
}
+
+ @Test
public void testIndexServletContainsWordWithAmp() throws Exception {
Node root = getIndexContributions("en");
Element[] UARoot = findEntryInAllContributions(root, "character &");
assertEquals(1, UARoot.length);
}
+
+ @Test
public void testIndexServletContainsWordWithQuot() throws Exception {
Node root = getIndexContributions("en");
Element[] UARoot = findEntryInAllContributions(root, "character \"");
assertEquals(1, UARoot.length);
}
+
+ @Test
public void testIndexServletContainsWordWithApostrophe() throws Exception {
Node root = getIndexContributions("en");
Element[] UARoot = findEntryInAllContributions(root, "character '");
assertEquals(1, UARoot.length);
}
+ @Test
public void testDeWordNotInEnIndex() throws Exception {
Node root = getIndexContributions("en");
Element[] UARoot = findEntryInAllContributions(root, "munich");
assertEquals(0, UARoot.length);
}
-
+
+ @Test
public void testWordInDeIndex() throws Exception {
Node root = getIndexContributions("de");
Element[] UARoot = findEntryInAllContributions(root, "munich");
assertEquals(1, UARoot.length);
}
-
+
+ @Test
public void testWordNotInDeIndex() throws Exception {
Node root = getIndexContributions("de");
Element[] UARoot = findEntryInAllContributions(root, "xyz");
assertEquals(0, UARoot.length);
}
-
+
private Element[] findEntryInAllContributions(Node parent, String keyword) {
NodeList contributions = parent.getChildNodes();
List<Node> results = new ArrayList<Node>();
@@ -116,8 +132,8 @@ public class IndexServletTest extends TestCase {
}
}
return results.toArray(new Element[results.size()]);
- }
-
+ }
+
private void findEntryInIndexContribution(Element parent, String keyword,
List<Node> results) {
NodeList indexes = parent.getChildNodes();
@@ -163,5 +179,5 @@ public class IndexServletTest extends TestCase {
assertEquals("indexContributions", root.getNodeName());
return root;
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadIndexUsingRemoteHelp.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadIndexUsingRemoteHelp.java
index a241adbb4..a821e420d 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadIndexUsingRemoteHelp.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadIndexUsingRemoteHelp.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 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,33 +11,37 @@
package org.eclipse.ua.tests.help.remote;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.List;
-import junit.framework.TestCase;
-
import org.eclipse.help.IIndex;
import org.eclipse.help.IIndexEntry;
import org.eclipse.help.internal.HelpPlugin;
import org.eclipse.help.internal.base.BaseHelpSystem;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class LoadIndexUsingRemoteHelp {
-public class LoadIndexUsingRemoteHelp extends TestCase {
-
private int mode;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
RemotePreferenceStore.savePreferences();
mode = BaseHelpSystem.getMode();
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
RemotePreferenceStore.restorePreferences();
BaseHelpSystem.setMode(mode);
}
+ @Test
public void testIndexContribution() throws Exception {
String locale = "en";
HelpPlugin.getIndexManager().clearCache();
@@ -50,7 +54,8 @@ public class LoadIndexUsingRemoteHelp extends TestCase {
assertEquals(1, matchingEntries(index, "entry1_" + locale).length);
assertEquals(1, matchingEntries(index, "entry2_" + locale).length);
}
-
+
+ @Test
public void testIndexWithTwoRemoteServers() throws Exception {
String locale = "en";
HelpPlugin.getIndexManager().clearCache();
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadTocUsingRemoteHelp.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadTocUsingRemoteHelp.java
index 377ab4b3d..110d4892c 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadTocUsingRemoteHelp.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/LoadTocUsingRemoteHelp.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 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,28 +11,32 @@
package org.eclipse.ua.tests.help.remote;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
import org.eclipse.help.internal.HelpPlugin;
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.toc.Toc;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class LoadTocUsingRemoteHelp {
-public class LoadTocUsingRemoteHelp extends TestCase {
-
private int mode;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
RemotePreferenceStore.savePreferences();
mode = BaseHelpSystem.getMode();
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
RemotePreferenceStore.restorePreferences();
BaseHelpSystem.setMode(mode);
}
+ @Test
public void testTocContribution() throws Exception {
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
RemotePreferenceStore.setMockRemoteServer();
@@ -48,7 +52,8 @@ public class LoadTocUsingRemoteHelp extends TestCase {
assertEquals(0, deTocs);
RemotePreferenceStore.disableRemoteHelp();
}
-
+
+ @Test
public void testTocContributionDe() throws Exception {
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
RemotePreferenceStore.setMockRemoteServer();
@@ -64,7 +69,8 @@ public class LoadTocUsingRemoteHelp extends TestCase {
assertEquals(1, deTocs);
RemotePreferenceStore.disableRemoteHelp();
}
-
+
+ @Test
public void testTocContributionFromTwoServers() throws Exception {
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
RemotePreferenceStore.setTwoMockRemoteServers();
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchServletTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchServletTest.java
index 0c91e8539..dfb94bd19 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchServletTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchServletTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * 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
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.remote;
+import static org.junit.Assert.assertEquals;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -22,76 +24,82 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
-import junit.framework.TestCase;
-
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.entityresolver.LocalEntityResolver;
import org.eclipse.help.internal.server.WebappManager;
import org.eclipse.ua.tests.help.util.ParallelTestSupport;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-public class ParallelSearchServletTest extends TestCase {
-
+public class ParallelSearchServletTest {
+
private int mode;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
BaseHelpSystem.ensureWebappRunning();
mode = BaseHelpSystem.getMode();
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
BaseHelpSystem.setMode(mode);
}
-
+
private class SearchServletTester implements ParallelTestSupport.ITestCase {
private String phrase;
private int expectedHits;
-
+
public SearchServletTester(String phrase, int expectedHits) {
this.phrase = phrase;
this.expectedHits = expectedHits;
}
-
+
@Override
public String runTest() throws Exception {
Node[] hits = getSearchHitsFromServlet(phrase);
if (hits.length != expectedHits) {
- return "Searching for " + phrase + " got "
+ return "Searching for " + phrase + " got "
+ hits.length + " hits, expected " + expectedHits;
}
return null;
- }
+ }
}
+ @Test
public void testNotFoundNonParallel() {
ParallelTestSupport.testSingleCase(new SearchServletTester("duernfryehd", 0), 100);
}
-
+
+ @Test
public void testFoundNonParallel() {
ParallelTestSupport.testSingleCase(new SearchServletTester("jehcyqpfjs", 1), 100);
}
+ @Test
public void testNotFoundInParallel() {
- ParallelTestSupport.testInParallel(new SearchServletTester[]
+ ParallelTestSupport.testInParallel(new SearchServletTester[]
{ new SearchServletTester("duernfryehd", 0),
new SearchServletTester("duernfryehd", 0)}, 100);
}
+ @Test
public void testFoundInParallel() {
- ParallelTestSupport.testInParallel(new SearchServletTester[]
+ ParallelTestSupport.testInParallel(new SearchServletTester[]
{ new SearchServletTester("jehcyqpfjs", 1),
new SearchServletTester("jehcyqpfjs", 1)}, 100);
}
-
+
+ @Test
public void testMixedParallelSearches() {
- ParallelTestSupport.testInParallel(new SearchServletTester[]
+ ParallelTestSupport.testInParallel(new SearchServletTester[]
{ new SearchServletTester("jehcyqpfjs", 1),
new SearchServletTester("duernfryehd", 0),
new SearchServletTester("jehcyqpfjs", 1),
@@ -127,5 +135,5 @@ public class ParallelSearchServletTest extends TestCase {
}
return hits.toArray(new Node[hits.size()]);
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchUsingRemote.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchUsingRemote.java
index 1d7ab2c6b..f39874b0c 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchUsingRemote.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchUsingRemote.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * 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
@@ -14,42 +14,44 @@ package org.eclipse.ua.tests.help.remote;
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.ua.tests.help.search.SearchTestUtils;
import org.eclipse.ua.tests.help.util.ParallelTestSupport;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import junit.framework.TestCase;
+public class ParallelSearchUsingRemote {
-public class ParallelSearchUsingRemote extends TestCase {
-
private class Searcher implements ParallelTestSupport.ITestCase {
-
+
private int count = 0;
@Override
public String runTest() throws Exception {
count++;
return SearchTestUtils.searchForExpectedResults
(searchWords[count%3], expectedResults[count%3], "en");
- }
+ }
}
-
+
private int mode;
private String[] searchWords = new String[] {"endfdsadsads", "dedfdsadsads", "jehcyqpfjs" };
- private String[][] expectedResults = new String[][] {
+ private String[][] expectedResults = new String[][] {
new String[] { "http://www.eclipse.org" },
new String[0],
new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml" }
- };
+ };
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
RemotePreferenceStore.savePreferences();
mode = BaseHelpSystem.getMode();
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
RemotePreferenceStore.restorePreferences();
BaseHelpSystem.setMode(mode);
}
+ @Test
public void testSearchOnOneThreadWithRemote() throws Exception {
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
RemotePreferenceStore.setMockRemoteServer();
@@ -57,6 +59,7 @@ public class ParallelSearchUsingRemote extends TestCase {
RemotePreferenceStore.disableRemoteHelp();
}
+ @Test
public void testSearchInParallelWithRemote() throws Exception {
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
RemotePreferenceStore.setMockRemoteServer();
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/RemotePreferenceTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/RemotePreferenceTest.java
index 78efe7ada..097690ffd 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/RemotePreferenceTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/RemotePreferenceTest.java
@@ -11,7 +11,7 @@
package org.eclipse.ua.tests.help.remote;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
@@ -19,29 +19,33 @@ import org.eclipse.help.internal.base.HelpBasePlugin;
import org.eclipse.help.internal.base.IHelpBaseConstants;
import org.eclipse.help.internal.base.remote.PreferenceFileHandler;
import org.eclipse.help.internal.base.remote.RemoteIC;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-public class RemotePreferenceTest extends TestCase {
+public class RemotePreferenceTest {
public static void setPreference(String name, String value) {
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(HelpBasePlugin.PLUGIN_ID);
prefs.put(name, value);
}
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
RemotePreferenceStore.savePreferences();
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
RemotePreferenceStore.restorePreferences();
}
-
+
private void setToDefault(String preference) {
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(HelpBasePlugin.PLUGIN_ID);
prefs.remove(preference);
}
-
+
+ @Test
public void testDefaults() {
setToDefault(IHelpBaseConstants.P_KEY_REMOTE_HELP_NAME);
setToDefault(IHelpBaseConstants.P_KEY_REMOTE_HELP_HOST);
@@ -51,13 +55,14 @@ public class RemotePreferenceTest extends TestCase {
setToDefault(IHelpBaseConstants.P_KEY_REMOTE_HELP_ON);
setToDefault(IHelpBaseConstants.P_KEY_REMOTE_HELP_DEFAULT_PORT);
PreferenceFileHandler handler = new PreferenceFileHandler();
- assertEquals(0, handler.getTotalRemoteInfocenters());
+ assertEquals(0, handler.getTotalRemoteInfocenters());
assertEquals(0, handler.getEnabledEntries().length);
}
/*
* Test the default settings from Eclipse 3.3
*/
+ @Test
public void test33Defaults() {
setPreference("remoteHelpOn", "false");
setPreference("remoteHelpHost", "");
@@ -71,10 +76,11 @@ public class RemotePreferenceTest extends TestCase {
assertEquals(0, handler.getTotalRemoteInfocenters());
assertEquals(0, handler.getEnabledEntries().length);
}
-
+
/*
* Test settings which worked in Eclipse 3.3 to read a remote infocenter
*/
+ @Test
public void test33Remote() {
setPreference("remoteHelpOn", "true");
setPreference("remoteHelpHost", "localhost");
@@ -88,7 +94,8 @@ public class RemotePreferenceTest extends TestCase {
assertEquals(1, handler.getTotalRemoteInfocenters());
assertEquals(1, handler.getEnabledEntries().length);
}
-
+
+ @Test
public void testZeroRemoteInfocenters() {
setPreference("remoteHelpOn", "true");
setPreference("remoteHelpHost", "");
@@ -105,7 +112,8 @@ public class RemotePreferenceTest extends TestCase {
assertEquals(0, handler.getEnabledEntries().length);
assertEquals(0, handler.getPathEntries().length);
}
-
+
+ @Test
public void testOneRemoteInfocenter() {
setPreference("remoteHelpOn", "true");
setPreference("remoteHelpHost", "localhost");
@@ -126,7 +134,8 @@ public class RemotePreferenceTest extends TestCase {
assertEquals(1, handler.getPathEntries().length);
assertEquals("/help", handler.getPathEntries()[0].toLowerCase());
}
-
+
+ @Test
public void testTwoRemoteInfocenters() {
setPreference("remoteHelpHost", "localhost,www.eclipse.org");
setPreference("remoteHelpPath", "/help,/eclipse/help");
@@ -151,6 +160,7 @@ public class RemotePreferenceTest extends TestCase {
assertEquals("/eclipse/help", handler.getPathEntries()[1].toLowerCase());
}
+ @Test
public void testOnePathTwoOfEverythingElse() {
setPreference("remoteHelpOn", "true");
setPreference("remoteHelpHost", "localhost");
@@ -171,7 +181,8 @@ public class RemotePreferenceTest extends TestCase {
assertEquals(1, handler.getPathEntries().length);
assertEquals("/help", handler.getPathEntries()[0].toLowerCase());
}
-
+
+ @Test
public void testPathOnly() {
setPreference("remoteHelpOn", "true");
setPreference("remoteHelpHost", "localhost");
@@ -193,6 +204,7 @@ public class RemotePreferenceTest extends TestCase {
//assertEquals("/help", handler.getPathEntries()[0].toLowerCase());
}
+ @Test
public void testWriteNoRemote() {
PreferenceFileHandler.commitRemoteICs(new RemoteIC[0]);
PreferenceFileHandler handler = new PreferenceFileHandler();
@@ -203,6 +215,7 @@ public class RemotePreferenceTest extends TestCase {
assertEquals(0, handler.getPathEntries().length);
}
+ @Test
public void testWriteOneRemote() {
RemoteIC[] ic = {new RemoteIC(true, "name", "host", "/help", "http","8080")};
PreferenceFileHandler.commitRemoteICs(ic);
@@ -217,7 +230,8 @@ public class RemotePreferenceTest extends TestCase {
assertEquals(1, handler.getPathEntries().length);
assertEquals("/help", handler.getPathEntries()[0].toLowerCase());
}
-
+
+ @Test
public void testWriteTwoRemote() {
RemoteIC[] ic = {new RemoteIC(true, "name", "host", "/help", "http", "8080"),
new RemoteIC(false, "remote", "remotehost", "/help2", "http", "8081")};
@@ -237,5 +251,5 @@ public class RemotePreferenceTest extends TestCase {
assertEquals("/help", handler.getPathEntries()[0].toLowerCase());
assertEquals("/help2", handler.getPathEntries()[1].toLowerCase());
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchIndexCreation.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchIndexCreation.java
index 17d7258d5..0efca40d2 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchIndexCreation.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchIndexCreation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * 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
@@ -11,9 +11,10 @@
package org.eclipse.ua.tests.help.remote;
-import java.net.URL;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
-import junit.framework.TestCase;
+import java.net.URL;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.help.internal.HelpPlugin;
@@ -21,14 +22,17 @@ import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.search.AnalyzerDescriptor;
import org.eclipse.help.internal.search.SearchIndex;
import org.eclipse.help.internal.search.SearchIndexWithIndexingProgress;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SearchIndexCreation {
-public class SearchIndexCreation extends TestCase {
-
private int mode;
private AnalyzerDescriptor analyzerDesc;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
BaseHelpSystem.ensureWebappRunning();
mode = BaseHelpSystem.getMode();
RemotePreferenceStore.savePreferences();
@@ -38,13 +42,14 @@ public class SearchIndexCreation extends TestCase {
HelpPlugin.getTocManager().getTocs("en");
analyzerDesc = new AnalyzerDescriptor("en-us");
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
RemotePreferenceStore.restorePreferences();
BaseHelpSystem.setMode(mode);
}
+ @Test
public void testSearchIndexMakesNoRemoteCalls() throws Throwable {
int initialCallCount = MockContentServlet.getCallcount();
SearchIndexWithIndexingProgress index = new SearchIndexWithIndexingProgress("en-us", analyzerDesc, HelpPlugin
@@ -57,7 +62,8 @@ public class SearchIndexCreation extends TestCase {
int finalCallCount = MockContentServlet.getCallcount();
assertEquals("Remote server called", 0, finalCallCount - initialCallCount);
}
-
+
+ @Test
public void testSearchIndexMakesNoRemoteCalls2() throws Throwable {
int initialCallCount = MockContentServlet.getCallcount();
SearchIndexWithIndexingProgress index = new SearchIndexWithIndexingProgress("en-us", analyzerDesc, HelpPlugin
@@ -70,7 +76,8 @@ public class SearchIndexCreation extends TestCase {
int finalCallCount = MockContentServlet.getCallcount();
assertEquals("Remote server called", 0, finalCallCount - initialCallCount);
}
-
+
+ @Test
public void testSearchIndexMakesNoRemoteCallsRemotePriority() throws Throwable {
RemotePreferenceStore.setMockRemotePriority();
int initialCallCount = MockContentServlet.getCallcount();
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java
index 9a5a89995..3d728fb8a 100755
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 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,6 +11,8 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.remote;
+import static org.junit.Assert.assertEquals;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -23,78 +25,89 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
-import junit.framework.TestCase;
-
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.entityresolver.LocalEntityResolver;
import org.eclipse.help.internal.server.WebappManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-public class SearchServletTest extends TestCase {
-
+public class SearchServletTest {
+
private int mode;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
BaseHelpSystem.ensureWebappRunning();
mode = BaseHelpSystem.getMode();
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
BaseHelpSystem.setMode(mode);
}
-
+
+ @Test
public void testRemoteSearchNotFound() throws Exception {
Node[] hits = getSearchHitsFromServlet("duernfryehd");
assertEquals(0, hits.length);
}
+ @Test
public void testRemoteSearchFound() throws Exception {
Node[] hits = getSearchHitsFromServlet("jehcyqpfjs");
assertEquals(1, hits.length);
}
+ @Test
public void testRemoteSearchOrFound() throws Exception {
Node[] hits = getSearchHitsFromServlet("jehcyqpfjs OR duernfryehd");
assertEquals(1, hits.length);
}
+ @Test
public void testRemoteSearchAndFound() throws Exception {
Node[] hits = getSearchHitsFromServlet("jehcyqpfjs AND vkrhjewiwh");
assertEquals(1, hits.length);
}
+ @Test
public void testRemoteSearchAndNotFound() throws Exception {
Node[] hits = getSearchHitsFromServlet("jehcyqpfjs AND duernfryehd");
assertEquals(0, hits.length);
}
-
+
+ @Test
public void testRemoteSearchExactMatchFound() throws Exception {
Node[] hits = getSearchHitsFromServlet("\"jehcyqpfjs vkrhjewiwh\"");
assertEquals(1, hits.length);
}
+ @Test
public void testRemoteSearchExactMatchNotFound() throws Exception {
Node[] hits = getSearchHitsFromServlet("\"vkrhjewiwh jehcyqpfjs\"");
assertEquals(0, hits.length);
}
+ @Test
public void testRemoteSearchWordNotInDefaultLocale() throws Exception {
Node[] hits = getSearchHitsFromServlet("deuejwuid");
assertEquals(0, hits.length);
}
+ @Test
public void testRemoteSearchUsingDeLocale() throws Exception {
Node[] hits = getSearchHitsUsingLocale("deuejwuid", "de");
assertEquals(1, hits.length);
}
-
+
+ @Test
public void testRemoteSearchUsingEnLocale() throws Exception {
Node[] hits = getSearchHitsUsingLocale("deuejwuid", "en");
assertEquals(0, hits.length);
@@ -106,7 +119,7 @@ public class SearchServletTest extends TestCase {
URL url = new URL("http", "localhost", port, "/help/search?phrase=" + URLEncoder.encode(phrase, "UTF-8"));
return makeServletCall(url);
}
-
+
protected Node[] getSearchHitsUsingLocale(String phrase, String locale)
throws Exception {
int port = WebappManager.getPort();
@@ -137,5 +150,5 @@ public class SearchServletTest extends TestCase {
}
return hits.toArray(new Node[hits.size()]);
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchUsingRemoteHelp.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchUsingRemoteHelp.java
index f53a444fd..b178213aa 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchUsingRemoteHelp.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchUsingRemoteHelp.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 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
@@ -13,62 +13,68 @@ package org.eclipse.ua.tests.help.remote;
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.ua.tests.help.search.SearchTestUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import junit.framework.TestCase;
+public class SearchUsingRemoteHelp {
-public class SearchUsingRemoteHelp extends TestCase {
-
private int mode;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
RemotePreferenceStore.savePreferences();
mode = BaseHelpSystem.getMode();
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
RemotePreferenceStore.restorePreferences();
BaseHelpSystem.setMode(mode);
}
-
+
+ @Test
public void testSearchDefaultLocale() throws Exception {
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
RemotePreferenceStore.setMockRemoteServer();
- SearchTestUtils.searchOneLocale("endfdsadsads", new String[] { "http://www.eclipse.org" },
- "en");
+ SearchTestUtils.searchOneLocale("endfdsadsads", new String[] { "http://www.eclipse.org" },
+ "en");
RemotePreferenceStore.disableRemoteHelp();
- SearchTestUtils.searchOneLocale("endfdsadsads", new String[0], "en");
+ SearchTestUtils.searchOneLocale("endfdsadsads", new String[0], "en");
}
-
+
+ @Test
public void testSearchDefaultLocaleTwoServers() throws Exception {
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
RemotePreferenceStore.setTwoMockRemoteServers();
- SearchTestUtils.searchOneLocale("endfdsadsads", new String[] { "http://www.eclipse.org" },
- "en");
+ SearchTestUtils.searchOneLocale("endfdsadsads", new String[] { "http://www.eclipse.org" },
+ "en");
RemotePreferenceStore.disableRemoteHelp();
- SearchTestUtils.searchOneLocale("endfdsadsads", new String[0], "en");
+ SearchTestUtils.searchOneLocale("endfdsadsads", new String[0], "en");
}
+ @Test
public void testSearchDeWordInDeLocale() throws Exception {
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
RemotePreferenceStore.setMockRemoteServer();
- SearchTestUtils.searchOneLocale("dedfdsadsads", new String[] { "http://www.eclipse.org" }, "de");
+ SearchTestUtils.searchOneLocale("dedfdsadsads", new String[] { "http://www.eclipse.org" }, "de");
RemotePreferenceStore.disableRemoteHelp();
- SearchTestUtils.searchOneLocale("dedfdsadsads", new String[0], "de");
+ SearchTestUtils.searchOneLocale("dedfdsadsads", new String[0], "de");
}
-
+
+ @Test
public void testSearchEnWordInDeLocale() throws Exception {
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
RemotePreferenceStore.setMockRemoteServer();
- SearchTestUtils.searchOneLocale("endfdsadsads", new String[0], "de");
+ SearchTestUtils.searchOneLocale("endfdsadsads", new String[0], "de");
RemotePreferenceStore.disableRemoteHelp();
}
-
+
+ @Test
public void testSearchDeWordInEnLocale() throws Exception {
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
RemotePreferenceStore.setMockRemoteServer();
- SearchTestUtils.searchOneLocale("dedfdsadsads", new String[0], "en");
+ SearchTestUtils.searchOneLocale("dedfdsadsads", new String[0], "en");
RemotePreferenceStore.disableRemoteHelp();
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocManagerTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocManagerTest.java
index 6d42dabab..dfb2f6b5a 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocManagerTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocManagerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 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,8 +10,10 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.remote;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.HashSet;
-import junit.framework.TestCase;
import org.eclipse.help.AbstractTocProvider;
import org.eclipse.help.internal.HelpPlugin;
@@ -19,43 +21,49 @@ import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.base.remote.RemoteTocProvider;
import org.eclipse.help.internal.toc.TocContribution;
import org.eclipse.help.internal.toc.TocFileProvider;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TocManagerTest {
-public class TocManagerTest extends TestCase {
-
private int mode;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
BaseHelpSystem.ensureWebappRunning();
mode = BaseHelpSystem.getMode();
RemotePreferenceStore.savePreferences();
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
BaseHelpSystem.setMode(mode);
RemotePreferenceStore.restorePreferences();
}
+ @Test
public void testDuplicatesOneRemote() throws Exception {
-
+
RemotePreferenceStore.setMockRemoteServer();
HelpPlugin.getTocManager().clearCache();
boolean hasDuplicates=hasDuplicateContributions(HelpPlugin.getTocManager().getTocContributions("en"));
assertFalse(hasDuplicates);
}
-
+
+ @Test
public void testDuplicatesTwoRemote() throws Exception {
-
+
RemotePreferenceStore.setTwoMockRemoteServers();
HelpPlugin.getTocManager().clearCache();
boolean hasDuplicates=hasDuplicateContributions(HelpPlugin.getTocManager().getTocContributions("en"));
assertFalse(hasDuplicates);
}
-
+
+ @Test
public void testLocalProviderPriority() throws Exception {
-
+
int localPriority=0,remotePriority=0;
RemotePreferenceStore.setMockRemoteServer();
RemotePreferenceStore.setMockLocalPriority();
@@ -64,44 +72,45 @@ public class TocManagerTest extends TestCase {
for (AbstractTocProvider tocProvider : tocProviders) {
if(tocProvider instanceof TocFileProvider)
localPriority = tocProvider.getPriority();
-
+
if(tocProvider instanceof RemoteTocProvider)
remotePriority = tocProvider.getPriority();
}
-
+
assertTrue(localPriority<remotePriority);
}
-
+
+ @Test
public void testRemoteProviderPriority() throws Exception {
-
+
RemotePreferenceStore.setMockRemoteServer();
RemotePreferenceStore.setMockRemotePriority();
HelpPlugin.getTocManager().clearCache();
int localPriority=0,remotePriority=0;
-
+
AbstractTocProvider [] tocProviders = HelpPlugin.getTocManager().getTocProviders();
for (AbstractTocProvider tocProvider : tocProviders) {
if(tocProvider instanceof TocFileProvider)
localPriority = tocProvider.getPriority();
-
+
if(tocProvider instanceof RemoteTocProvider)
remotePriority = tocProvider.getPriority();
}
-
+
assertTrue(remotePriority<localPriority);
}
-
+
public static boolean hasDuplicateContributions(TocContribution[] tocContributions)
{
HashSet<String> contributionsFound = new HashSet<String>();
-
+
for (TocContribution tocContribution : tocContributions) {
if(contributionsFound.contains(tocContribution.getId()))
return true;
else
contributionsFound.add(tocContribution.getId());
}
-
+
return false;
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java
index ebd5a0529..42b2e85a4 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 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,6 +11,8 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.remote;
+import static org.junit.Assert.assertEquals;
+
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
@@ -19,51 +21,56 @@ import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import junit.framework.TestCase;
-
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.entityresolver.LocalEntityResolver;
import org.eclipse.help.internal.server.WebappManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
-public class TocServletTest extends TestCase {
-
+public class TocServletTest {
+
private int mode;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
BaseHelpSystem.ensureWebappRunning();
mode = BaseHelpSystem.getMode();
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
BaseHelpSystem.setMode(mode);
}
+ @Test
public void testTocServletContainsUAToc() throws Exception {
Node root = getTocContributions("en");
Element[] UARoot = findContributionById(root, "/org.eclipse.ua.tests/data/help/toc/root.xml");
assertEquals(1, UARoot.length);
}
+ @Test
public void testTocServletContainsFilteredToc() throws Exception {
Node root = getTocContributions("en");
Element[] UARoot = findContributionById(root, "/org.eclipse.ua.tests/data/help/toc/filteredToc/toc.xml");
assertEquals(1, UARoot.length);
}
-
+
+ @Test
public void testTocServletContainsUnlinkedToc() throws Exception {
Node root = getTocContributions("en");
Element[] UARoot = findContributionById(root, "/org.eclipse.ua.tests/data/help/toc/filteredToc/nonPrimaryToc.xml");
assertEquals(1, UARoot.length);
}
-
+
+ @Test
public void testReadEnToc() throws Exception {
Node root = getTocContributions("en");
Element[] uaRoot = findContributionById(root, "/org.eclipse.ua.tests/data/help/search/toc.xml");
@@ -76,8 +83,9 @@ public class TocServletTest extends TestCase {
assertEquals(1, topicEn.length);
Element[] topicDe = findChildren(topicSearch[0], "topic", "label", "testde.html");
assertEquals(0, topicDe.length);
- }
-
+ }
+
+ @Test
public void testReadDeToc() throws Exception {
Node root = getTocContributions("de");
Element[] uaRoot = findContributionById(root, "/org.eclipse.ua.tests/data/help/search/toc.xml");
@@ -91,11 +99,11 @@ public class TocServletTest extends TestCase {
Element[] topicDe = findChildren(topicSearch[0], "topic", "label", "testde.html");
assertEquals(1, topicDe.length);
}
-
+
private Element[] findContributionById(Node root, String id) {
return findChildren(root, "tocContribution", "id", id);
}
-
+
private Element[] findChildren(Node parent, String childKind, String attributeName, String attributeValue) {
NodeList contributions = parent.getChildNodes();
List<Node> results = new ArrayList<Node>();
@@ -104,14 +112,14 @@ public class TocServletTest extends TestCase {
if (next instanceof Element) {
Element nextElement = (Element)next;
if ( childKind.equals(nextElement.getTagName()) && attributeValue.equals(nextElement.getAttribute(attributeName))) {
-
- results.add(next);
+
+ results.add(next);
}
}
}
return results.toArray(new Element[results.size()]);
}
-
+
protected Node getTocContributions( String locale)
throws Exception {
@@ -127,5 +135,5 @@ public class TocServletTest extends TestCase {
assertEquals("tocContributions", root.getNodeName());
return root;
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/UnionTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/UnionTest.java
index 627066cc8..3bc02b4ce 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/UnionTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/UnionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 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
@@ -10,14 +10,16 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.scope;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.eclipse.help.base.AbstractHelpScope;
import org.eclipse.help.internal.base.scope.UnionScope;
import org.eclipse.ua.tests.help.other.UserTopic;
+import org.junit.Test;
+
+public class UnionTest {
-public class UnionTest extends TestCase {
-
private AbstractHelpScope createScope(char char1, char char2) {
AbstractHelpScope result = new UnionScope(
new AbstractHelpScope[]{new MockScope(char1, true),
@@ -25,28 +27,32 @@ public class UnionTest extends TestCase {
return result;
}
+ @Test
public void testInIn() {
UserTopic topic = new UserTopic("ab", "http://www.eclipse.org", true);
AbstractHelpScope scope = createScope('a', 'b');
- assertTrue(scope.inScope(topic));
+ assertTrue(scope.inScope(topic));
}
+ @Test
public void testInOut() {
UserTopic topic = new UserTopic("a", "http://www.eclipse.org", true);
AbstractHelpScope scope = createScope('a', 'b');
- assertTrue(scope.inScope(topic));
+ assertTrue(scope.inScope(topic));
}
-
+
+ @Test
public void testOutIn() {
UserTopic topic = new UserTopic("b", "http://www.eclipse.org", true);
AbstractHelpScope scope = createScope('a', 'b');
- assertTrue(scope.inScope(topic));
+ assertTrue(scope.inScope(topic));
}
-
+
+ @Test
public void testOutOut() {
UserTopic topic = new UserTopic("c", "http://www.eclipse.org", true);
AbstractHelpScope scope = createScope('a', 'b');
- assertFalse(scope.inScope(topic));
+ assertFalse(scope.inScope(topic));
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/AdvancedSearchServiceTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/AdvancedSearchServiceTest.java
index 1609fde19..899b9dc6c 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/AdvancedSearchServiceTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/AdvancedSearchServiceTest.java
@@ -1,21 +1,24 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 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
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ua.tests.help.webapp.service;
+import static org.junit.Assert.assertEquals;
+
import java.net.URL;
import java.net.URLEncoder;
import org.eclipse.help.internal.server.WebappManager;
import org.eclipse.ua.tests.help.remote.SearchServletTest;
+import org.junit.Test;
import org.w3c.dom.Node;
public class AdvancedSearchServiceTest extends SearchServletTest {
@@ -27,7 +30,7 @@ public class AdvancedSearchServiceTest extends SearchServletTest {
URL url = new URL("http", "localhost", port, "/help/vs/service/advancedsearch?searchWord=" + URLEncoder.encode(searchWord, "UTF-8"));
return makeServletCall(url);
}
-
+
@Override
protected Node[] getSearchHitsUsingLocale(String searchWord, String locale)
throws Exception {
@@ -37,33 +40,36 @@ public class AdvancedSearchServiceTest extends SearchServletTest {
return makeServletCall(url);
}
- public void testRemoteSearchXMLSchema()
+ @Test
+ public void testRemoteSearchXMLSchema()
throws Exception {
int port = WebappManager.getPort();
- URL url = new URL("http", "localhost", port,
+ URL url = new URL("http", "localhost", port,
"/help/vs/service/advancedsearch?searchWord=" + URLEncoder.encode("jehcyqpfjs vkrhjewiwh", "UTF-8"));
URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/advancedsearch.xsd");
String schema = schemaUrl.toString();
String uri = url.toString();
String result = SchemaValidator.testXMLSchema(uri, schema);
-
+
assertEquals("URL: \"" + uri + "\" is ", "valid", result);
}
- public void testRemoteSearchXMLSchemaExactMatchFound()
+ @Test
+ public void testRemoteSearchXMLSchemaExactMatchFound()
throws Exception {
int port = WebappManager.getPort();
- URL url = new URL("http", "localhost", port,
+ URL url = new URL("http", "localhost", port,
"/help/vs/service/advancedsearch?searchWord=" + URLEncoder.encode("\"jehcyqpfjs vkrhjewiwh\"", "UTF-8"));
URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/advancedsearch.xsd");
String schema = schemaUrl.toString();
String uri = url.toString();
String result = SchemaValidator.testXMLSchema(uri, schema);
-
+
assertEquals("URL: \"" + uri + "\" is ", "valid", result);
}
- public void testRemoteSearchJSONSchema()
+ @Test
+ public void testRemoteSearchJSONSchema()
throws Exception {
// fail("Not yet implemented.");
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContentServiceTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContentServiceTest.java
index 38d9ce385..21cc4a7f0 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContentServiceTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContentServiceTest.java
@@ -1,24 +1,29 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 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
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ua.tests.help.webapp.service;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
import java.io.IOException;
import org.eclipse.ua.tests.help.remote.ContentServletTest;
+import org.junit.Test;
public class ContentServiceTest extends ContentServletTest {
private static final String UA_TESTS = "org.eclipse.ua.tests";
@Override
+ @Test
public void testSimpleContent() throws Exception {
final String path = "/data/help/index/topic1.html";
String remoteContent = ServicesTestUtils.getRemoteContent(UA_TESTS, path, "en");
@@ -27,6 +32,7 @@ public class ContentServiceTest extends ContentServletTest {
}
@Override
+ @Test
public void testFilteredContent() throws Exception {
final String path = "/data/help/manual/filter.xhtml";
String remoteContent = ServicesTestUtils.getRemoteContent(UA_TESTS, path, "en");
@@ -35,14 +41,16 @@ public class ContentServiceTest extends ContentServletTest {
}
@Override
+ @Test
public void testContentInEnLocale() throws Exception {
final String path = "/data/help/search/testnl1.xhtml";
String remoteContent = ServicesTestUtils.getRemoteContent(UA_TESTS, path, "en");
String localContent = ServicesTestUtils.getLocalContent(UA_TESTS, path);
assertEquals(remoteContent, localContent);
}
-
+
@Override
+ @Test
public void testContentInDeLocale() throws Exception {
final String path = "/data/help/search/testnl1.xhtml";
String remoteContent = ServicesTestUtils.getRemoteContent(UA_TESTS, path, "de");
@@ -51,15 +59,11 @@ public class ContentServiceTest extends ContentServletTest {
assertEquals(remoteContent, deLocalContent);
assertFalse(remoteContent.equals(enLocalContent));
}
-
+
@Override
+ @Test(expected = IOException.class)
public void testRemoteContentNotFound() throws Exception {
- try {
- ServicesTestUtils.getRemoteContent(UA_TESTS, "/no/such/path.html", "en");
- fail("No exception thrown");
- } catch (IOException e) {
- // Exception caught as expected
- }
+ ServicesTestUtils.getRemoteContent(UA_TESTS, "/no/such/path.html", "en");
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContextServiceTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContextServiceTest.java
index 838b42b59..deb2c6050 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContextServiceTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContextServiceTest.java
@@ -1,20 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 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
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ua.tests.help.webapp.service;
+import static org.junit.Assert.assertEquals;
+
import java.net.URL;
import java.net.URLEncoder;
import org.eclipse.help.internal.server.WebappManager;
import org.eclipse.ua.tests.help.remote.ContextServletTest;
+import org.junit.Test;
import org.w3c.dom.Element;
public class ContextServiceTest extends ContextServletTest {
@@ -23,11 +26,11 @@ public class ContextServiceTest extends ContextServletTest {
protected Element[] getContextsFromServlet(String phrase)
throws Exception {
int port = WebappManager.getPort();
- URL url = new URL("http", "localhost", port, "/help/vs/service/context?id="
+ URL url = new URL("http", "localhost", port, "/help/vs/service/context?id="
+ URLEncoder.encode(phrase, "UTF-8"));
return makeServletCall(url);
}
-
+
@Override
protected Element[] getContextsUsingLocale(String phrase, String locale)
throws Exception {
@@ -37,7 +40,8 @@ public class ContextServiceTest extends ContextServletTest {
return makeServletCall(url);
}
- public void testContextServiceXMLSchema()
+ @Test
+ public void testContextServiceXMLSchema()
throws Exception {
int port = WebappManager.getPort();
URL url = new URL("http", "localhost", port, "/help/vs/service/context?id=org.eclipse.ua.tests.test_cheatsheets&lang=en");
@@ -45,11 +49,12 @@ public class ContextServiceTest extends ContextServletTest {
String schema = schemaUrl.toString();
String uri = url.toString();
String result = SchemaValidator.testXMLSchema(uri, schema);
-
+
assertEquals("URL: \"" + uri + "\" is ", "valid", result);
}
- public void testContextServiceJSONSchema()
+ @Test
+ public void testContextServiceJSONSchema()
throws Exception {
// fail("Not yet implemented.");
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java
index d1e0d2faf..1a44ae15d 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java
@@ -1,15 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 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
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ua.tests.help.webapp.service;
+import static org.junit.Assert.assertEquals;
+
import java.io.InputStream;
import java.net.URL;
@@ -19,6 +21,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.eclipse.help.internal.entityresolver.LocalEntityResolver;
import org.eclipse.help.internal.server.WebappManager;
import org.eclipse.ua.tests.help.remote.IndexServletTest;
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
@@ -41,7 +44,8 @@ public class IndexServiceTest extends IndexServletTest {
return root;
}
- public void testIndexServiceXMLSchema()
+ @Test
+ public void testIndexServiceXMLSchema()
throws Exception {
int port = WebappManager.getPort();
URL url = new URL("http", "localhost", port, "/help/vs/service/index?lang=en");
@@ -49,11 +53,12 @@ public class IndexServiceTest extends IndexServletTest {
String schema = schemaUrl.toString();
String uri = url.toString();
String result = SchemaValidator.testXMLSchema(uri, schema);
-
+
assertEquals("URL: \"" + uri + "\" is ", "valid", result);
}
- public void testIndexServiceJSONSchema()
+ @Test
+ public void testIndexServiceJSONSchema()
throws Exception {
// fail("Not yet implemented.");
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/SearchServiceTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/SearchServiceTest.java
index 6aa0eed76..9c65668cd 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/SearchServiceTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/SearchServiceTest.java
@@ -1,21 +1,24 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 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
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ua.tests.help.webapp.service;
+import static org.junit.Assert.assertEquals;
+
import java.net.URL;
import java.net.URLEncoder;
import org.eclipse.help.internal.server.WebappManager;
import org.eclipse.ua.tests.help.remote.SearchServletTest;
+import org.junit.Test;
import org.w3c.dom.Node;
public class SearchServiceTest extends SearchServletTest {
@@ -27,7 +30,7 @@ public class SearchServiceTest extends SearchServletTest {
URL url = new URL("http", "localhost", port, "/help/vs/service/search?phrase=" + URLEncoder.encode(phrase, "UTF-8"));
return makeServletCall(url);
}
-
+
@Override
protected Node[] getSearchHitsUsingLocale(String phrase, String locale)
throws Exception {
@@ -37,33 +40,36 @@ public class SearchServiceTest extends SearchServletTest {
return makeServletCall(url);
}
- public void testRemoteSearchXMLSchema()
+ @Test
+ public void testRemoteSearchXMLSchema()
throws Exception {
int port = WebappManager.getPort();
- URL url = new URL("http", "localhost", port,
+ URL url = new URL("http", "localhost", port,
"/help/vs/service/search?phrase=" + URLEncoder.encode("jehcyqpfjs vkrhjewiwh", "UTF-8"));
URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/search.xsd");
String schema = schemaUrl.toString();
String uri = url.toString();
String result = SchemaValidator.testXMLSchema(uri, schema);
-
+
assertEquals("URL: \"" + uri + "\" is ", "valid", result);
}
- public void testRemoteSearchXMLSchemaExactMatchFound()
+ @Test
+ public void testRemoteSearchXMLSchemaExactMatchFound()
throws Exception {
int port = WebappManager.getPort();
- URL url = new URL("http", "localhost", port,
+ URL url = new URL("http", "localhost", port,
"/help/vs/service/search?phrase=" + URLEncoder.encode("\"jehcyqpfjs vkrhjewiwh\"", "UTF-8"));
URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/search.xsd");
String schema = schemaUrl.toString();
String uri = url.toString();
String result = SchemaValidator.testXMLSchema(uri, schema);
-
+
assertEquals("URL: \"" + uri + "\" is ", "valid", result);
}
- public void testRemoteSearchJSONSchema()
+ @Test
+ public void testRemoteSearchJSONSchema()
throws Exception {
// fail("Not yet implemented.");
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java
index 87f2b8f8a..84458b2fd 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java
@@ -1,15 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 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
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ua.tests.help.webapp.service;
+import static org.junit.Assert.assertEquals;
+
import java.io.InputStream;
import java.net.URL;
@@ -19,6 +21,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.eclipse.help.internal.entityresolver.LocalEntityResolver;
import org.eclipse.help.internal.server.WebappManager;
import org.eclipse.ua.tests.help.remote.TocServletTest;
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
@@ -43,7 +46,7 @@ public class TocServiceTest extends TocServletTest {
/*
* Disabled, see Bug 339274
- public void testTocServiceXMLSchema()
+ public void testTocServiceXMLSchema()
throws Exception {
int port = WebappManager.getPort();
URL url = new URL("http", "localhost", port, "/help/vs/service/toc?lang=en");
@@ -51,12 +54,12 @@ public class TocServiceTest extends TocServletTest {
String schema = schemaUrl.toString();
String uri = url.toString();
String result = SchemaValidator.testXMLSchema(uri, schema);
-
+
assertEquals("URL: \"" + uri + "\" is ", "valid", result);
}
*/
-
- public void testTocServiceJSONSchema()
+ @Test
+ public void testTocServiceJSONSchema()
throws Exception {
/*int port = WebappManager.getPort();
URL url = new URL("http", "localhost", port, "/help/vs/service/toc?lang=en");
@@ -64,7 +67,7 @@ public class TocServiceTest extends TocServletTest {
String schema = schemaUrl.toString();
String uri = url.toString();
String result = SchemaValidator.testJSONSchema(uri, schema);
-
+
assertEquals("URL: \"" + uri + "\" is ", "valid", result);*/
// fail("Not yet implemented.");
}

Back to the top