[jbosstools-commits] JBoss Tools SVN: r17482 - trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Sep 8 19:45:58 EDT 2009
Author: dgolovin
Date: 2009-09-08 19:45:58 -0400 (Tue, 08 Sep 2009)
New Revision: 17482
Added:
trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest1.xml
trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest2.xml
Modified:
trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3892
increase code coverage for o.j.t.common plug-in
Modified: trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest.java 2009-09-08 23:45:37 UTC (rev 17481)
+++ trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest.java 2009-09-08 23:45:58 UTC (rev 17482)
@@ -10,7 +10,14 @@
******************************************************************************/
package org.jboss.tools.common.xml.test;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import javax.xml.parsers.DocumentBuilder;
+
import org.jboss.tools.common.xml.XMLUtilities;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import junit.framework.TestCase;
@@ -18,8 +25,7 @@
public class XMLUtilitiesTest extends TestCase {
public final void testCreateDocumentBuilder() {
- assertNotNull("Element builder without validation wasn't created", XMLUtilities.createDocumentBuilder(true)); // TODO
- assertNotNull("Element builder with validation wasn't created", XMLUtilities.createDocumentBuilder(true)); // TODO
+ assertNotNull("Element builder without validation wasn't created", XMLUtilities.createDocumentBuilder()); // TODO
}
public static final String ELEMENT_NAME = "ElementName";
@@ -30,4 +36,56 @@
assertTrue(element.getNodeName().equals(ELEMENT_NAME));
}
+ public void testCreateDocumentBuilderBoolean() {
+ assertNotNull("Element builder with validation wasn't created", XMLUtilities.createDocumentBuilder(true)); // TODO
+ }
+
+ public void testGetDocumentReaderEntityResolver() throws IOException {
+ assertNotNull(getGoodDocument());;
+ }
+
+ public void testHasAttributeElementString() {
+ Element element = getGoodDocument().getDocumentElement();
+ assertTrue(XMLUtilities.hasAttribute(element, "attribute1"));
+ }
+
+ public void testGetChildrenElementsElementString() {
+ Element element = getGoodDocument().getDocumentElement();
+ assertTrue(XMLUtilities.getChildren(element, "child1").length==4);
+ }
+
+ public void testGetUniqueChildElementString() {
+ Element element = getGoodDocument().getDocumentElement();
+ assertNotNull(XMLUtilities.getUniqueChild(element, "child1"));
+ }
+
+ public void testGetChildrenElementString() {
+ Element element = getGoodDocument().getDocumentElement();
+ assertTrue(XMLUtilities.getChildren(element, "child1").length==4);
+ }
+
+ public void testGetFirstChildElementString() {
+ Element element = getGoodDocument().getDocumentElement();
+ Element first = XMLUtilities.getFirstChild(element,"child1");
+ assertTrue(first.getAttribute("first").equals("true"));
+ first = XMLUtilities.getFirstChild(element,"child2");
+ assertTrue(first.getAttribute("first").equals("true"));
+ first = XMLUtilities.getFirstChild(element,"child10");
+ assertNull(first);
+ }
+
+ public static final Document getGoodDocument() {
+ InputStream in = null;
+ try {
+ in = XMLUtilitiesTest.class.getResourceAsStream("XMLUtilitiesTest1.xml");
+ Document document = XMLUtilities.getDocument(new InputStreamReader(in), XMLUtilities.EMPTY_RESOLVER);
+ assertNotNull(document);
+ return document;
+ } finally {
+ try {
+ in.close();
+ } catch (IOException e) {
+ }
+ }
+ }
}
Added: trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest1.xml
===================================================================
--- trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest1.xml (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest1.xml 2009-09-08 23:45:58 UTC (rev 17482)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<node1 attribute1="valueOfAttribute1">
+ <child1 first="true"></child1>
+ <child1></child1>
+ <child1></child1>
+ <child1></child1>
+ <child2 first="true"></child2>
+ <child3></child3>
+ <child4></child4>
+ <child5></child5>
+</node1>
\ No newline at end of file
Property changes on: trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest1.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest2.xml
===================================================================
--- trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest2.xml (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest2.xml 2009-09-08 23:45:58 UTC (rev 17482)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<
+<node1>
+ <child1></child1>
+ <child2></child2>
+ <child3></child3>
+ <child4></child4>
+ <child5></child5>
+</node1>
\ No newline at end of file
Property changes on: trunk/common/tests/org.jboss.tools.common.test/src/org/jboss/tools/common/xml/test/XMLUtilitiesTest2.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the jbosstools-commits
mailing list