Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Austin2011-03-02 21:06:00 +0000
committerChris Austin2011-03-02 21:06:00 +0000
commitf80d928f29a67bfad5d8779e0d916627e5c035d7 (patch)
tree3eae5c4a5e0e05a8062c9bdaeffca2bad7056034 /org.eclipse.ua.tests/help/org
parent6954a216bfa05fb8ce639426c60a2c5d211e1512 (diff)
downloadeclipse.platform.ua-f80d928f29a67bfad5d8779e0d916627e5c035d7.tar.gz
eclipse.platform.ua-f80d928f29a67bfad5d8779e0d916627e5c035d7.tar.xz
eclipse.platform.ua-f80d928f29a67bfad5d8779e0d916627e5c035d7.zip
Bug 319907 - [Help] Promote main help servlets to public API
Diffstat (limited to 'org.eclipse.ua.tests/help/org')
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/AllHelpTests.java4
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java7
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java3
-rwxr-xr-xorg.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java7
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java3
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/AdvancedSearchServiceTest.java69
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/AllWebappServiceTests.java41
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContentServiceTest.java60
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContextServiceTest.java55
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ExtensionServiceTest.java161
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexFragmentServiceTest.java82
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java60
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/SchemaValidator.java55
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/SearchServiceTest.java69
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ServicesTestUtils.java41
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java169
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java68
17 files changed, 945 insertions, 9 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/AllHelpTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/AllHelpTests.java
index 78996dbd1..06bee8eaf 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/AllHelpTests.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/AllHelpTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * Copyright (c) 2006, 2011 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
@@ -23,6 +23,7 @@ import org.eclipse.ua.tests.help.scope.AllScopeTests;
import org.eclipse.ua.tests.help.search.AllSearchTests;
import org.eclipse.ua.tests.help.toc.AllTocTests;
import org.eclipse.ua.tests.help.webapp.AllWebappTests;
+import org.eclipse.ua.tests.help.webapp.service.AllWebappServiceTests;
/*
* Tests help functionality (automated).
@@ -50,5 +51,6 @@ public class AllHelpTests extends TestSuite {
addTest(AllOtherHelpTests.suite());
addTest(AllRemoteTests.suite());
addTest(AllScopeTests.suite());
+ addTest(AllWebappServiceTests.suite());
}
}
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 917cfd653..16bb41b58 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services
*******************************************************************************/
package org.eclipse.ua.tests.help.remote;
@@ -70,14 +71,14 @@ public class ContextServletTest extends TestCase {
}
}
- private Element[] getContextsFromServlet(String phrase)
+ protected Element[] getContextsFromServlet(String phrase)
throws Exception {
int port = WebappManager.getPort();
URL url = new URL("http", "localhost", port, "/help/context?id=" + URLEncoder.encode(phrase, "UTF-8"));
return makeServletCall(url);
}
- private Element[] getContextsUsingLocale(String phrase, String locale)
+ protected Element[] getContextsUsingLocale(String phrase, String locale)
throws Exception {
int port = WebappManager.getPort();
URL url = new URL("http", "localhost", port, "/help/context?id="
@@ -85,7 +86,7 @@ public class ContextServletTest extends TestCase {
return makeServletCall(url);
}
- private Element[] makeServletCall(URL url) throws IOException,
+ protected Element[] makeServletCall(URL url) throws IOException,
ParserConfigurationException, FactoryConfigurationError,
SAXException {
InputStream is = url.openStream();
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 ca9e0f40f..2f4c41d79 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services
*******************************************************************************/
package org.eclipse.ua.tests.help.remote;
@@ -146,7 +147,7 @@ public class IndexServletTest extends TestCase {
}
}
- private Node getIndexContributions( String locale)
+ protected Node getIndexContributions( String locale)
throws Exception {
int port = WebappManager.getPort();
URL url = new URL("http", "localhost", port, "/help/index?lang=" + locale);
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 b2eaf5d99..4cc36c1dc 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services
*******************************************************************************/
package org.eclipse.ua.tests.help.remote;
@@ -97,14 +98,14 @@ public class SearchServletTest extends TestCase {
assertEquals(0, hits.length);
}
- private Node[] getSearchHitsFromServlet(String phrase)
+ protected Node[] getSearchHitsFromServlet(String phrase)
throws Exception {
int port = WebappManager.getPort();
URL url = new URL("http", "localhost", port, "/help/search?phrase=" + URLEncoder.encode(phrase, "UTF-8"));
return makeServletCall(url);
}
- private Node[] getSearchHitsUsingLocale(String phrase, String locale)
+ protected Node[] getSearchHitsUsingLocale(String phrase, String locale)
throws Exception {
int port = WebappManager.getPort();
URL url = new URL("http", "localhost", port, "/help/search?phrase="
@@ -112,7 +113,7 @@ public class SearchServletTest extends TestCase {
return makeServletCall(url);
}
- private Node[] makeServletCall(URL url) throws IOException,
+ protected Node[] makeServletCall(URL url) throws IOException,
ParserConfigurationException, FactoryConfigurationError,
SAXException {
InputStream is = url.openStream();
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 fda5de956..bd1fe780a 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Snehasish Paul <snehpaul@in.ibm.com> - Eclipse help public API services
*******************************************************************************/
package org.eclipse.ua.tests.help.remote;
@@ -110,7 +111,7 @@ public class TocServletTest extends TestCase {
}
- private Node getTocContributions( String locale)
+ protected Node getTocContributions( String locale)
throws Exception {
int port = WebappManager.getPort();
URL url = new URL("http", "localhost", port, "/help/toc?lang=" + locale);
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
new file mode 100644
index 000000000..36d288891
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/AdvancedSearchServiceTest.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 java.net.URL;
+import java.net.URLEncoder;
+
+import org.eclipse.help.internal.server.WebappManager;
+import org.eclipse.ua.tests.help.remote.SearchServletTest;
+import org.w3c.dom.Node;
+
+public class AdvancedSearchServiceTest extends SearchServletTest {
+
+ protected Node[] getSearchHitsFromServlet(String searchWord)
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/advancedsearch?searchWord=" + URLEncoder.encode(searchWord, "UTF-8"));
+ return makeServletCall(url);
+ }
+
+ protected Node[] getSearchHitsUsingLocale(String searchWord, String locale)
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/advancedsearch?searchWord="
+ + URLEncoder.encode(searchWord, "UTF-8") + "&lang=" + locale);
+ return makeServletCall(url);
+ }
+
+ public void testRemoteSearchXMLSchema()
+ throws Exception {
+ int port = WebappManager.getPort();
+ 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()
+ throws Exception {
+ int port = WebappManager.getPort();
+ 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()
+ throws Exception {
+// fail("Not yet implemented.");
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/AllWebappServiceTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/AllWebappServiceTests.java
new file mode 100644
index 000000000..dc2a167f8
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/AllWebappServiceTests.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 junit.framework.Test;
+import junit.framework.TestSuite;
+
+/*
+ * Tests utility classes and servlets used in Web Application
+ */
+public class AllWebappServiceTests extends TestSuite {
+
+ /*
+ * Returns the entire test suite.
+ */
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "org.eclipse.ua.tests.help.AllWebappServiceTests");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(AdvancedSearchServiceTest.class);
+ suite.addTestSuite(ContentServiceTest.class);
+ suite.addTestSuite(ContextServiceTest.class);
+ suite.addTestSuite(ExtensionServiceTest.class);
+ suite.addTestSuite(IndexFragmentServiceTest.class);
+ suite.addTestSuite(IndexServiceTest.class);
+ suite.addTestSuite(SearchServiceTest.class);
+ suite.addTestSuite(TocFragmentServiceTest.class);
+ suite.addTestSuite(TocServiceTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
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
new file mode 100644
index 000000000..96264b8dc
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContentServiceTest.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 java.io.IOException;
+
+import org.eclipse.ua.tests.help.remote.ContentServletTest;
+
+public class ContentServiceTest extends ContentServletTest {
+
+ private static final String UA_TESTS = "org.eclipse.ua.tests";
+
+ public void testSimpleContent() throws Exception {
+ final String path = "/data/help/index/topic1.html";
+ String remoteContent = ServicesTestUtils.getRemoteContent(UA_TESTS, path, "en");
+ String localContent = ServicesTestUtils.getLocalContent(UA_TESTS, path);
+ assertEquals(remoteContent, localContent);
+ }
+
+ public void testFilteredContent() throws Exception {
+ final String path = "/data/help/manual/filter.xhtml";
+ String remoteContent = ServicesTestUtils.getRemoteContent(UA_TESTS, path, "en");
+ String localContent = ServicesTestUtils.getLocalContent(UA_TESTS, path);
+ assertEquals(remoteContent, localContent);
+ }
+
+ 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);
+ }
+
+ public void testContentInDeLocale() throws Exception {
+ final String path = "/data/help/search/testnl1.xhtml";
+ String remoteContent = ServicesTestUtils.getRemoteContent(UA_TESTS, path, "de");
+ String enLocalContent = ServicesTestUtils.getLocalContent(UA_TESTS, path);
+ String deLocalContent = ServicesTestUtils.getLocalContent(UA_TESTS, "/nl/de" + path);
+ assertEquals(remoteContent, deLocalContent);
+ assertFalse(remoteContent.equals(enLocalContent));
+ }
+
+ 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
+ }
+ }
+
+}
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
new file mode 100644
index 000000000..08d681832
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ContextServiceTest.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 java.net.URL;
+import java.net.URLEncoder;
+
+import org.eclipse.help.internal.server.WebappManager;
+import org.eclipse.ua.tests.help.remote.ContextServletTest;
+import org.w3c.dom.Element;
+
+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="
+ + URLEncoder.encode(phrase, "UTF-8"));
+ return makeServletCall(url);
+ }
+
+ protected Element[] getContextsUsingLocale(String phrase, String locale)
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/context?id="
+ + URLEncoder.encode(phrase, "UTF-8") + "&lang=" + locale);
+ return makeServletCall(url);
+ }
+
+ 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");
+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/context.xsd");
+ String schema = schemaUrl.toString();
+ String uri = url.toString();
+ String result = SchemaValidator.testXMLSchema(uri, schema);
+
+ assertEquals("URL: \"" + uri + "\" is ", "valid", result);
+ }
+
+ public void testContextServiceJSONSchema()
+ throws Exception {
+// fail("Not yet implemented.");
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ExtensionServiceTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ExtensionServiceTest.java
new file mode 100644
index 000000000..0000efc5c
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ExtensionServiceTest.java
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+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.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 ExtensionServiceTest extends TestCase {
+
+ private int mode;
+
+ protected void setUp() throws Exception {
+ BaseHelpSystem.ensureWebappRunning();
+ mode = BaseHelpSystem.getMode();
+ BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
+ }
+
+ protected void tearDown() throws Exception {
+ BaseHelpSystem.setMode(mode);
+ }
+
+ public void testExtensionServiceContributionExactMatch1() throws Exception {
+ Node root = getContentExtensions("en");
+ Element[] UARoot = findContributionByContent(root,
+ "/org.eclipse.ua.tests/data/help/dynamic/shared/doc2.xml#element.1");
+ assertEquals(1, UARoot.length);
+ }
+
+ public void testExtensionServiceContributionExactMatch3() throws Exception {
+ Node root = getContentExtensions("en");
+ Element[] UARoot = findContributionByContent(root,
+ "/org.eclipse.ua.tests/data/help/dynamic/shared/doc2.xml#element.3");
+ assertEquals(1, UARoot.length);
+ }
+
+ public void testExtensionServiceContributionNoMatch() throws Exception {
+ Node root = getContentExtensions("en");
+ Element[] UARoot = findContributionByContent(root,
+ "/org.eclipse.ua.tests/data/help/dynamic/shared/doc2.xml#element.4");
+ assertEquals(0, UARoot.length);
+ }
+
+ public void testExtensionServiceContributionByPath() throws Exception {
+ Node root = getContentExtensions("en");
+ Element[] UARoot = findContributionByPath(root,
+ "/org.eclipse.ua.tests/data/help/dynamic/extension.xml#anchor.invalidcontribution");
+ assertEquals(2, UARoot.length);
+ }
+
+ public void testExtensionServiceReplacementExactMatch() throws Exception {
+ Node root = getContentExtensions("en");
+ Element[] UARoot = findReplacementByContent(root,
+ "/org.eclipse.ua.tests/data/help/dynamic/shared/doc2.xml#element.1");
+ assertEquals(1, UARoot.length);
+ }
+
+ public void testExtensionServiceReplacementNoMatch() throws Exception {
+ Node root = getContentExtensions("en");
+ Element[] UARoot = findReplacementByContent(root,
+ "/org.eclipse.ua.tests/data/help/dynamic/shared/doc2.xml#element.3");
+ assertEquals(0, UARoot.length);
+ }
+
+ public void testExtensionServiceReplacementByPath() throws Exception {
+ Node root = getContentExtensions("en");
+ Element[] UARoot = findReplacementByPath(root,
+ "/org.eclipse.ua.tests/data/help/dynamic/shared/doc1.xml#element.2");
+ assertEquals(1, UARoot.length);
+ }
+
+ private Element[] findContributionByContent(Node root, String content) {
+ return findChildren(root, "contribution", "content", content);
+ }
+
+ private Element[] findContributionByPath(Node root, String path) {
+ return findChildren(root, "contribution", "path", path);
+ }
+
+ private Element[] findReplacementByContent(Node root, String content) {
+ return findChildren(root, "replacement", "content", content);
+ }
+
+ private Element[] findReplacementByPath(Node root, String path) {
+ return findChildren(root, "replacement", "path", path);
+ }
+
+ private Element[] findChildren(Node parent, String childKind,
+ String attributeName, String attributeValue) {
+ NodeList contributions = parent.getChildNodes();
+ List<Node> results = new ArrayList<Node>();
+ for (int i = 0; i < contributions.getLength(); i++) {
+ Node next = contributions.item(i);
+ if (next instanceof Element) {
+ Element nextElement = (Element)next;
+ if ( childKind.equals(nextElement.getTagName()) && attributeValue.equals(nextElement.getAttribute(attributeName))) {
+
+ results.add(next);
+ }
+ }
+ }
+ return results.toArray(new Element[results.size()]);
+ }
+
+ private Node getContentExtensions(String locale)
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/extension?lang=" + locale);
+ InputStream is = url.openStream();
+ InputSource inputSource = new InputSource(is);
+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ documentBuilder.setEntityResolver(new LocalEntityResolver());
+ Document document = documentBuilder.parse(inputSource);
+ Node root = document.getFirstChild();
+ is.close();
+ assertEquals("contentExtensions", root.getNodeName());
+ return root;
+ }
+
+ public void testExtensionFragmentServiceXMLSchema()
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/extension?lang=en");
+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/extension.xsd");
+ String schema = schemaUrl.toString();
+ String uri = url.toString();
+ String result = SchemaValidator.testXMLSchema(uri, schema);
+
+ assertEquals("URL: \"" + uri + "\" is ", "valid", result);
+ }
+
+ public void testExtensionFragmentServiceJSONSchema()
+ throws Exception {
+// fail("Not yet implemented.");
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexFragmentServiceTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexFragmentServiceTest.java
new file mode 100644
index 000000000..e488d07b3
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexFragmentServiceTest.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 java.io.InputStream;
+import java.net.URL;
+
+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.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+public class IndexFragmentServiceTest extends TestCase {
+
+ private int mode;
+
+ protected void setUp() throws Exception {
+ BaseHelpSystem.ensureWebappRunning();
+ mode = BaseHelpSystem.getMode();
+ BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
+ }
+
+ protected void tearDown() throws Exception {
+ BaseHelpSystem.setMode(mode);
+ }
+
+ public void testIndexServletEn() throws Exception {
+ getTreeData("en");
+ }
+
+ public void testIndexServletDe() throws Exception {
+ getTreeData("de");
+ }
+
+ private void getTreeData(String locale)
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/indexfragment?lang=" + locale);
+ InputStream is = url.openStream();
+ InputSource inputSource = new InputSource(is);
+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ documentBuilder.setEntityResolver(new LocalEntityResolver());
+ Document document = documentBuilder.parse(inputSource);
+ Node root = document.getFirstChild();
+ is.close();
+ assertEquals("tree_data", root.getNodeName());
+ }
+
+ public void testIndexFragmentServiceXMLSchema()
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/indexfragment?lang=en");
+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/indexfragment.xsd");
+ String schema = schemaUrl.toString();
+ String uri = url.toString();
+ String result = SchemaValidator.testXMLSchema(uri, schema);
+
+ assertEquals("URL: \"" + uri + "\" is ", "valid", result);
+ }
+
+ public void testIndexFragmentServiceJSONSchema()
+ 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
new file mode 100644
index 000000000..29589fee6
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.parsers.DocumentBuilder;
+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.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+public class IndexServiceTest extends IndexServletTest {
+
+ protected Node getIndexContributions( String locale)
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/index?lang=" + locale);
+ InputStream is = url.openStream();
+ InputSource inputSource = new InputSource(is);
+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ documentBuilder.setEntityResolver(new LocalEntityResolver());
+ Document document = documentBuilder.parse(inputSource);
+ Node root = document.getFirstChild();
+ is.close();
+ assertEquals("indexContributions", root.getNodeName());
+ return root;
+ }
+
+ public void testIndexServiceXMLSchema()
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/index?lang=en");
+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/index.xsd");
+ String schema = schemaUrl.toString();
+ String uri = url.toString();
+ String result = SchemaValidator.testXMLSchema(uri, schema);
+
+ assertEquals("URL: \"" + uri + "\" is ", "valid", result);
+ }
+
+ public void testIndexServiceJSONSchema()
+ throws Exception {
+// fail("Not yet implemented.");
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/SchemaValidator.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/SchemaValidator.java
new file mode 100644
index 000000000..e220db3ed
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/SchemaValidator.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 java.io.File;
+import java.net.URL;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
+import org.xml.sax.SAXException;
+
+public class SchemaValidator {
+
+ public static String testXMLSchema(String uri, String schemaFile) {
+ String msg = ""; //$NON-NLS-1$
+ try {
+ SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); //$NON-NLS-1$
+ Schema schema = null;
+ if (schemaFile.startsWith("http") || schemaFile.startsWith("ftp"))
+ schema = factory.newSchema(new URL(schemaFile));
+ else
+ schema = factory.newSchema(new File(schemaFile));
+
+ Validator validator = schema.newValidator();
+ Source source = new StreamSource(uri);
+ try {
+ validator.validate(source);
+ msg = "valid"; //$NON-NLS-1$
+ } catch (SAXException ex) {
+ msg = "not valid. Details: " + ex.getMessage(); //$NON-NLS-1$
+ }
+ } catch(Exception e) {
+ msg = "Exception e: " + e; //$NON-NLS-1$
+ }
+
+ return msg;
+ }
+
+ public static String testJSONSchema(String uri, String schemaFile) {
+ // TODO: Not yet implemented
+ return ""; //$NON-NLS-1$
+ }
+}
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
new file mode 100644
index 000000000..8965169a5
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/SearchServiceTest.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 java.net.URL;
+import java.net.URLEncoder;
+
+import org.eclipse.help.internal.server.WebappManager;
+import org.eclipse.ua.tests.help.remote.SearchServletTest;
+import org.w3c.dom.Node;
+
+public class SearchServiceTest extends SearchServletTest {
+
+ protected Node[] getSearchHitsFromServlet(String phrase)
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/search?phrase=" + URLEncoder.encode(phrase, "UTF-8"));
+ return makeServletCall(url);
+ }
+
+ protected Node[] getSearchHitsUsingLocale(String phrase, String locale)
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/search?phrase="
+ + URLEncoder.encode(phrase, "UTF-8") + "&lang=" + locale);
+ return makeServletCall(url);
+ }
+
+ public void testRemoteSearchXMLSchema()
+ throws Exception {
+ int port = WebappManager.getPort();
+ 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()
+ throws Exception {
+ int port = WebappManager.getPort();
+ 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()
+ throws Exception {
+// fail("Not yet implemented.");
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ServicesTestUtils.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ServicesTestUtils.java
new file mode 100644
index 000000000..096de8159
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ServicesTestUtils.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.help.internal.server.WebappManager;
+import org.eclipse.help.internal.webapp.utils.Utils;
+import org.eclipse.ua.tests.help.remote.RemoteTestUtils;
+
+public class ServicesTestUtils extends RemoteTestUtils {
+
+ public static String getRemoteContent(String plugin, String path,
+ String locale) throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/rtopic/" + plugin
+ + path + "?lang=" + locale);
+ return readFromURL(url);
+ }
+
+ public static String getLocalContent(String plugin, String path)
+ throws IOException {
+ String localContent = RemoteTestUtils.getLocalContent(plugin, path);
+ try {
+ localContent = Utils.updateResponse(localContent);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return localContent;
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java
new file mode 100644
index 000000000..3b65d9fab
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+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.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 TocFragmentServiceTest extends TestCase {
+
+ private int mode;
+
+ protected void setUp() throws Exception {
+ BaseHelpSystem.ensureWebappRunning();
+ mode = BaseHelpSystem.getMode();
+ BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
+ }
+
+ protected void tearDown() throws Exception {
+ BaseHelpSystem.setMode(mode);
+ }
+
+ public void testTocFragmentServiceContainsUAToc() throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port,
+ "/help/vs/service/tocfragment?lang=en");
+ Node root = getTreeData(url);
+ Element[] UARoot = findNodeById(root,
+ "/org.eclipse.ua.tests/data/help/toc/root.xml");
+ assertEquals(1, UARoot.length);
+ }
+
+ public void testTocFragmentServiceContainsFilteredToc() throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port,
+ "/help/vs/service/tocfragment?lang=en&toc=/org.eclipse.ua.tests/data/help/toc/root.xml&path=2");
+ Node root = getTreeData(url);
+ Element[] UARoot = findNodeById(root,
+ "/org.eclipse.ua.tests/data/help/toc/root.xml");
+ assertEquals(1, UARoot.length);
+ Element[] filterNode = findNodeById(UARoot[0], "2");
+ assertEquals(1, filterNode.length);
+ Element[] results = findChildren(filterNode[0], "node", "href",
+ "../topic/org.eclipse.ua.tests/data/help/toc/filteredToc/simple_page.html");
+ assertEquals(24, results.length);
+
+ results = findChildren(filterNode[0], "node", "href",
+ "../topic/org.eclipse.ua.tests/data/help/toc/filteredToc/helpInstalled.html");
+ assertEquals(1, results.length);
+ }
+
+ /*
+ * These tests are still failing - see Bug 338732
+ *
+ *
+ public void testReadEnToc() throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port,
+ "/help/vs/service/tocfragment?lang=en&toc=/org.eclipse.ua.tests/data/help/toc/root.xml&path=7");
+ Node root = getTreeData(url);
+ Element[] UARoot = findNodeById(root,
+ "/org.eclipse.ua.tests/data/help/toc/root.xml");
+ assertEquals(1, UARoot.length);
+ Element[] searchNode = findNodeById(UARoot[0], "7");
+ assertEquals(1, searchNode.length);
+ Element[] topicEn = findChildren(searchNode[0], "node", "href",
+ "../topic/org.eclipse.ua.tests/data/help/search/test_en.html");
+ assertEquals(1, topicEn.length);
+ Element[] topicDe = findChildren(searchNode[0], "node", "href",
+ "../topic/org.eclipse.ua.tests/data/help/search/test_de.html");
+ assertEquals(0, topicDe.length);
+ }
+
+ public void testReadDeToc() throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port,
+ "/help/vs/service/tocfragment?lang=de&toc=/org.eclipse.ua.tests/data/help/toc/root.xml&path=7");
+ Node root = getTreeData(url);
+ Element[] UARoot = findNodeById(root,
+ "/org.eclipse.ua.tests/data/help/toc/root.xml");
+ assertEquals(1, UARoot.length);
+ Element[] searchNode = findNodeById(UARoot[0], "7");
+ Element[] topicEn = findChildren(searchNode[0], "node", "href",
+ "../topic/org.eclipse.ua.tests/data/help/search/test_en.html");
+ assertEquals(0, topicEn.length);
+ Element[] topicDe = findChildren(searchNode[0], "node", "href",
+ "../topic/org.eclipse.ua.tests/data/help/search/test_de.html");
+ assertEquals(1, topicDe.length);
+ }
+
+ */
+
+ private Element[] findNodeById(Node root, String id) {
+ return findChildren(root, "node", "id", id);
+ }
+
+ private Element[] findChildren(Node parent, String childKind,
+ String attributeName, String attributeValue) {
+ NodeList nodes = parent.getChildNodes();
+ List<Node> results = new ArrayList<Node>();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node next = nodes.item(i);
+ if (next instanceof Element) {
+ Element nextElement = (Element)next;
+ if ( childKind.equals(nextElement.getTagName())
+ && attributeValue.equals(nextElement.getAttribute(attributeName))) {
+
+ results.add(next);
+ }
+ }
+ }
+ return (Element[]) results.toArray(new Element[results.size()]);
+ }
+
+
+ private Node getTreeData(URL url)
+ throws Exception {
+ InputStream is = url.openStream();
+ InputSource inputSource = new InputSource(is);
+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ documentBuilder.setEntityResolver(new LocalEntityResolver());
+ Document document = documentBuilder.parse(inputSource);
+ Node root = document.getFirstChild();
+ is.close();
+ assertEquals("tree_data", root.getNodeName());
+ return root;
+ }
+
+ public void testTocFragmentServiceXMLSchema()
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/tocfragment?lang=en");
+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/tocfragment.xsd");
+ String schema = schemaUrl.toString();
+ String uri = url.toString();
+ String result = SchemaValidator.testXMLSchema(uri, schema);
+
+ assertEquals("URL: \"" + uri + "\" is ", "valid", result);
+ }
+
+ public void testTocFragmentServiceJSONSchema()
+ 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
new file mode 100644
index 000000000..b49feffa0
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.parsers.DocumentBuilder;
+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.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+public class TocServiceTest extends TocServletTest {
+
+ protected Node getTocContributions( String locale)
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/toc?lang=" + locale);
+ InputStream is = url.openStream();
+ InputSource inputSource = new InputSource(is);
+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ documentBuilder.setEntityResolver(new LocalEntityResolver());
+ Document document = documentBuilder.parse(inputSource);
+ Node root = document.getFirstChild();
+ is.close();
+ assertEquals("tocContributions", root.getNodeName());
+ return root;
+ }
+
+ public void testTocServiceXMLSchema()
+ throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/toc?lang=en");
+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/xml/toc.xsd");
+ String schema = schemaUrl.toString();
+ String uri = url.toString();
+ String result = SchemaValidator.testXMLSchema(uri, schema);
+
+ assertEquals("URL: \"" + uri + "\" is ", "valid", result);
+ }
+
+ public void testTocServiceJSONSchema()
+ throws Exception {
+ /*int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/vs/service/toc?lang=en");
+ URL schemaUrl = new URL("http", "localhost", port, "/help/test/schema/json/toc.json");
+ 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