diff options
Diffstat (limited to 'org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java')
-rw-r--r-- | org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java index 6d94b18ce..20a318b7b 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2015 IBM Corporation and others. + * Copyright (c) 2010, 2016 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 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.ua.tests.help.dynamic; +import static org.junit.Assert.assertTrue; + import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -22,19 +24,19 @@ import org.eclipse.help.internal.xhtml.DynamicXHTMLProcessor; import org.eclipse.help.ui.internal.HelpUIPlugin; import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin; import org.eclipse.ua.tests.util.XMLUtil; +import org.junit.Before; +import org.junit.Test; import org.osgi.framework.Bundle; import org.xml.sax.SAXException; -import junit.framework.TestCase; - -public class DynamicXHTMLProcessorTest extends TestCase { +public class DynamicXHTMLProcessorTest { - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { // activate the UI plug-in for UI filtering ability HelpUIPlugin.getDefault(); } - + private String process(String path) throws Exception { Bundle bundle = UserAssistanceTestPlugin.getDefault().getBundle(); InputStream is = getProcessedInput(path, bundle); @@ -48,7 +50,7 @@ public class DynamicXHTMLProcessorTest extends TestCase { String href = '/' + bundle.getBundleId() +path; return DynamicXHTMLProcessor.process(href, in, "en", true); } - + private String readStream(InputStream is) throws Exception { InputStreamReader inputStreamReader = new InputStreamReader(is, "UTF-8"); StringBuffer buffer = new StringBuffer(); @@ -64,39 +66,46 @@ public class DynamicXHTMLProcessorTest extends TestCase { return buffer.toString(); } + @Test public void testXhtmlNoCollapseAnchor() throws Exception { String processed = process("data/help/dynamic/xhtml/emptyAnchor.xhtml"); assertTrue("Anchor collapsed in " + processed, processed.indexOf("</a>") > 0); } - + + @Test public void testXhtmlNoCollapseParagraph() throws Exception { String processed = process("data/help/dynamic/xhtml/emptyAnchor.xhtml"); assertTrue("Paragraph collapsed in " + processed, processed.indexOf("</p>") > 0); } - + + @Test public void testXhtmlNoCollapseAnchorIC() throws Exception { String processed = process("data/help/dynamic/xhtml/emptyAnchorWithComment.xhtml"); assertTrue("Anchor collapsed in " + processed, processed.indexOf("</a>") > 0); } - + + @Test public void testXhtmlNoCollapseParagraphIC() throws Exception { String processed = process("data/help/dynamic/xhtml/emptyAnchorWithComment.xhtml"); assertTrue("Paragraph collapsed in " + processed, processed.indexOf("</p>") > 0); } + @Test public void testXhtmlNoCollapseDiv() throws Exception { String processed = process("data/help/dynamic/xhtml/emptyDiv.xhtml"); assertTrue("Div collapsed in " + processed, processed.indexOf("</div>") > 0); } - + + @Test public void testXhtmlNoCollapseScript() throws Exception { String processed = process("data/help/dynamic/xhtml/emptyAnchor.xhtml"); assertTrue("Div collapsed in " + processed, processed.indexOf("</script>") > 0); } - + + @Test public void testValidXML() throws Exception { String processed = process("data/help/dynamic/xhtml/emptyAnchor.xhtml"); XMLUtil.assertParseableXML(processed); } - + } |