Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2011-09-06 16:14:11 +0000
committerChris Goldthorpe2011-09-06 16:14:11 +0000
commit5e64f60c82a2553b44b764e7e359d6e903f67822 (patch)
tree0894f21a1520b75fceeee50c7290b80a77c624a4 /org.eclipse.ua.tests
parent33a4df3270f503683d80fb9cc3c70766890b1cf4 (diff)
downloadeclipse.platform.ua-5e64f60c82a2553b44b764e7e359d6e903f67822.tar.gz
eclipse.platform.ua-5e64f60c82a2553b44b764e7e359d6e903f67822.tar.xz
eclipse.platform.ua-5e64f60c82a2553b44b764e7e359d6e903f67822.zip
Bug 330868 - [Webapp] Wrong doc path when a page is referenced twice
Diffstat (limited to 'org.eclipse.ua.tests')
-rw-r--r--org.eclipse.ua.tests/data/help/toc/filteredToc/filter.xml10
-rw-r--r--org.eclipse.ua.tests/data/help/toc/filteredToc/parent8859.html1
-rw-r--r--org.eclipse.ua.tests/data/help/toc/filteredToc/parentUTF8.html4
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/FragmentServletTest.java13
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java42
5 files changed, 57 insertions, 13 deletions
diff --git a/org.eclipse.ua.tests/data/help/toc/filteredToc/filter.xml b/org.eclipse.ua.tests/data/help/toc/filteredToc/filter.xml
index 111f42790..27206a168 100644
--- a/org.eclipse.ua.tests/data/help/toc/filteredToc/filter.xml
+++ b/org.eclipse.ua.tests/data/help/toc/filteredToc/filter.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?NLS TYPE="org.eclipse.help.toc"?>
<!--
- Copyright (c) 2005, 2009 IBM Corporation and others.
+ Copyright (c) 2005, 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
@@ -131,9 +131,17 @@
<topic label="UTF8 page with child links" href = "data/help/toc/filteredToc/parentUTF8.html" >
<topic href="data/help/toc/filteredToc/simple_page.html" label="España">
</topic>
+ <topic href="data/help/toc/filteredToc/simple_page.html" label="second UTF8 Child">
+ </topic>
+ <topic label="navigation topic">
+ <topic href="data/help/toc/filteredToc/simple_page.html" label="Topic">
+ </topic>
+ </topic>
</topic>
<topic label="ISO 8859 page with child links" href = "data/help/toc/filteredToc/parent8859.html" >
<topic href="data/help/toc/filteredToc/simple_page.html" label="brasileño">
</topic>
+ <topic href="data/help/toc/filteredToc/simple_page.html" label="second ISO 8859 Child">
+ </topic>
</topic>
</toc>
diff --git a/org.eclipse.ua.tests/data/help/toc/filteredToc/parent8859.html b/org.eclipse.ua.tests/data/help/toc/filteredToc/parent8859.html
index d980199d4..24fba4c9e 100644
--- a/org.eclipse.ua.tests/data/help/toc/filteredToc/parent8859.html
+++ b/org.eclipse.ua.tests/data/help/toc/filteredToc/parent8859.html
@@ -15,6 +15,7 @@ Expected results:
<ul class="childlinks">
<li><a href="../../../../../org.eclipse.ua.tests/data/help/toc/filteredToc/simple_page.html">brasileño</a></li>
+<li><a href="../../../../../org.eclipse.ua.tests/data/help/toc/filteredToc/simple_page.html">second ISO 8859 Child</a></li>
</ul>
</p>
diff --git a/org.eclipse.ua.tests/data/help/toc/filteredToc/parentUTF8.html b/org.eclipse.ua.tests/data/help/toc/filteredToc/parentUTF8.html
index 18e328477..1f2dd2a4a 100644
--- a/org.eclipse.ua.tests/data/help/toc/filteredToc/parentUTF8.html
+++ b/org.eclipse.ua.tests/data/help/toc/filteredToc/parentUTF8.html
@@ -7,13 +7,15 @@
</head>
<body>
This is a document encoded in UTF-8 with child links.
-Check that the actual results match the expected results.
+Check that the actual results match the expected results in appearance.
<br>
Expected results:
<p>
<ul class="childlinks">
<li><a href="../../../../../org.eclipse.ua.tests/data/help/toc/filteredToc/simple_page.html">España</a></li>
+<li><a href="../../../../../org.eclipse.ua.tests/data/help/toc/filteredToc/simple_page.html">second UTF8 Child</a></li>
+<li><a href="../../../../../org.eclipse.ua.tests/data/help/toc/filteredToc/simple_page.html">navigation topic</a></li>
</ul>
</p>
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/FragmentServletTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/FragmentServletTest.java
index d421d3c51..46d7b4de5 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/FragmentServletTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/FragmentServletTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 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
@@ -25,7 +25,12 @@ public class FragmentServletTest extends TestCase {
public void testFixHrefNormal() {
String href = TocFragmentServlet.fixupHref(DOC_HTML, PATH);
- assertEquals(DOC_HTML, href);
+ assertEquals(DOC_HTML + "?cp=1_2", href);
+ }
+
+ public void testFixHrefWithParameter() {
+ String href = TocFragmentServlet.fixupHref(DOC_HTML + "?a=b", PATH);
+ assertEquals(DOC_HTML + "?a=b&cp=1_2", href);
}
public void testFixHrefNull() {
@@ -35,12 +40,12 @@ public class FragmentServletTest extends TestCase {
public void testFixHrefWithAnchor() {
String href = TocFragmentServlet.fixupHref(DOC_HTML + "#A", PATH);
- assertEquals(DOC_HTML + "?path=1_2#A" , href);
+ assertEquals(DOC_HTML + "?cp=1_2#A" , href);
}
public void testFixHrefWithAnchorAndParams() {
String href = TocFragmentServlet.fixupHref(DOC_HTML + "?a=b#A", PATH);
- assertEquals(DOC_HTML + "?a=b&path=1_2#A" , href);
+ assertEquals(DOC_HTML + "?a=b&cp=1_2#A" , href);
}
}
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
index 039f8900e..68e7a61c9 100644
--- 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
@@ -66,11 +66,11 @@ public class TocFragmentServiceTest extends TestCase {
assertEquals(1, UARoot.length);
Element[] filterNode = findNodeById(UARoot[0], "2");
assertEquals(1, filterNode.length);
- Element[] results = findChildren(filterNode[0], "node", "href",
+ Element[] results = findHref(filterNode[0], "node",
"../topic/org.eclipse.ua.tests/data/help/toc/filteredToc/simple_page.html");
assertEquals(24, results.length);
- results = findChildren(filterNode[0], "node", "href",
+ results = findHref(filterNode[0], "node",
"../topic/org.eclipse.ua.tests/data/help/toc/filteredToc/helpInstalled.html");
assertEquals(1, results.length);
}
@@ -87,10 +87,10 @@ public class TocFragmentServiceTest extends TestCase {
assertEquals(1, UARoot.length);
Element[] searchNode = findChildren(UARoot[0], "node", "title", "search");
assertEquals(1, searchNode.length);
- Element[] topicEn = findChildren(searchNode[0], "node", "href",
+ Element[] topicEn = findHref(searchNode[0], "node",
"../topic/org.eclipse.ua.tests/data/help/search/test_en.html");
assertEquals(1, topicEn.length);
- Element[] topicDe = findChildren(searchNode[0], "node", "href",
+ Element[] topicDe = findHref(searchNode[0], "node",
"../topic/org.eclipse.ua.tests/data/help/search/test_de.html");
assertEquals(0, topicDe.length);
}
@@ -124,10 +124,10 @@ public class TocFragmentServiceTest extends TestCase {
"/org.eclipse.ua.tests/data/help/toc/root.xml");
assertEquals(1, UARoot.length);
Element[] searchNode = findChildren(UARoot[0], "node", "title", "search");
- Element[] topicEn = findChildren(searchNode[0], "node", "href",
+ Element[] topicEn = findHref(searchNode[0], "node",
"../topic/org.eclipse.ua.tests/data/help/search/test_en.html");
assertEquals(0, topicEn.length);
- Element[] topicDe = findChildren(searchNode[0], "node", "href",
+ Element[] topicDe = findHref(searchNode[0], "node",
"../topic/org.eclipse.ua.tests/data/help/search/test_de.html");
assertEquals(1, topicDe.length);
BaseHelpSystem.setMode(helpMode);
@@ -136,7 +136,7 @@ public class TocFragmentServiceTest extends TestCase {
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();
@@ -154,6 +154,34 @@ public class TocFragmentServiceTest extends TestCase {
}
return (Element[]) results.toArray(new Element[results.size()]);
}
+
+ /*
+ * Look for a matching href, the query part of the href is not compared
+ */
+ private Element[] findHref(Node parent, String childKind,
+ 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()) ) {
+ String href = nextElement.getAttribute("href");
+ if (href != null) {
+ int query = href.indexOf('?');
+ if (query >= 0) {
+ href = href.substring(0, query);
+ }
+ if (href.equals (attributeValue)) {
+ results.add(next);
+ }
+ }
+ }
+ }
+ }
+ return (Element[]) results.toArray(new Element[results.size()]);
+ }
private Node getTreeData(URL url)

Back to the top