diff options
author | Lucas Bullen | 2018-05-25 16:17:44 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2018-05-30 08:58:03 +0000 |
commit | 61d6c006d59893a7db1250aec86c3a14da5a5066 (patch) | |
tree | 0d5badfbf11412b791a0ed0f4f4dcf5ab7cb89d9 /org.eclipse.ua.tests/help/org/eclipse/ua/tests | |
parent | a963495fa4ae0da91b076962334cc40b4f01225d (diff) | |
download | eclipse.platform.ua-61d6c006d59893a7db1250aec86c3a14da5a5066.tar.gz eclipse.platform.ua-61d6c006d59893a7db1250aec86c3a14da5a5066.tar.xz eclipse.platform.ua-61d6c006d59893a7db1250aec86c3a14da5a5066.zip |
Bug 535106 - Help topics with space in names no longer work with PhotonI20180531-2125I20180531-2000I20180531-1245I20180531-0910
- Remove the double URL encoding
Change-Id: Iec61341cea76bcb846411c1019fc68b708b0cf2a
Signed-off-by: Lucas Bullen <lbullen@redhat.com>
Diffstat (limited to 'org.eclipse.ua.tests/help/org/eclipse/ua/tests')
-rw-r--r-- | org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/AllWebappTests.java | 3 | ||||
-rw-r--r-- | org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/EclipseConnectorTests.java | 80 |
2 files changed, 82 insertions, 1 deletions
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); + } +} |