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/26 23:24:55 UTC
svn commit: r1366205 [2/2] - in /webservices/commons/trunk/modules/axiom: ./
modules/axiom-api/src/main/java/org/apache/axiom/om/
modules/axiom-api/src/main/java/org/apache/axiom/om/dom/
modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/...
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestGetSAXSource.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestGetSAXSource.java?rev=1366205&r1=1366204&r2=1366205&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestGetSAXSource.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestGetSAXSource.java Thu Jul 26 21:24:54 2012
@@ -20,20 +20,17 @@ package org.apache.axiom.ts.om.container
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
+import java.net.URL;
+import javax.xml.transform.OutputKeys;
import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.stream.StreamResult;
import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
-import org.apache.axiom.om.util.StAXParserConfiguration;
+import org.apache.axiom.testutils.XMLAssertEx;
import org.apache.axiom.testutils.conformance.ConformanceTestFile;
import org.apache.axiom.ts.ConformanceTestCase;
-import org.apache.xalan.processor.TransformerFactoryImpl;
-import org.custommonkey.xmlunit.XMLAssert;
-import org.custommonkey.xmlunit.XMLUnit;
+import org.xml.sax.XMLReader;
import org.xml.sax.InputSource;
public class TestGetSAXSource extends ConformanceTestCase {
@@ -49,19 +46,25 @@ public class TestGetSAXSource extends Co
}
protected void runTest() throws Throwable {
+ OMXMLParserWrapper builder = metaFactory.createOMBuilder(metaFactory.getOMFactory(),
+ TEST_PARSER_CONFIGURATION, new InputSource(file.getUrl().toString()));
+ SAXSource source = containerFactory.getContainer(builder).getSAXSource(cache);
+ XMLReader xmlReader = source.getXMLReader();
ByteArrayOutputStream out = new ByteArrayOutputStream();
- InputStream in = getFileAsStream();
- try {
- OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
- StAXParserConfiguration.PRESERVE_CDATA_SECTIONS, in);
- SAXSource source = containerFactory.getContainer(builder).getSAXSource(cache);
- StreamResult result = new StreamResult(out);
- new TransformerFactoryImpl().newTransformer().transform(source, result);
- } finally {
- in.close();
- }
- XMLAssert.assertXMLIdentical(XMLUnit.compareXML(
- containerFactory.getControl(getFileAsStream()),
- new InputSource(new ByteArrayInputStream(out.toByteArray()))), true);
+ SAXSerializer serializer = new SAXSerializer();
+ // A SAXSource has no way to tell its consumer about the encoding of the document.
+ // Just set it to UTF-8 to have a well defined encoding.
+ serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+ serializer.setOutputStream(out);
+ xmlReader.setContentHandler(serializer);
+ xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", serializer);
+ xmlReader.parse(source.getInputSource());
+ InputSource control = containerFactory.getControl(file.getAsStream());
+ InputSource test = new InputSource(new ByteArrayInputStream(out.toByteArray()));
+ // Configure the InputSources such that external entities can be resolved
+ String systemId = new URL(file.getUrl(), "dummy.xml").toString();
+ control.setSystemId(systemId);
+ test.setSystemId(systemId);
+ XMLAssertEx.assertXMLIdentical(control, test, false);
}
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestGetXMLStreamReader.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestGetXMLStreamReader.java?rev=1366205&r1=1366204&r2=1366205&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestGetXMLStreamReader.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestGetXMLStreamReader.java Thu Jul 26 21:24:54 2012
@@ -24,12 +24,12 @@ import javax.xml.stream.XMLStreamReader;
import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.om.util.StAXUtils;
import org.apache.axiom.testutils.conformance.ConformanceTestFile;
import org.apache.axiom.testutils.stax.XMLStreamReaderComparator;
import org.apache.axiom.ts.ConformanceTestCase;
+import org.xml.sax.InputSource;
/**
* Test comparing the output of {@link OMContainer#getXMLStreamReader(boolean)} with that of a
@@ -48,12 +48,12 @@ public class TestGetXMLStreamReader exte
}
protected final void runTest() throws Throwable {
- InputStream in1 = getFileAsStream();
- InputStream in2 = getFileAsStream();
+ InputStream in = file.getAsStream();
try {
- XMLStreamReader expected = StAXUtils.createXMLStreamReader(in1);
+ XMLStreamReader expected = StAXUtils.createXMLStreamReader(TEST_PARSER_CONFIGURATION, file.getUrl().toString(), in);
try {
- OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), in2);
+ OMXMLParserWrapper builder = metaFactory.createOMBuilder(metaFactory.getOMFactory(),
+ TEST_PARSER_CONFIGURATION, new InputSource(file.getUrl().toString()));
try {
XMLStreamReader actual = containerFactory.getContainer(builder).getXMLStreamReader(cache);
new XMLStreamReaderComparator(containerFactory.filter(expected), containerFactory.filter(actual)).compare();
@@ -64,8 +64,7 @@ public class TestGetXMLStreamReader exte
expected.close();
}
} finally {
- in1.close();
- in2.close();
+ in.close();
}
}
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestSerialize.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestSerialize.java?rev=1366205&r1=1366204&r2=1366205&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestSerialize.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/container/TestSerialize.java Thu Jul 26 21:24:54 2012
@@ -21,15 +21,11 @@ package org.apache.axiom.ts.om.container
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.InputStream;
-
-import junit.framework.AssertionFailedError;
+import java.net.URL;
import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
-import org.apache.axiom.om.util.StAXParserConfiguration;
import org.apache.axiom.testutils.conformance.ConformanceTestFile;
import org.apache.axiom.ts.ConformanceTestCase;
import org.apache.commons.io.IOUtils;
@@ -51,37 +47,36 @@ public class TestSerialize extends Confo
}
protected void runTest() throws Throwable {
- InputStream in = getFileAsStream();
+ OMXMLParserWrapper builder = metaFactory.createOMBuilder(metaFactory.getOMFactory(),
+ TEST_PARSER_CONFIGURATION, new InputSource(file.getUrl().toString()));
try {
- OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
- StAXParserConfiguration.PRESERVE_CDATA_SECTIONS, in);
+ OMContainer container = containerFactory.getContainer(builder);
+ // We need to clone the InputSource objects so that we can dump their contents
+ // if the test fails
+ InputSource control[] = duplicateInputSource(containerFactory.getControl(file.getAsStream()));
+ InputSource actual[] = duplicateInputSource(serializationMethod.serialize(container));
try {
- OMContainer container = containerFactory.getContainer(builder);
- // We need to clone the InputSource objects so that we can dump their contents
- // if the test fails
- InputSource control[] = duplicateInputSource(containerFactory.getControl(getFileAsStream()));
- InputSource actual[] = duplicateInputSource(serializationMethod.serialize(container));
- try {
- XMLAssert.assertXMLIdentical(XMLUnit.compareXML(control[0], actual[0]), true);
- } catch (Throwable ex) {
- System.out.println("Control:");
- dumpInputSource(control[1]);
- System.out.println("Actual:");
- dumpInputSource(actual[1]);
- throw ex;
- }
- if (serializationMethod.isCaching()) {
- assertTrue(container.isComplete());
- } else {
- // TODO: need to investigate why assertConsumed is not working here
- assertFalse(container.isComplete());
-// assertConsumed(element);
- }
- } finally {
- builder.close();
+ // Configure the InputSources such that external entities can be resolved
+ String systemId = new URL(file.getUrl(), "dummy.xml").toString();
+ control[0].setSystemId(systemId);
+ actual[0].setSystemId(systemId);
+ XMLAssert.assertXMLIdentical(XMLUnit.compareXML(control[0], actual[0]), true);
+ } catch (Throwable ex) {
+ System.out.println("Control:");
+ dumpInputSource(control[1]);
+ System.out.println("Actual:");
+ dumpInputSource(actual[1]);
+ throw ex;
+ }
+ if (serializationMethod.isCaching()) {
+ assertTrue(container.isComplete());
+ } else {
+ // TODO: need to investigate why assertConsumed is not working here
+ assertFalse(container.isComplete());
+// assertConsumed(element);
}
} finally {
- in.close();
+ builder.close();
}
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestClone.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestClone.java?rev=1366205&r1=1366204&r2=1366205&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestClone.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/document/TestClone.java Thu Jul 26 21:24:54 2012
@@ -20,18 +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.om.util.StAXParserConfiguration;
+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 {
@@ -40,19 +35,12 @@ public class TestClone extends Conforman
}
protected void runTest() throws Throwable {
- OMFactory factory = metaFactory.getOMFactory();
- InputStream in = getFileAsStream();
- try {
- OMDocument original = OMXMLBuilderFactory.createOMBuilder(factory,
- StAXParserConfiguration.PRESERVE_CDATA_SECTIONS, in).getDocument();
- OMDocument clone = (OMDocument)original.clone(new OMCloneOptions());
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- clone.serialize(baos);
- XMLAssert.assertXMLIdentical(XMLUnit.compareXML(
- new InputSource(getFileAsStream()),
- 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/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestCloneOMElement2.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestCloneOMElement2.java?rev=1366205&r1=1366204&r2=1366205&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestCloneOMElement2.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestCloneOMElement2.java Thu Jul 26 21:24:54 2012
@@ -36,7 +36,7 @@ public class TestCloneOMElement2 extends
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
- InputStream in = getFileAsStream();
+ InputStream in = file.getAsStream();
try {
OMElement original = OMXMLBuilderFactory.createOMBuilder(factory, in).getDocumentElement();
OMElement clone = original.cloneOMElement();
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1366205&r1=1366204&r2=1366205&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java Thu Jul 26 21:24:54 2012
@@ -31,8 +31,8 @@ import org.apache.axiom.testutils.suite.
public class SOAPTestSuiteBuilder extends TestSuiteBuilder {
private static final String[] badSOAPFiles = { "wrongSoapNs.xml", "notnamespaceQualified.xml", "soap11/twoheaders.xml", "soap11/twoBodymessage.xml",
"soap11/envelopeMissing.xml", "soap11/haederBodyWrongOrder.xml", "soap11/invalid-faultcode.xml", "soap11/invalid-faultstring.xml",
- "soap11/invalid-faultactor.xml", "soap11/processing-instruction.xml",
- "soap12/header-bad-case.xml", "soap12/header-no-namespace.xml", "soap12/processing-instruction.xml" };
+ "soap11/invalid-faultactor.xml", "soap11/processing-instruction.xml", "soap11/entity-reference.xml",
+ "soap12/header-bad-case.xml", "soap12/header-no-namespace.xml", "soap12/processing-instruction.xml", "soap12/entity-reference.xml" };
private static final String[] goodSOAPFiles = { TestConstants.WHITESPACE_MESSAGE,
TestConstants.MINIMAL_MESSAGE, TestConstants.REALLY_BIG_MESSAGE,
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/faultreason/TestGetTextWithCDATA.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/faultreason/TestGetTextWithCDATA.java?rev=1366205&r1=1366204&r2=1366205&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/faultreason/TestGetTextWithCDATA.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap11/faultreason/TestGetTextWithCDATA.java Thu Jul 26 21:24:54 2012
@@ -25,7 +25,6 @@ import javax.xml.stream.XMLStreamReader;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMXMLBuilderFactory;
-import org.apache.axiom.om.util.StAXParserConfiguration;
import org.apache.axiom.om.util.StAXUtils;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFault;
@@ -54,7 +53,7 @@ public class TestGetTextWithCDATA extend
"</SOAP-ENV:Body>" +
"</SOAP-ENV:Envelope>";
XMLStreamReader soap11Parser = StAXUtils.createXMLStreamReader(
- StAXParserConfiguration.PRESERVE_CDATA_SECTIONS, new StringReader(soap11Fault));
+ TEST_PARSER_CONFIGURATION, new StringReader(soap11Fault));
SOAPModelBuilder soap11Builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(metaFactory, soap11Parser);
OMElement element = soap11Builder.getDocumentElement();
element.build();
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testutils/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testutils/pom.xml?rev=1366205&r1=1366204&r2=1366205&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testutils/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testutils/pom.xml Thu Jul 26 21:24:54 2012
@@ -61,6 +61,17 @@
<artifactId>junit</artifactId>
</dependency>
<dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ </dependency>
+ <dependency>
+ <!-- This should not be necessary, but XMLAssertEx contains code that fails on some Java runtimes,
+ presumably because of a bug in the DOM implementation. Therefore we use a well defined
+ version of Xerces. -->
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </dependency>
+ <dependency>
<!-- We use this only for LDAP like filters -->
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
@@ -95,7 +106,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/commons/trunk/modules/axiom/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java?rev=1366205&r1=1366204&r2=1366205&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java Thu Jul 26 21:24:54 2012
@@ -22,12 +22,16 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.stream.StreamSource;
+
+import org.codehaus.stax2.DTDInfo;
public final class ConformanceTestFile {
private static ConformanceTestFile[] instances;
@@ -35,12 +39,17 @@ public final class ConformanceTestFile {
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 hasEntityReferences) {
+ private ConformanceTestFile(String resourceName, String shortName, boolean hasDTD,
+ boolean hasExternalSubset, boolean hasInternalSubset, boolean hasEntityReferences) {
this.resourceName = resourceName;
this.shortName = shortName;
this.hasDTD = hasDTD;
+ this.hasExternalSubset = hasExternalSubset;
+ this.hasInternalSubset = hasInternalSubset;
this.hasEntityReferences = hasEntityReferences;
}
@@ -56,16 +65,24 @@ public final class ConformanceTestFile {
return hasDTD;
}
+ public boolean hasExternalSubset() {
+ return hasExternalSubset;
+ }
+
+ public boolean hasInternalSubset() {
+ return hasInternalSubset;
+ }
+
public boolean hasEntityReferences() {
return hasEntityReferences;
}
public InputStream getAsStream() {
- InputStream in = ConformanceTestFile.class.getClassLoader().getResourceAsStream(resourceName);
- if (in == null) {
- throw new Error("The test resource " + resourceName + " could not be found");
- }
- return in;
+ return ConformanceTestFile.class.getClassLoader().getResourceAsStream(resourceName);
+ }
+
+ public URL getUrl() {
+ return ConformanceTestFile.class.getClassLoader().getResource(resourceName);
}
public static synchronized ConformanceTestFile[] getConformanceTestFiles() {
@@ -80,14 +97,18 @@ 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;
- InputStream in2 = ConformanceTestFile.class.getResourceAsStream(name);
try {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(in2);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StreamSource(
+ ConformanceTestFile.class.getResource(name).toString()));
while (reader.hasNext()) {
switch (reader.next()) {
case XMLStreamReader.DTD:
hasDTD = true;
+ hasInternalSubset = reader.getText().length() > 0;
+ hasExternalSubset = ((DTDInfo)reader).getDTDSystemId() != null;
break;
case XMLStreamReader.ENTITY_REFERENCE:
hasEntityReferences = true;
@@ -97,10 +118,8 @@ public final class ConformanceTestFile {
reader.close();
} catch (XMLStreamException ex) {
throw new Error("Unable to parse " + resourceName);
- } finally {
- in2.close();
}
- result.add(new ConformanceTestFile(resourceName, name, hasDTD, hasEntityReferences));
+ result.add(new ConformanceTestFile(resourceName, name, hasDTD, hasExternalSubset, hasInternalSubset, hasEntityReferences));
}
in.close();
return (ConformanceTestFile[])result.toArray(new ConformanceTestFile[result.size()]);