Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2011-09-06 19:59:23 +0000
committerChris Goldthorpe2011-09-06 20:09:08 +0000
commit4acf1b2639cd2457edb2b05be86615a55a71261d (patch)
tree7c5b1581269cad4e35d2240bc6e20338b3b61c6a /org.eclipse.ua.tests/help/org
parent5e64f60c82a2553b44b764e7e359d6e903f67822 (diff)
downloadeclipse.platform.ua-4acf1b2639cd2457edb2b05be86615a55a71261d.tar.gz
eclipse.platform.ua-4acf1b2639cd2457edb2b05be86615a55a71261d.tar.xz
eclipse.platform.ua-4acf1b2639cd2457edb2b05be86615a55a71261d.zip
Bug 353141 - [Help] Help System: Loose content files in directory should
override their counterparts in ZIP
Diffstat (limited to 'org.eclipse.ua.tests/help/org')
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/AllWebappTests.java1
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/TocZipTest.java67
2 files changed, 68 insertions, 0 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 de366f41f..eb0e979b6 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
@@ -40,6 +40,7 @@ public class AllWebappTests extends TestSuite {
suite.addTestSuite(ParallelServerAccessTest.class);
suite.addTestSuite(HelpServerBinding.class);
suite.addTestSuite(HtmlCoderTest.class);
+ suite.addTestSuite(TocZipTest.class);
//$JUnit-END$
return suite;
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/TocZipTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/TocZipTest.java
new file mode 100644
index 000000000..4b836370e
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/TocZipTest.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.eclipse.help.internal.base.BaseHelpSystem;
+import org.eclipse.help.internal.server.WebappManager;
+
+/**
+ * Tests for reading from toc.zip
+ */
+public class TocZipTest extends TestCase {
+
+ protected void setUp() throws Exception {
+ BaseHelpSystem.ensureWebappRunning();
+ }
+
+ public void testDocInZipOnly() throws IOException {
+ final String path = "/org.eclipse.ua.tests/data/help/manual/dz1.html";
+ String contents = readPage(path);
+ assertTrue(contents.indexOf("dz1 from doc.zip") > -1);
+ }
+
+ /**
+ * Verify that loose files override those in doc.zip
+ * @throws IOException
+ */
+ public void testDocInZipAndBundle() throws IOException {
+ final String path = "/org.eclipse.ua.tests/data/help/manual/dz2.html";
+ String contents = readPage(path);
+ assertFalse(contents.indexOf("dz2 from doc.zip") > -1);
+ assertTrue(contents.indexOf("dz2 from bundle") > -1);
+ }
+
+ private String readPage(final String path) throws MalformedURLException,
+ IOException {
+ int port = WebappManager.getPort();
+ URL url = new URL("http", "localhost", port, "/help/topic" + path);
+ InputStream is = url.openStream();
+ BufferedInputStream buffered = new BufferedInputStream(is);
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ int result = buffered.read();
+ while(result != -1) {
+ os.write(result);
+ result = buffered.read();
+ }
+ return os.toString();
+ }
+
+}

Back to the top