diff options
author | Chris Goldthorpe | 2007-07-03 16:57:12 +0000 |
---|---|---|
committer | Chris Goldthorpe | 2007-07-03 16:57:12 +0000 |
commit | 99555f8ad8745a10a3478b2d40f8ab87531c4385 (patch) | |
tree | 43a4b10e66bea643141c4a376454bfd48cfd90f9 /org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc | |
parent | 591088c0e97b4a51f6b842138b3c5da3d6f62a41 (diff) | |
download | eclipse.platform.ua-99555f8ad8745a10a3478b2d40f8ab87531c4385.tar.gz eclipse.platform.ua-99555f8ad8745a10a3478b2d40f8ab87531c4385.tar.xz eclipse.platform.ua-99555f8ad8745a10a3478b2d40f8ab87531c4385.zip |
Bug 194490 - Create JUnit test suite to validate links in tocs
Diffstat (limited to 'org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc')
-rw-r--r-- | org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocLinkChecker.java | 68 |
1 files changed, 68 insertions, 0 deletions
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 new file mode 100644 index 000000000..9c30baccf --- /dev/null +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocLinkChecker.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2007 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.toc; + +import java.util.ArrayList; + +import org.eclipse.help.internal.validation.TocValidator; +import org.eclipse.help.internal.validation.TocValidator.BrokenLink; + +import junit.framework.Assert; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +public class TocLinkChecker extends TestCase { + + 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"}; + private static final String[] JDT_USER = {"/org.eclipse.jdt.doc.user/toc.xml"}; + private static final String[] JDT_ISV = {"/org.eclipse.jdt.doc.isv/toc.xml"}; + + public static Test suite() { + return new TestSuite(TocLinkChecker.class); + } + + public void testPlatformUser() throws Exception { + ArrayList failures = TocValidator.validate(PLATFORM_USER); + doAssert(failures); + } + + public void testPlatformIsv() throws Exception { + ArrayList failures = TocValidator.validate(PLATFORM_ISV); + doAssert(failures); + } + + public void testPdeUser() throws Exception { + ArrayList failures = TocValidator.validate(PDE_USER); + doAssert(failures); + } + + public void testJdtUser() throws Exception { + ArrayList failures = TocValidator.validate(JDT_USER); + doAssert(failures); + } + + public void testJdtIsv() throws Exception { + ArrayList failures = TocValidator.validate(JDT_ISV); + doAssert(failures); + } + + private void doAssert(ArrayList failures) { + StringBuffer message = new StringBuffer(); + for (int i = 0; i < failures.size(); i++) { + BrokenLink link = (BrokenLink)failures.get(i); + message.append("Invalid link in \"" + link.getTocID() + "\": " + link.getHref()); + } + Assert.assertTrue(message.toString(), failures.isEmpty()); + } +} |