Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2011-06-20 16:53:12 +0000
committerChris Goldthorpe2011-06-20 16:53:12 +0000
commite2940b4c9dcde2e3d0d55a5348f8ed49a6a31ff8 (patch)
tree3e40f6f4276a8370feba060caa277726c10e375f
parent97c4ff8396781ef951491ce940eae1560b422c0f (diff)
downloadeclipse.platform.ua-e2940b4c9dcde2e3d0d55a5348f8ed49a6a31ff8.tar.gz
eclipse.platform.ua-e2940b4c9dcde2e3d0d55a5348f8ed49a6a31ff8.tar.xz
eclipse.platform.ua-e2940b4c9dcde2e3d0d55a5348f8ed49a6a31ff8.zip
Bug 344499 - Print Selected Topic and All Subtopics Incorrectly Injects Section Numbers
-rw-r--r--org.eclipse.help.webapp/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java7
-rw-r--r--org.eclipse.ua.tests/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.ua.tests/bundleversions/bundleversions.odsbin13924 -> 14531 bytes
-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/PrintSubtopics.java60
6 files changed, 67 insertions, 5 deletions
diff --git a/org.eclipse.help.webapp/META-INF/MANIFEST.MF b/org.eclipse.help.webapp/META-INF/MANIFEST.MF
index 4654fcdf1..82c24ca83 100644
--- a/org.eclipse.help.webapp/META-INF/MANIFEST.MF
+++ b/org.eclipse.help.webapp/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %help_webapp_plugin_name
Bundle-SymbolicName: org.eclipse.help.webapp;singleton:=true
-Bundle-Version: 3.6.0.qualifier
+Bundle-Version: 3.6.100.qualifier
Bundle-Activator: org.eclipse.help.internal.webapp.HelpWebappPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java
index 2bf324b19..f1872f1a1 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java
@@ -53,8 +53,8 @@ public class PrintData extends RequestData {
private static final int defaultMaxTopics = 500;
// where to inject the section numbers
- private static final Pattern PATTERN_HEADING = Pattern.compile("<body.*?>[\\s]*?([\\w])", Pattern.MULTILINE | Pattern.DOTALL | Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
-
+ private static final Pattern PATTERN_HEADING = Pattern.compile("<body.*?>[\\s]*?([^<\\s])", Pattern.MULTILINE | Pattern.DOTALL | Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
+
// to normalize external links to new base href
private static final Pattern PATTERN_LINK = Pattern.compile("(src|href)=\"(.*?\")", Pattern.MULTILINE | Pattern.DOTALL | Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
@@ -329,8 +329,9 @@ public class PrintData extends RequestData {
/*
* Injects the sectionId into the document heading.
+ * public static for JUnit Testing
*/
- private String injectHeading(String content, String sectionId) {
+ public static String injectHeading(String content, String sectionId) {
Matcher matcher = PATTERN_HEADING.matcher(content);
if (matcher.find()) {
String heading = "<a id=\"section" + sectionId + "\">" + sectionId + ". </a>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
diff --git a/org.eclipse.ua.tests/META-INF/MANIFEST.MF b/org.eclipse.ua.tests/META-INF/MANIFEST.MF
index a464e3562..b39564ec4 100644
--- a/org.eclipse.ua.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.ua.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: User Assistance Test
Bundle-SymbolicName: org.eclipse.ua.tests;singleton:=true
-Bundle-Version: 3.3.400.qualifier
+Bundle-Version: 3.3.500.qualifier
Bundle-Activator: org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin
Require-Bundle: org.junit,
org.eclipse.core.resources,
diff --git a/org.eclipse.ua.tests/bundleversions/bundleversions.ods b/org.eclipse.ua.tests/bundleversions/bundleversions.ods
index 93c9960c5..18e13648a 100644
--- a/org.eclipse.ua.tests/bundleversions/bundleversions.ods
+++ b/org.eclipse.ua.tests/bundleversions/bundleversions.ods
Binary files differ
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 3ce669f38..de366f41f 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
@@ -32,6 +32,7 @@ public class AllWebappTests extends TestSuite {
suite.addTestSuite(UrlCoderTest.class);
suite.addTestSuite(UrlUtilsTests.class);
suite.addTestSuite(LocaleTest.class);
+ suite.addTestSuite(PrintSubtopics.class);
suite.addTestSuite(RestrictedTopicParameter.class);
suite.addTestSuite(FilterExtensionTest.class);
suite.addTestSuite(FragmentServletTest.class);
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/PrintSubtopics.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/PrintSubtopics.java
new file mode 100644
index 000000000..fe6215569
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/PrintSubtopics.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;
+
+import org.eclipse.help.internal.webapp.data.PrintData;
+import junit.framework.TestCase;
+
+/**
+ * Test for methods in PrintData
+ */
+
+public class PrintSubtopics extends TestCase {
+
+ public void testHeadingInsertion() {
+ String result = PrintData.injectHeading("<body> <p>Title</p>", "1");
+ assertEquals("<body> <p><a id=\"section1\">1. </a>Title</p>", result);
+ }
+
+ public void testHeaderInsertionSkipsWhitespace() {
+ checkHeadingInsertion("<body> <p> \n\r</p><h1>", "Title</h1>");
+ }
+
+ public void testAccentedCharacter() {
+ checkHeadingInsertion("<body> <p>", "\u00E1guila</p>");
+ }
+
+ public void testinvertedQuestionmark() {
+ checkHeadingInsertion("<body> <p>", "\u00BFQu\u00E9 es Eclipse?</p>");
+ }
+
+ public void testSlash() {
+ checkHeadingInsertion("<body> <p>", "/usr/bin</p>");
+ }
+
+ public void testChineseCharacter() {
+ checkHeadingInsertion("<body> <p>", "\u623F\u5B50</p>");
+ }
+
+ public void testChineseExtbCharacter() {
+ checkHeadingInsertion("<body> <p>", "\uD840\uDC06</p>");
+ }
+
+ /*
+ * Check that insertions occur between preInsert and postInsert
+ */
+ public void checkHeadingInsertion(String preInsert, String postInsert) {
+ String result = PrintData.injectHeading(preInsert + postInsert, "1");
+ assertEquals(preInsert + "<a id=\"section1\">1. </a>" + postInsert, result);
+ }
+
+}

Back to the top