You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2012/07/23 14:18:21 UTC
svn commit: r1364604 - in /webservices/axiom/branches/AXIOM-435/modules:
axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/
axiom-testutils/ axiom-testutils/src/main/java/org/apache/axiom/testutils/
Author: veithen
Date: Mon Jul 23 12:18:21 2012
New Revision: 1364604
URL: http://svn.apache.org/viewvc?rev=1364604&view=rev
Log:
More unfinished code.
Added:
webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/XMLAssertEx.java (with props)
Modified:
webservices/axiom/branches/AXIOM-435/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCreateOMBuilderFromDOMSource.java
webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/pom.xml
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCreateOMBuilderFromDOMSource.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCreateOMBuilderFromDOMSource.java?rev=1364604&r1=1364603&r2=1364604&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCreateOMBuilderFromDOMSource.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/TestCreateOMBuilderFromDOMSource.java Mon Jul 23 12:18:21 2012
@@ -29,6 +29,7 @@ import javax.xml.transform.dom.DOMSource
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.testutils.XMLAssertEx;
import org.apache.axiom.testutils.conformance.ConformanceTestFile;
import org.apache.axiom.ts.ConformanceTestCase;
import org.custommonkey.xmlunit.XMLAssert;
@@ -66,9 +67,10 @@ public class TestCreateOMBuilderFromDOMS
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
builder.getDocument().serialize(baos);
- XMLAssert.assertXMLIdentical(XMLUnit.compareXML(
- new InputSource(getFileAsStream()),
- new InputSource(new ByteArrayInputStream(baos.toByteArray()))), true);
+ XMLAssertEx.assertXMLIdentical(
+ getFileAsStream(),
+ new ByteArrayInputStream(baos.toByteArray()),
+ expandEntityReferences == null ? false : expandEntityReferences.booleanValue());
} finally {
in.close();
}
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/pom.xml?rev=1364604&r1=1364603&r2=1364604&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/pom.xml (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/pom.xml Mon Jul 23 12:18:21 2012
@@ -61,6 +61,10 @@
<artifactId>junit</artifactId>
</dependency>
<dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ </dependency>
+ <dependency>
<!-- We use this only for LDAP like filters -->
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
Added: webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/XMLAssertEx.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/XMLAssertEx.java?rev=1364604&view=auto
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/XMLAssertEx.java (added)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/XMLAssertEx.java Mon Jul 23 12:18:21 2012
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.testutils;
+
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.EntityReference;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public final class XMLAssertEx {
+ private XMLAssertEx() {}
+
+ private static Document parse(InputStream in, boolean expandEntityReferences) throws Exception {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ factory.setExpandEntityReferences(expandEntityReferences);
+ Document document = factory.newDocumentBuilder().parse(in);
+ replaceEntityReferences(document);
+ return document;
+ }
+
+ private static void replaceEntityReferences(Node node) {
+ NodeList children = node.getChildNodes();
+ for (int i=0, l=children.getLength(); i<l; i++) {
+ Node child = children.item(i);
+ if (child instanceof EntityReference) {
+ Element replacement = node.getOwnerDocument().createElementNS(null, "entity-reference");
+ replacement.setAttributeNS(null, "name", child.getNodeName());
+ node.replaceChild(replacement, child);
+ } else {
+ replaceEntityReferences(child);
+ }
+ }
+ }
+
+ public static void assertXMLIdentical(InputStream control, InputStream test, boolean entityReferencesExpanded) throws Exception {
+ XMLAssert.assertXMLIdentical(XMLUnit.compareXML(
+ parse(control, entityReferencesExpanded),
+ parse(test, false)), true);
+ }
+}
Propchange: webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/XMLAssertEx.java
------------------------------------------------------------------------------
svn:eol-style = native