Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2009-06-23 18:00:00 +0000
committerChris Goldthorpe2009-06-23 18:00:00 +0000
commit1aa5eaee6949286982b9b88dd01216e721e94eeb (patch)
treed69354a68c71c8b042d431a0f8818cb4197a6d4a
parente0595fa6e9371d88cd981d2021a09503055771b9 (diff)
downloadeclipse.platform.ua-1aa5eaee6949286982b9b88dd01216e721e94eeb.tar.gz
eclipse.platform.ua-1aa5eaee6949286982b9b88dd01216e721e94eeb.tar.xz
eclipse.platform.ua-1aa5eaee6949286982b9b88dd01216e721e94eeb.zip
Bug 279522 – [Test] Seperate Link checker tests into generated/non generated
-rw-r--r--org.eclipse.help.base/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/validation/TocValidator.java29
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocLinkChecker.java56
3 files changed, 71 insertions, 16 deletions
diff --git a/org.eclipse.help.base/META-INF/MANIFEST.MF b/org.eclipse.help.base/META-INF/MANIFEST.MF
index 5cc89997c..db62109ea 100644
--- a/org.eclipse.help.base/META-INF/MANIFEST.MF
+++ b/org.eclipse.help.base/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %help_base_plugin_name
Bundle-SymbolicName: org.eclipse.help.base; singleton:=true
-Bundle-Version: 3.4.0.qualifier
+Bundle-Version: 3.4.100.qualifier
Bundle-Activator: org.eclipse.help.internal.base.HelpBasePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/validation/TocValidator.java b/org.eclipse.help.base/src/org/eclipse/help/internal/validation/TocValidator.java
index c38ba7929..fe009243a 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/validation/TocValidator.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/validation/TocValidator.java
@@ -50,6 +50,16 @@ public class TocValidator {
return href; }
}
+ public static abstract class Filter {
+ abstract public boolean isIncluded(String href);
+ }
+
+ public static class PassThroughFilter extends Filter {
+ public boolean isIncluded(String href) {
+ return true;
+ }
+ }
+
/**
* Checks the validity of all <code>href</code> attributes on <code>topic</code> elements in the toc and the
* <code>topic</code> attribute on the <code>toc</code> element if there is one. Also checks validity of any
@@ -63,10 +73,14 @@ public class TocValidator {
* @throws ParserConfigurationException
*/
public static ArrayList validate(String[] hrefs) throws IOException, SAXException, ParserConfigurationException{
+ return filteredValidate(hrefs, new PassThroughFilter());
+ }
+
+ public static ArrayList filteredValidate (String[] hrefs, Filter filter) throws IOException, SAXException, ParserConfigurationException{
TocValidator v = new TocValidator();
ArrayList result = new ArrayList();
for (int i = 0; i < hrefs.length; i++)
- v.processToc(hrefs[i], null, result);
+ v.processToc(hrefs[i], null, result, filter);
return result;
}
@@ -78,7 +92,8 @@ public class TocValidator {
/* Checks validity of all links in a given toc. If all links are valid, an empty ArrayList is returned.
* Otherwise an ArrayList of BrokenLink objects is returned.
*/
- private void processToc(String href, String plugin, ArrayList result) throws IOException, SAXException, ParserConfigurationException {
+ private void processToc(String href, String plugin, ArrayList result, Filter filter)
+ throws IOException, SAXException, ParserConfigurationException {
String path;
if (href.startsWith("/")) { //$NON-NLS-1$
href = href.substring(1);
@@ -102,19 +117,19 @@ public class TocValidator {
System.out.println("Starting toc: " + key); //$NON-NLS-1$
processedTocs.put(key, new Object());
TocContribution contribution = parser.parse(new TocFile(plugin,path, true, "en", null, null)); //$NON-NLS-1$
- process(contribution.getToc(), plugin, path, result);
+ process(contribution.getToc(), plugin, path, result, filter);
}
/* Checks validity of all links in the given IUAElement and recursively calls itself to check all children.
* If there are any links to other tocs, calls the processToc method to validate them. If any broken links
* are found, an appropriate BrokenLink object will be added to the result ArrayList.
*/
- private void process(IUAElement element, String plugin, String path, ArrayList result) throws SAXException, ParserConfigurationException {
+ private void process(IUAElement element, String plugin, String path, ArrayList result, Filter filter) throws SAXException, ParserConfigurationException {
String href;
if (element instanceof ILink) {
href = ((ILink)element).getToc();
try {
- processToc(href, plugin, result);
+ processToc(href, plugin, result, filter);
} catch (IOException e) {
result.add(new BrokenLink("/" + plugin + "/" + path, href)); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -124,14 +139,14 @@ public class TocValidator {
href = ((IToc)element).getTopic(null).getHref();
else
href = ((IHelpResource)element).getHref();
- if (href != null)
+ if (href != null && filter.isIncluded(href))
if (!checkLink(href, plugin)) {
result.add(new BrokenLink("/" + plugin + "/" + path, href)); //$NON-NLS-1$ //$NON-NLS-2$
}
}
IUAElement [] children = element.getChildren();
for (int i = 0; i < children.length; i++)
- process(children[i], plugin, path, result);
+ process(children[i], plugin, path, result, filter);
}
/* Checks validity of a given link from a toc in a given plug-in.
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocLinkChecker.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocLinkChecker.java
index 9c30baccf..cf300f593 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocLinkChecker.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocLinkChecker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2009 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
@@ -11,6 +11,7 @@
package org.eclipse.ua.tests.help.toc;
import java.util.ArrayList;
+import java.util.List;
import org.eclipse.help.internal.validation.TocValidator;
import org.eclipse.help.internal.validation.TocValidator.BrokenLink;
@@ -22,6 +23,30 @@ import junit.framework.TestSuite;
public class TocLinkChecker extends TestCase {
+ private final class ReferenceFilter extends TocValidator.Filter {
+ public boolean isIncluded(String href) {
+ return href.startsWith("reference");
+ }
+ }
+
+ private final class NonReferenceFilter extends TocValidator.Filter {
+ public boolean isIncluded(String href) {
+ return !href.startsWith("reference");
+ }
+ }
+
+ private final class NonReferenceNonSampleFilter extends TocValidator.Filter {
+ public boolean isIncluded(String href) {
+ return !href.startsWith("reference") && !href.startsWith("samples");
+ }
+ }
+
+ private final class ReferenceOrSampleFilter extends TocValidator.Filter {
+ public boolean isIncluded(String href) {
+ return href.startsWith("reference") || href.startsWith("samples");
+ }
+ }
+
private static final String[] PLATFORM_USER = {"/org.eclipse.platform.doc.user/toc.xml"};
private static final String[] PLATFORM_ISV = {"/org.eclipse.platform.doc.isv/toc.xml"};
private static final String[] PDE_USER = {"/org.eclipse.pde.doc.user/toc.xml"};
@@ -36,14 +61,24 @@ public class TocLinkChecker extends TestCase {
ArrayList failures = TocValidator.validate(PLATFORM_USER);
doAssert(failures);
}
+
+ public void testPlatformIsvStatic() throws Exception {
+ ArrayList failures = TocValidator.filteredValidate(PLATFORM_ISV, new NonReferenceNonSampleFilter());
+ doAssert(failures);
+ }
- public void testPlatformIsv() throws Exception {
- ArrayList failures = TocValidator.validate(PLATFORM_ISV);
+ public void testPlatformIsvGenerated() throws Exception {
+ ArrayList failures = TocValidator.filteredValidate(PLATFORM_ISV, new ReferenceOrSampleFilter());
+ doAssert(failures);
+ }
+
+ public void testPdeUserStatic() throws Exception {
+ ArrayList failures = TocValidator.filteredValidate(PDE_USER, new NonReferenceFilter());
doAssert(failures);
}
- public void testPdeUser() throws Exception {
- ArrayList failures = TocValidator.validate(PDE_USER);
+ public void testPdeUserGenerated() throws Exception {
+ ArrayList failures = TocValidator.filteredValidate(PDE_USER, new ReferenceFilter());
doAssert(failures);
}
@@ -52,12 +87,17 @@ public class TocLinkChecker extends TestCase {
doAssert(failures);
}
- public void testJdtIsv() throws Exception {
- ArrayList failures = TocValidator.validate(JDT_ISV);
+ public void testJdtIsvStatic() throws Exception {
+ ArrayList failures = TocValidator.filteredValidate(JDT_ISV, new NonReferenceFilter());
+ doAssert(failures);
+ }
+
+ public void testJdtIsvGenerated() throws Exception {
+ ArrayList failures = TocValidator.filteredValidate(JDT_ISV, new ReferenceFilter());
doAssert(failures);
}
- private void doAssert(ArrayList failures) {
+ private void doAssert(List failures) {
StringBuffer message = new StringBuffer();
for (int i = 0; i < failures.size(); i++) {
BrokenLink link = (BrokenLink)failures.get(i);

Back to the top