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/25 23:20:25 UTC
svn commit: r1365757 - in /webservices/axiom/branches/AXIOM-435/modules:
axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/
axiom-api/src/test/java/org/apache/axiom/om/impl/serialize/
axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/ axio...
Author: veithen
Date: Wed Jul 25 21:20:25 2012
New Revision: 1365757
URL: http://svn.apache.org/viewvc?rev=1365757&view=rev
Log:
More unfinished code.
Modified:
webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTestCase.java
webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializerTest.java
webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java
webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCloneNode.java
webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMEntityReferenceImpl.java
webservices/axiom/branches/AXIOM-435/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestClone.java
webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/pom.xml
webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTestCase.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTestCase.java?rev=1365757&r1=1365756&r2=1365757&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTestCase.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTestCase.java Wed Jul 25 21:20:25 2012
@@ -28,8 +28,8 @@ import junit.framework.TestSuite;
import org.apache.axiom.om.AbstractTestCase;
import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.testutils.XMLAssertEx;
import org.apache.axiom.testutils.conformance.ConformanceTestFile;
-import org.xml.sax.InputSource;
public class StreamSourceToOMResultTestCase extends AbstractTestCase {
private final OMMetaFactory omMetaFactory;
@@ -45,14 +45,13 @@ public class StreamSourceToOMResultTestC
}
protected void runTest() throws Throwable {
- StreamSource source = new StreamSource(file.getAsStream());
+ StreamSource source = new StreamSource(file.getUrl().toString());
OMResult result = new OMResult(omMetaFactory.getOMFactory());
transformerFactory.newTransformer().transform(source, result);
ByteArrayOutputStream out = new ByteArrayOutputStream();
result.getDocument().serialize(out);
- assertXMLIdentical(compareXML(
- new InputSource(file.getAsStream()),
- new InputSource(new ByteArrayInputStream(out.toByteArray()))), true);
+ XMLAssertEx.assertXMLIdentical(file.getUrl(),
+ new ByteArrayInputStream(out.toByteArray()), true);
}
public static TestSuite suite(OMMetaFactory omMetaFactory,
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializerTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializerTest.java?rev=1365757&r1=1365756&r2=1365757&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializerTest.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializerTest.java Wed Jul 25 21:20:25 2012
@@ -26,14 +26,15 @@ import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.stream.StreamSource;
import junit.framework.TestSuite;
import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.testutils.XMLAssertEx;
import org.apache.axiom.testutils.conformance.ConformanceTestFile;
import org.apache.axiom.util.stax.dialect.StAXDialect;
import org.apache.axiom.util.stax.dialect.StAXDialectDetector;
-import org.xml.sax.InputSource;
public class StreamingOMSerializerTest extends AbstractTestCase {
private final ConformanceTestFile file;
@@ -49,18 +50,18 @@ public class StreamingOMSerializerTest e
inputFactory = dialect.normalize(inputFactory);
// Allow CDATA events
inputFactory = dialect.enableCDataReporting(inputFactory);
+ inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE);
XMLOutputFactory outputFactory = dialect.normalize(XMLOutputFactory.newInstance());
StreamingOMSerializer serializer = new StreamingOMSerializer();
ByteArrayOutputStream out = new ByteArrayOutputStream();
- XMLStreamReader reader = inputFactory.createXMLStreamReader(file.getAsStream());
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StreamSource(file.getUrl().toString()));
String encoding = reader.getEncoding();
XMLStreamWriter writer = outputFactory.createXMLStreamWriter(out, encoding);
writer.writeStartDocument(encoding, reader.getVersion());
serializer.serialize(reader, writer, false);
writer.writeEndDocument();
writer.flush();
- assertXMLIdentical(compareXML(new InputSource(file.getAsStream()),
- new InputSource(new ByteArrayInputStream(out.toByteArray()))), true);
+ XMLAssertEx.assertXMLIdentical(file.getUrl(), new ByteArrayInputStream(out.toByteArray()), false);
}
public static TestSuite suite() throws Exception {
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java?rev=1365757&r1=1365756&r2=1365757&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java Wed Jul 25 21:20:25 2012
@@ -95,7 +95,12 @@ public class DialectTestSuiteBuilder ext
addTest(new TestGetNameIllegalStateException(staxImpl, XMLStreamConstants.CDATA, true));
addTest(new TestGetNamespaceContextImplicitNamespaces(staxImpl));
for (int i=0; i<conformanceTestFiles.length; i++) {
- addTest(new TestGetNamespaceContext(staxImpl, conformanceTestFiles[i]));
+ ConformanceTestFile file = conformanceTestFiles[i];
+ // Some parsers have problems with external subsets; anyway the test files with
+ // DTDs are not essential for this test.
+ if (!file.hasExternalSubset()) {
+ addTest(new TestGetNamespaceContext(staxImpl, file));
+ }
}
addTest(new TestGetNamespacePrefixDefaultNamespace(staxImpl));
addTest(new TestGetNamespaceURIIllegalStateException(staxImpl, XMLStreamConstants.START_ELEMENT, false));
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCloneNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCloneNode.java?rev=1365757&r1=1365756&r2=1365757&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCloneNode.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCloneNode.java Wed Jul 25 21:20:25 2012
@@ -36,7 +36,7 @@ public class TestCloneNode extends DOMTe
}
protected void runTest() throws Throwable {
- Document document = dbf.newDocumentBuilder().parse(file.getAsStream());
+ Document document = dbf.newDocumentBuilder().parse(file.getUrl().toString());
Document document2 = (Document)document.cloneNode(true);
XMLAssert.assertXMLIdentical(XMLUnit.compareXML(document, document2), true);
}
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMEntityReferenceImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMEntityReferenceImpl.java?rev=1365757&r1=1365756&r2=1365757&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMEntityReferenceImpl.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMEntityReferenceImpl.java Wed Jul 25 21:20:25 2012
@@ -55,7 +55,6 @@ public class OMEntityReferenceImpl exten
}
OMNode clone(OMCloneOptions options, OMContainer targetParent) {
- // TODO
- throw new UnsupportedOperationException();
+ return new OMEntityReferenceImpl(targetParent, name, replacementText, factory, false);
}
}
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestClone.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestClone.java?rev=1365757&r1=1365756&r2=1365757&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestClone.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestClone.java Wed Jul 25 21:20:25 2012
@@ -20,17 +20,13 @@ package org.apache.axiom.ts.om.document;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
import org.apache.axiom.om.OMCloneOptions;
import org.apache.axiom.om.OMDocument;
-import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.testutils.XMLAssertEx;
import org.apache.axiom.testutils.conformance.ConformanceTestFile;
import org.apache.axiom.ts.ConformanceTestCase;
-import org.custommonkey.xmlunit.XMLAssert;
-import org.custommonkey.xmlunit.XMLUnit;
import org.xml.sax.InputSource;
public class TestClone extends ConformanceTestCase {
@@ -39,19 +35,12 @@ public class TestClone extends Conforman
}
protected void runTest() throws Throwable {
- OMFactory factory = metaFactory.getOMFactory();
- InputStream in = file.getAsStream();
- try {
- OMDocument original = OMXMLBuilderFactory.createOMBuilder(factory,
- TEST_PARSER_CONFIGURATION, in).getDocument();
- OMDocument clone = (OMDocument)original.clone(new OMCloneOptions());
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- clone.serialize(baos);
- XMLAssert.assertXMLIdentical(XMLUnit.compareXML(
- new InputSource(file.getAsStream()),
- new InputSource(new ByteArrayInputStream(baos.toByteArray()))), true);
- } finally {
- in.close();
- }
+ OMDocument original = metaFactory.createOMBuilder(metaFactory.getOMFactory(),
+ TEST_PARSER_CONFIGURATION, new InputSource(file.getUrl().toString())).getDocument();
+ OMDocument clone = (OMDocument)original.clone(new OMCloneOptions());
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ clone.serialize(baos);
+ XMLAssertEx.assertXMLIdentical(file.getUrl(),
+ new ByteArrayInputStream(baos.toByteArray()), false);
}
}
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=1365757&r1=1365756&r2=1365757&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/pom.xml (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/pom.xml Wed Jul 25 21:20:25 2012
@@ -99,7 +99,7 @@
filelist.parentFile.mkdirs();
filelist.delete();
new File(project.basedir, "src/main/resources/org/apache/axiom/testutils/conformance").eachFile({
- if (it.file) {
+ if (it.file && it.name.endsWith(".xml")) {
filelist.append("$it.name\n");
}
})
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java?rev=1365757&r1=1365756&r2=1365757&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java Wed Jul 25 21:20:25 2012
@@ -31,20 +31,24 @@ import javax.xml.stream.XMLStreamExcepti
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.stream.StreamSource;
+import org.codehaus.stax2.DTDInfo;
+
public final class ConformanceTestFile {
private static ConformanceTestFile[] instances;
private final String resourceName;
private final String shortName;
private final boolean hasDTD;
+ private final boolean hasExternalSubset;
private final boolean hasInternalSubset;
private final boolean hasEntityReferences;
private ConformanceTestFile(String resourceName, String shortName, boolean hasDTD,
- boolean hasInternalSubset, boolean hasEntityReferences) {
+ boolean hasExternalSubset, boolean hasInternalSubset, boolean hasEntityReferences) {
this.resourceName = resourceName;
this.shortName = shortName;
this.hasDTD = hasDTD;
+ this.hasExternalSubset = hasExternalSubset;
this.hasInternalSubset = hasInternalSubset;
this.hasEntityReferences = hasEntityReferences;
}
@@ -61,6 +65,10 @@ public final class ConformanceTestFile {
return hasDTD;
}
+ public boolean hasExternalSubset() {
+ return hasExternalSubset;
+ }
+
public boolean hasInternalSubset() {
return hasInternalSubset;
}
@@ -89,6 +97,7 @@ public final class ConformanceTestFile {
while ((name = in.readLine()) != null) {
String resourceName = "org/apache/axiom/testutils/conformance/" + name;
boolean hasDTD = false;
+ boolean hasExternalSubset = false;
boolean hasInternalSubset = false;
boolean hasEntityReferences = false;
try {
@@ -99,6 +108,7 @@ public final class ConformanceTestFile {
case XMLStreamReader.DTD:
hasDTD = true;
hasInternalSubset = reader.getText().length() > 0;
+ hasExternalSubset = ((DTDInfo)reader).getDTDSystemId() != null;
break;
case XMLStreamReader.ENTITY_REFERENCE:
hasEntityReferences = true;
@@ -109,7 +119,7 @@ public final class ConformanceTestFile {
} catch (XMLStreamException ex) {
throw new Error("Unable to parse " + resourceName);
}
- result.add(new ConformanceTestFile(resourceName, name, hasDTD, hasInternalSubset, hasEntityReferences));
+ result.add(new ConformanceTestFile(resourceName, name, hasDTD, hasExternalSubset, hasInternalSubset, hasEntityReferences));
}
in.close();
return (ConformanceTestFile[])result.toArray(new ConformanceTestFile[result.size()]);