Author: ggregory
Date: Fri Aug 10 22:53:17 2012
New Revision: 1371836
URL: http://svn.apache.org/viewvc?rev=1371836&view=rev
Log:
Using Niall Pemberton's tip.
Modified:
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
Modified:
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java?rev=1371836&r1=1371835&r2=1371836&view=diff
==============================================================================
---
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
(original)
+++
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
Fri Aug 10 22:53:17 2012
@@ -26,6 +26,7 @@ import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.Reader;
import java.nio.charset.Charset;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -35,7 +36,6 @@ import org.apache.commons.io.ByteOrderMa
import org.apache.commons.io.Charsets;
import org.junit.Assert;
import org.junit.Assume;
-import org.junit.Ignore;
import org.junit.Test;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
@@ -165,6 +165,12 @@ public class BOMInputStreamTest {
assertEquals("X", doc.getFirstChild().getNodeName());
}
+ private void parseXml(Reader in) throws SAXException, IOException,
ParserConfigurationException {
+ final Document doc =
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new
InputSource(in));
+ assertNotNull(doc);
+ assertEquals("X", doc.getFirstChild().getNodeName());
+ }
+
private void readBOMInputStreamTwice(String resource) throws Exception {
InputStream inputStream =
this.getClass().getResourceAsStream(resource);
Assert.assertNotNull(inputStream);
@@ -594,26 +600,22 @@ public class BOMInputStreamTest {
parseXml(createUtf16LeDataStream(data, true));
}
- @Ignore
@Test
public void testReadXmlWithBOMUtf32Be() throws Exception {
Assume.assumeTrue(Charset.isSupported("UTF_32BE"));
byte[] data = "<?xml version=\"1.0\"
encoding=\"UTF-32BE\"?><X/>".getBytes("UTF_32BE");
- // XML parser does not know what to do with UTF-32
parseXml(new BOMInputStream(createUtf32BeDataStream(data, true),
ByteOrderMark.UTF_32BE));
- // XML parser does not know what to do with UTF-32
- parseXml(createUtf32BeDataStream(data, true));
+ // XML parser does not know what to do with UTF-32, so we warp the
input stream with a XmlStreamReader
+ parseXml(new XmlStreamReader(createUtf32BeDataStream(data, true)));
}
- @Ignore
@Test
public void testReadXmlWithBOMUtf32Le() throws Exception {
Assume.assumeTrue(Charset.isSupported("UTF_32LE"));
byte[] data = "<?xml version=\"1.0\"
encoding=\"UTF-32LE\"?><X/>".getBytes("UTF_32LE");
- // XML parser does not know what to do with UTF-32
parseXml(new BOMInputStream(createUtf32LeDataStream(data, true),
ByteOrderMark.UTF_32LE));
- // XML parser does not know what to do with UTF-32
- parseXml(createUtf32LeDataStream(data, true));
+ // XML parser does not know what to do with UTF-32, so we warp the
input stream with a XmlStreamReader
+ parseXml(new XmlStreamReader(createUtf32LeDataStream(data, true)));
}
@Test