Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java2
-rw-r--r--org.eclipse.ua.tests/data/help/index/topic .html16
-rw-r--r--org.eclipse.ua.tests/data/help/index/topic%.html16
-rw-r--r--org.eclipse.ua.tests/data/help/index/topic&.html16
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/AllWebappTests.java3
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/EclipseConnectorTests.java80
6 files changed, 130 insertions, 3 deletions
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java
index c2624e5f5..3b496139e 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java
@@ -28,7 +28,6 @@ import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.eclipse.core.runtime.URIUtil;
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.base.MissingContentManager;
import org.eclipse.help.internal.base.remote.RemoteHelpInputStream;
@@ -113,7 +112,6 @@ public class EclipseConnector {
// enable activities matching url
// HelpBasePlugin.getActivitySupport().enableActivities(url);
- url = URIUtil.fromString(url).toString();
url = "help:" + url; //$NON-NLS-1$
}
diff --git a/org.eclipse.ua.tests/data/help/index/topic .html b/org.eclipse.ua.tests/data/help/index/topic .html
new file mode 100644
index 000000000..ca25dc06f
--- /dev/null
+++ b/org.eclipse.ua.tests/data/help/index/topic .html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<HTML>
+<HEAD>
+<meta name="copyright" content="Copyright (c) Red Hat Inc. and others 2018. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
+<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
+<TITLE>topic .html</TITLE>
+</HEAD>
+<BODY>
+
+<p>
+topic .html
+</p>
+
+</BODY>
+</HTML>
diff --git a/org.eclipse.ua.tests/data/help/index/topic%.html b/org.eclipse.ua.tests/data/help/index/topic%.html
new file mode 100644
index 000000000..be91eaba7
--- /dev/null
+++ b/org.eclipse.ua.tests/data/help/index/topic%.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<HTML>
+<HEAD>
+<meta name="copyright" content="Copyright (c) Red Hat Inc. and others 2018. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
+<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
+<TITLE>topic%.html</TITLE>
+</HEAD>
+<BODY>
+
+<p>
+topic%.html
+</p>
+
+</BODY>
+</HTML>
diff --git a/org.eclipse.ua.tests/data/help/index/topic&.html b/org.eclipse.ua.tests/data/help/index/topic&.html
new file mode 100644
index 000000000..71a2027d5
--- /dev/null
+++ b/org.eclipse.ua.tests/data/help/index/topic&.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<HTML>
+<HEAD>
+<meta name="copyright" content="Copyright (c) Red Hat Inc. and others 2018. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
+<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
+<TITLE>topic&.html</TITLE>
+</HEAD>
+<BODY>
+
+<p>
+topic&.html
+</p>
+
+</BODY>
+</HTML>
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/AllWebappTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/AllWebappTests.java
index fb2912396..286fc8d96 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/AllWebappTests.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/AllWebappTests.java
@@ -33,7 +33,8 @@ import org.junit.runners.Suite;
HelpServerBinding.class,
HtmlCoderTest.class,
TocZipTest.class,
- JsonHelperTests.class
+ JsonHelperTests.class,
+ EclipseConnectorTests.class
})
public class AllWebappTests {
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/EclipseConnectorTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/EclipseConnectorTests.java
new file mode 100644
index 000000000..22b6e3f79
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/EclipseConnectorTests.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat Inc. 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:
+ * Lucas Bullen (Red Hat Inc.) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ua.tests.help.webapp;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.help.internal.HelpPlugin;
+import org.eclipse.help.internal.base.BaseHelpSystem;
+import org.eclipse.help.internal.server.WebappManager;
+import org.eclipse.ua.tests.help.remote.RemotePreferenceStore;
+import org.eclipse.ua.tests.help.remote.RemoteTestUtils;
+import org.eclipse.ua.tests.help.remote.TestServerManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class EclipseConnectorTests {
+ private int mode;
+
+ @Before
+ public void setUp() throws Exception {
+ BaseHelpSystem.ensureWebappRunning();
+ mode = BaseHelpSystem.getMode();
+ RemotePreferenceStore.savePreferences();
+ RemotePreferenceStore.setMockRemoteServer();
+ BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
+ HelpPlugin.getTocManager().getTocs("en");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ RemotePreferenceStore.restorePreferences();
+ BaseHelpSystem.setMode(mode);
+ }
+
+ @Test
+ public void testEncodedAmpersand() throws Exception {
+ final String path = "/data/help/index/" + URIUtil.fromString("topic&.html").toString();
+ String remoteContent = getHelpContent("mock.toc", path, "en");
+ int port = TestServerManager.getPort(0);
+ String expectedContent = RemoteTestUtils.createMockContent("mock.toc", path, "en", port);
+ assertEquals(expectedContent, remoteContent);
+ }
+
+ @Test
+ public void testEncodedSpace() throws Exception {
+ final String path = "/data/help/index/" + URIUtil.fromString("topic .html").toString();
+ String remoteContent = getHelpContent("mock.toc", path, "en");
+ int port = TestServerManager.getPort(0);
+ String expectedContent = RemoteTestUtils.createMockContent("mock.toc", path, "en", port);
+ assertEquals(expectedContent, remoteContent);
+ }
+
+ @Test
+ public void testEncodedPercentSign() throws Exception {
+ final String path = "/data/help/index/" + URIUtil.fromString("topic%.html").toString();
+ String remoteContent = getHelpContent("mock.toc", path, "en");
+ int port = TestServerManager.getPort(0);
+ String expectedContent = RemoteTestUtils.createMockContent("mock.toc", path, "en", port);
+ assertEquals(expectedContent, remoteContent);
+ }
+
+ private static String getHelpContent(String plugin, String path, String locale) throws Exception {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/nftopic/" + plugin + path + "?lang=" + locale);
+ return RemoteTestUtils.readFromURL(url);
+ }
+}

Back to the top