diff options
author | Curtis D'Entremont | 2006-10-13 19:14:44 +0000 |
---|---|---|
committer | Curtis D'Entremont | 2006-10-13 19:14:44 +0000 |
commit | ebefd0ee634c33f186ad4297a3102a4955f15ee2 (patch) | |
tree | e70a3ac4331ff9610f038ee485ba5690719997a7 /org.eclipse.ua.tests | |
parent | 8086790b674c974c31df4b5b3f4cf3daa5370f96 (diff) | |
download | eclipse.platform.ua-ebefd0ee634c33f186ad4297a3102a4955f15ee2.tar.gz eclipse.platform.ua-ebefd0ee634c33f186ad4297a3102a4955f15ee2.tar.xz eclipse.platform.ua-ebefd0ee634c33f186ad4297a3102a4955f15ee2.zip |
fixed failing tests (transformers randomly reorder attributes, so can't use direct string comparison)
Diffstat (limited to 'org.eclipse.ua.tests')
5 files changed, 167 insertions, 118 deletions
diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java index 19d2bfb7b..8456f4f2d 100644 --- a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java +++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java @@ -11,12 +11,23 @@ package org.eclipse.ua.tests.util; import java.io.ByteArrayInputStream; +import java.io.IOException; import java.io.InputStream; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; import junit.framework.Assert; -import org.eclipse.help.internal.dynamic.DOMProcessorHandler; -import org.eclipse.help.internal.dynamic.XMLProcessor; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; /** * A utility class for working with XML. @@ -30,9 +41,74 @@ public class XMLUtil extends Assert { } public static void assertXMLEquals(String msg, InputStream in1, InputStream in2) throws Exception { - XMLProcessor processor = new XMLProcessor(new DOMProcessorHandler[0]); - String s1 = FileUtil.readString(processor.process(in1, null)); - String s2 = FileUtil.readString(processor.process(in2, null)); + String s1 = process(in1); + String s2 = process(in2); assertEquals(msg, s1, s2); } + + private static String process(InputStream in) throws Exception { + SAXParserFactory factory = SAXParserFactory.newInstance(); + SAXParser parser = factory.newSAXParser(); + Handler handler = new Handler(); + parser.parse(in, handler); + return handler.toString(); + } + + private static class Handler extends DefaultHandler { + + private StringBuffer buf = new StringBuffer(); + + /* (non-Javadoc) + * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) + */ + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + buf.append('<'); + buf.append(qName); + + List list = new ArrayList(); + for (int i=0;i<attributes.getLength();++i) { + list.add(attributes.getQName(i)); + } + Collections.sort(list); + Iterator iter = list.iterator(); + while (iter.hasNext()) { + String name = (String)iter.next(); + buf.append(' '); + buf.append(name); + buf.append('='); + buf.append('"'); + buf.append(attributes.getValue(name)); + buf.append('"'); + } + buf.append('>'); + } + + /* (non-Javadoc) + * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String) + */ + public void endElement(String uri, String localName, String qName) throws SAXException { + buf.append('<'); + buf.append('/'); + buf.append(qName); + buf.append('>'); + } + + /* (non-Javadoc) + * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int) + */ + public void characters(char[] ch, int start, int length) throws SAXException { + buf.append(ch, start, length); + } + + /* (non-Javadoc) + * @see org.xml.sax.helpers.DefaultHandler#resolveEntity(java.lang.String, java.lang.String) + */ + public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { + return new InputSource(new StringReader("")); //$NON-NLS-1$ + } + + public String toString() { + return buf.toString(); + } + } } diff --git a/org.eclipse.ua.tests/data/help/dynamic/extension_expected.txt b/org.eclipse.ua.tests/data/help/dynamic/extension_expected.txt index 5a1d96c50..a9b1f5d93 100644 --- a/org.eclipse.ua.tests/data/help/dynamic/extension_expected.txt +++ b/org.eclipse.ua.tests/data/help/dynamic/extension_expected.txt @@ -1,4 +1,3 @@ -<?xml version="1.0" encoding="UTF-8"?> <root> <description> @@ -11,27 +10,24 @@ the same file. </element> - <!-- - Valid cases - --> + - <!-- anchor with no contributions; should just remove --> + - <!-- anchor with one contribution --> + <extendedContent id="content"> This is the first element from /org.eclipse.ua.tests/data/help/dynamic/extension.content.xml </extendedContent> - <!-- anchor with two contributions; one in legacy format (slash vs '#') --> + <extendedContent id="content2"> This is the second element from /org.eclipse.ua.tests/data/help/dynamic/extension.content.xml - </extendedContent> -<extendedContent id="content3"> + </extendedContent><extendedContent id="content3"> This is the third element from /org.eclipse.ua.tests/data/help/dynamic/extension.content.xml </extendedContent> - <!-- anchor with a contribution with dynamic content --> + <doc id="doc.1"> <description> This document contains a mixture of dynamic content and is used by other @@ -51,40 +47,37 @@ </element> <element id="element.2"> This is element 2 of doc2.xml - </element> -<element id="element.3"> + </element><element id="element.3"> This is element 3 of doc2.xml </element> </doc> - <!-- anchor with a contribution from this same file --> + <element id="element.1"> This element is used to test contributions and replaces from within the same file. </element> - <!-- anchor with xhtml body element contribution --> - <h1>Heading</h1> -<p> + + <h1>Heading</h1><p> This is the body of /org.eclipse.ua.tests/data/help/dynamic/extension/doc.xhtml. -</p> -<p> +</p><p> The body contains several elements, including these two paragraphs and the heading above. </p> - <!-- element with no id; shouldn't be modified --> - <element/> + + <element></element> - <!-- element with id but no replaces; shouldn't be modified --> - <element id="replace.1"/> + + <element id="replace.1"></element> - <!-- element to be replaced by another --> + <extendedContent id="content"> This is the first element from /org.eclipse.ua.tests/data/help/dynamic/extension.content.xml </extendedContent> - <!-- element to be replaced by another with dynamic content --> + <doc id="doc.1"> <description> This document contains a mixture of dynamic content and is used by other @@ -104,35 +97,32 @@ heading above. </element> <element id="element.2"> This is element 2 of doc2.xml - </element> -<element id="element.3"> + </element><element id="element.3"> This is element 3 of doc2.xml </element> </doc> - <!-- element to be replaced by another from the same file --> + <element id="element.1"> This element is used to test contributions and replaces from within the same file. </element> - <!-- - Invalid cases - --> + - <!-- anchor with valid id but invalid contributions --> + - <!-- anchor with missing id; should just remove --> + - <!-- anchor with missing id, wrong param; should just remove --> + - <!-- anchor with children elements; should just remove --> + - <!-- element with invalid replaces --> - <element id="replace.invalid"/> + + <element id="replace.invalid"></element> </root>
\ No newline at end of file diff --git a/org.eclipse.ua.tests/data/help/dynamic/filter_expected.txt b/org.eclipse.ua.tests/data/help/dynamic/filter_expected.txt index 66bfa08b1..3edd5098a 100644 --- a/org.eclipse.ua.tests/data/help/dynamic/filter_expected.txt +++ b/org.eclipse.ua.tests/data/help/dynamic/filter_expected.txt @@ -1,4 +1,3 @@ -<?xml version="1.0" encoding="UTF-8"?> <root> <description> @@ -6,21 +5,19 @@ of which should be applied and others which shouldn't. </description> - <!-- - Valid cases - --> - <!-- simple test cases; don't filter --> - <element/> - <element/> - <element/> - <element/> - <element/> - <element/> - <element/> - <element/> + + + <element></element> + <element></element> + <element></element> + <element></element> + <element></element> + <element></element> + <element></element> + <element></element> - <!-- simple test case; filter --> + @@ -30,7 +27,7 @@ - <!-- filter element test cases; don't filter --> + <element> </element> @@ -56,7 +53,7 @@ </element> - <!-- filter element test cases; filter --> + @@ -66,29 +63,29 @@ - <!-- multiple filters; shouldn't filter --> + <element> </element> - <!-- multiple filters; should filter --> + - <!-- filter with children; shouldn't filter --> + <element> <child>This child element shouldnt be filtered</child> </element> - <!-- filter with children; should filter all --> + - <!-- filter with dynamic content; should filter --> + - <!-- filter with dynamic content; shouldn't filter --> + <element> <doc id="doc.1"> <description> @@ -109,8 +106,7 @@ </element> <element id="element.2"> This is element 2 of doc2.xml - </element> -<element id="element.3"> + </element><element id="element.3"> This is element 3 of doc2.xml </element> </doc> @@ -136,40 +132,37 @@ </element> <element id="element.2"> This is element 2 of doc2.xml - </element> -<element id="element.3"> + </element><element id="element.3"> This is element 3 of doc2.xml </element> </doc> </element> - <!-- - Invalid cases - --> + - <!-- empty filter value --> - <element/> + + <element></element> - <!-- no equals --> - <element/> + + <element></element> - <!-- no value --> - <element/> + + <element></element> - <!-- no name --> - <element/> + + <element></element> - <!-- missing params --> + <element> </element> - <!-- missing name --> + <element> </element> - <!-- missing value --> + <element> </element> diff --git a/org.eclipse.ua.tests/data/help/dynamic/include_expected.txt b/org.eclipse.ua.tests/data/help/dynamic/include_expected.txt index 53a9c68c9..7dd8a81ad 100644 --- a/org.eclipse.ua.tests/data/help/dynamic/include_expected.txt +++ b/org.eclipse.ua.tests/data/help/dynamic/include_expected.txt @@ -1,4 +1,3 @@ -<?xml version="1.0" encoding="UTF-8"?> <root> <description> @@ -10,22 +9,20 @@ This element is used to test includes within the same file. </element> - <!-- - Valid cases - --> - <!-- valid include --> + + <paragraph id="paragraph.1"> This is the first paragraph from /org.eclipse.ua.tests/data/help/dynamic/include/doc1.xml </paragraph> - <!-- include from same document --> + <element id="element.1"> This element is used to test includes within the same file. </element> - <!-- included element has yet more dynamic content --> + <doc id="doc.1"> <description> This document contains a mixture of dynamic content and is used by other @@ -45,50 +42,47 @@ </element> <element id="element.2"> This is element 2 of doc2.xml - </element> -<element id="element.3"> + </element><element id="element.3"> This is element 3 of doc2.xml </element> </doc> - <!-- legacy format: no slash at beginning, slash in place of # --> + <paragraph id="paragraph.1"> This is the first paragraph from /org.eclipse.ua.tests/data/help/dynamic/include/doc1.xml </paragraph> - <!-- extra unknown parameters --> + <paragraph id="paragraph.1"> This is the first paragraph from /org.eclipse.ua.tests/data/help/dynamic/include/doc1.xml </paragraph> - <!-- extra unknown children --> + <paragraph id="paragraph.1"> This is the first paragraph from /org.eclipse.ua.tests/data/help/dynamic/include/doc1.xml </paragraph> - <!-- - Invalid cases - --> + - <!-- missing path --> + - <!-- missing path; unknown parameter --> - <!-- invalid bundle id --> + + - <!-- invalid path --> + - <!-- invalid file --> + - <!-- invalid id --> + </root>
\ No newline at end of file diff --git a/org.eclipse.ua.tests/data/help/dynamic/xhtml_expected.txt b/org.eclipse.ua.tests/data/help/dynamic/xhtml_expected.txt index 6b4e10daa..625ead310 100644 --- a/org.eclipse.ua.tests/data/help/dynamic/xhtml_expected.txt +++ b/org.eclipse.ua.tests/data/help/dynamic/xhtml_expected.txt @@ -1,13 +1,13 @@ -<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> -<meta content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." name="copyright"/> +<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." /> -<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"/> -<meta content="text/css" http-equiv="Content-Style-Type"/> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> +<meta http-equiv="Content-Style-Type" content="text/css" /> -<link charset="ISO-8859-1" href="../book.css" rel="STYLESHEET" type="text/css"/> +<link rel="STYLESHEET" href="../book.css" charset="ISO-8859-1" type="text/css" /> <title>Exporting files</title> <script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"> </script> </head> @@ -18,17 +18,16 @@ Exporting files </h1> <p class="Para">Files can be exported from the Workbench either by:</p> <ul> <li> Dragging and dropping to the file system (Windows and Linux GTK only), or</li> - <li> <img align="texttop" alt="Windows only" border="0" src="../images/win_only.png"/> + <li> <img align="texttop" border="0" src="../images/win_only.png" alt="Windows only" /> Copying and pasting to the file system, or</li> <li> Using the <a class="command-link" href="javascript:executeCommand("org.eclipse.ui.file.export")"> <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"/> - <b>Export wizard</b> -</a>.</li> + <b>Export wizard</b></a>.</li> </ul> <h2> Drag and drop or copy and paste</h2> -<p class="Para"> <img align="texttop" alt="Windows only" border="0" src="../images/win_only.png"/> +<p class="Para"> <img align="texttop" border="0" src="../images/win_only.png" alt="Windows only" /> The operating system's file system explorer can be used to export a copy of a folder or file from the Workbench to the file system.</p> <ol> @@ -64,8 +63,7 @@ Drag and drop or copy and paste</h2> <li> <p class="Para"> In the Export wizard, select <b>File system</b>, then click <b>Next</b>.</p> - <p class="Para"> <img alt="Export Wizard. Select an export destination." border="0" src="../images/Image42_export.png"/> -</p> + <p class="Para"> <img src="../images/Image42_export.png" alt="Export Wizard. Select an export destination." border="0" /></p> </li> <li> <p class="Para">Expand JaneQuser project, and click on JanesFolder. In the @@ -74,13 +72,11 @@ Drag and drop or copy and paste</h2> that some, but not all, of their contents will be exported.</p> <p class="Para">The <b>Select Types</b> button can be used to filter the types of resources to export.</p> - <p class="Para"> -<strong>Note:</strong> To export JanesINIFile.ini only, simply + <p class="Para"><strong>Note:</strong> To export JanesINIFile.ini only, simply select it in the navigation view and choose <b>File > Export</b>. The Export wizard will automatically ensure it is the only file selected for export. </p> - <p class="Para"> <img alt="Export Wizard. Enter a destination directory." border="0" src="../images/Image43_export_tree.png"/> -</p> + <p class="Para"> <img src="../images/Image43_export_tree.png" alt="Export Wizard. Enter a destination directory." border="0" /></p> </li> <li> <p class="Para"> In the <b> To directory</b> field, type or browse to select @@ -102,4 +98,4 @@ Drag and drop or copy and paste</h2> </ol> </body> -</html>
\ No newline at end of file +</html> |