Author: veithen
Date: Thu Apr 12 20:33:20 2012
New Revision: 1325493
URL: http://svn.apache.org/viewvc?rev=1325493&view=rev
Log:
AXIOM-311: Refactored the regression test for AXIOM-69.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestImportNode.java
- copied, changed from r1325452,
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ElementImportTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/resources/sigEncr.xml
- copied unchanged from r1325452,
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/resources/sigEncr.xml
Removed:
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ElementImportTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/resources/sigEncr.xml
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTestUtils.java
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMTestUtils.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTestUtils.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTestUtils.java?rev=1325493&r1=1325492&r2=1325493&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTestUtils.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMTestUtils.java
Thu Apr 12 20:33:20 2012
@@ -21,12 +21,6 @@ package org.apache.axiom.om;
import junit.framework.TestCase;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
import java.util.Iterator;
public class OMTestUtils {
@@ -51,57 +45,4 @@ public class OMTestUtils {
}
}
}
-
- public static void compare(Element ele, OMElement omele) throws Exception {
- if (ele == null && omele == null) {
- return;
- } else if (ele != null && omele != null) {
- TestCase.assertEquals("Element name not correct",
- ele.getLocalName(),
- omele.getLocalName());
- if (omele.getNamespace() != null) {
- TestCase.assertEquals("Namespace URI not correct",
- ele.getNamespaceURI(),
- omele.getNamespace().getNamespaceURI());
-
- }
-
- //go through the attributes
- NamedNodeMap map = ele.getAttributes();
- Iterator attIterator = omele.getAllAttributes();
- OMAttribute omattribute;
- while (attIterator != null && attIterator.hasNext() && map ==
null) {
- omattribute = (OMAttribute) attIterator.next();
- Node node = map.getNamedItemNS(
- omattribute.getNamespace().getNamespaceURI(),
- omattribute.getLocalName());
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- Attr attr = (Attr) node;
- TestCase.assertEquals(attr.getValue(),
- omattribute.getAttributeValue());
- } else {
- throw new OMException("return type is not a Attribute");
- }
-
- }
- Iterator it = omele.getChildren();
- NodeList list = ele.getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node node = list.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- TestCase.assertTrue(it.hasNext());
- OMNode tempOmNode = (OMNode) it.next();
- while (tempOmNode.getType() != OMNode.ELEMENT_NODE) {
- TestCase.assertTrue(it.hasNext());
- tempOmNode = (OMNode) it.next();
- }
- compare((Element) node, (OMElement) tempOmNode);
- }
- }
-
-
- } else {
- throw new Exception("One is null");
- }
- }
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMTestUtils.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMTestUtils.java?rev=1325493&r1=1325492&r2=1325493&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMTestUtils.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/OMTestUtils.java
Thu Apr 12 20:33:20 2012
@@ -20,18 +20,11 @@
package org.apache.axiom.om.impl.dom;
import junit.framework.TestCase;
-import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
import java.io.InputStream;
import java.util.Iterator;
@@ -64,57 +57,4 @@ public class OMTestUtils {
}
}
}
-
- public static void compare(Element ele, OMElement omele) throws Exception {
- if (ele == null && omele == null) {
- return;
- } else if (ele != null && omele != null) {
- TestCase.assertEquals("Element name not correct",
- ele.getLocalName(),
- omele.getLocalName());
- if (omele.getNamespace() != null) {
- TestCase.assertEquals("Namespace URI not correct",
- ele.getNamespaceURI(),
- omele.getNamespace().getNamespaceURI());
-
- }
-
- //go through the attributes
- NamedNodeMap map = ele.getAttributes();
- Iterator attIterator = omele.getAllAttributes();
- OMAttribute omattribute;
- while (attIterator != null && attIterator.hasNext() && map ==
null) {
- omattribute = (OMAttribute) attIterator.next();
- Node node = map.getNamedItemNS(
- omattribute.getNamespace().getNamespaceURI(),
- omattribute.getLocalName());
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- Attr attr = (Attr) node;
- TestCase.assertEquals(attr.getValue(),
- omattribute.getAttributeValue());
- } else {
- throw new OMException("return type is not a Attribute");
- }
-
- }
- Iterator it = omele.getChildren();
- NodeList list = ele.getChildNodes();
- for (int i = 0; i < list.getLength(); i++) {
- Node node = list.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- TestCase.assertTrue(it.hasNext());
- OMNode tempOmNode = (OMNode) it.next();
- while (tempOmNode.getType() != OMNode.ELEMENT_NODE) {
- TestCase.assertTrue(it.hasNext());
- tempOmNode = (OMNode) it.next();
- }
- compare((Element) node, (OMElement) tempOmNode);
- }
- }
-
-
- } else {
- throw new Exception("One is null");
- }
- }
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java?rev=1325493&r1=1325492&r2=1325493&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
Thu Apr 12 20:33:20 2012
@@ -36,6 +36,7 @@ public class OMDOMTestSuiteBuilder exten
protected void addTests() {
addTest(new
org.apache.axiom.ts.omdom.attr.TestGetNamespaceNormalized(metaFactory));
+ addTest(new
org.apache.axiom.ts.omdom.document.TestImportNode(metaFactory));
addTest(new
org.apache.axiom.ts.omdom.element.TestAddChildFromForeignDocument(metaFactory));
addTest(new
org.apache.axiom.ts.omdom.element.TestGetNamespaceNormalized(metaFactory));
addTest(new
org.apache.axiom.ts.omdom.element.TestRemoveChildIncomplete(metaFactory));
Copied:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestImportNode.java
(from r1325452,
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ElementImportTest.java)
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestImportNode.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestImportNode.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ElementImportTest.java&r1=1325452&r2=1325493&rev=1325493&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ElementImportTest.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/document/TestImportNode.java
Thu Apr 12 20:33:20 2012
@@ -17,25 +17,92 @@
* under the License.
*/
-package org.apache.axiom.om.impl.dom;
+package org.apache.axiom.ts.omdom.document;
+
+import java.util.Iterator;
import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMTestUtils;
-import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.dom.DOMMetaFactory;
+import org.apache.axiom.ts.AxiomTestCase;
+import org.w3c.dom.Attr;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import javax.xml.parsers.DocumentBuilderFactory;
-public class ElementImportTest extends AbstractTestCase {
+public class TestImportNode extends AxiomTestCase {
+ public TestImportNode(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
- public void testImport() throws Exception {
+ protected void runTest() throws Throwable {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document doc = dbf.newDocumentBuilder().parse(
- getTestResource("sigEncr.xml"));
- Node n = new
OMDOMFactory().getDocument().importNode(doc.getDocumentElement(), true);
- OMTestUtils.compare(doc.getDocumentElement(), (OMElement) n);
+ AbstractTestCase.getTestResource("sigEncr.xml"));
+ Document doc2 =
((DOMMetaFactory)metaFactory).newDocumentBuilderFactory().newDocumentBuilder().newDocument();
+ Node n = doc2.importNode(doc.getDocumentElement(), true);
+ compare(doc.getDocumentElement(), (OMElement) n);
+ }
+
+ private static void compare(Element ele, OMElement omele) throws Exception
{
+ if (ele == null && omele == null) {
+ return;
+ } else if (ele != null && omele != null) {
+ assertEquals("Element name not correct",
+ ele.getLocalName(),
+ omele.getLocalName());
+ if (omele.getNamespace() != null) {
+ assertEquals("Namespace URI not correct",
+ ele.getNamespaceURI(),
+ omele.getNamespace().getNamespaceURI());
+
+ }
+
+ //go through the attributes
+ NamedNodeMap map = ele.getAttributes();
+ Iterator attIterator = omele.getAllAttributes();
+ OMAttribute omattribute;
+ while (attIterator != null && attIterator.hasNext() && map ==
null) {
+ omattribute = (OMAttribute) attIterator.next();
+ Node node = map.getNamedItemNS(
+ omattribute.getNamespace().getNamespaceURI(),
+ omattribute.getLocalName());
+ if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
+ Attr attr = (Attr) node;
+ assertEquals(attr.getValue(),
+ omattribute.getAttributeValue());
+ } else {
+ throw new OMException("return type is not a Attribute");
+ }
+
+ }
+ Iterator it = omele.getChildren();
+ NodeList list = ele.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++) {
+ Node node = list.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ assertTrue(it.hasNext());
+ OMNode tempOmNode = (OMNode) it.next();
+ while (tempOmNode.getType() != OMNode.ELEMENT_NODE) {
+ assertTrue(it.hasNext());
+ tempOmNode = (OMNode) it.next();
+ }
+ compare((Element) node, (OMElement) tempOmNode);
+ }
+ }
+
+
+ } else {
+ throw new Exception("One is null");
+ }
}
}