use of javax.xml.stream.XMLInputFactory in project webservices-axiom by apache.
the class TestGetAttributeNamespaceWithNoPrefix method runTest.
protected void runTest() throws Throwable {
XMLInputFactory factory = staxImpl.newNormalizedXMLInputFactory();
XMLStreamReader reader = factory.createXMLStreamReader(new StringReader("<root attr=\"test\"><child xmlns=\"urn:ns\" attr=\"test\"/></root>"));
int eventType;
while ((eventType = reader.next()) != XMLStreamReader.END_DOCUMENT) {
if (eventType == XMLStreamReader.START_ELEMENT) {
for (int i = 0; i < reader.getAttributeCount(); i++) {
assertNull(reader.getAttributeNamespace(i));
}
}
}
}
use of javax.xml.stream.XMLInputFactory in project webservices-axiom by apache.
the class TestGetEncoding method runTest.
protected void runTest() throws Throwable {
XMLInputFactory factory = staxImpl.newNormalizedXMLInputFactory();
XMLStreamReader reader = factory.createXMLStreamReader(new ByteArrayInputStream("<?xml version='1.0' encoding='iso-8859-15'?><root/>".getBytes("iso-8859-15")));
assertEquals("iso-8859-15", reader.getEncoding());
reader.next();
try {
reader.getEncoding();
fail("Expected IllegalStateException");
} catch (IllegalStateException ex) {
// Expected
}
reader.close();
}
use of javax.xml.stream.XMLInputFactory in project webservices-axiom by apache.
the class TestGetEncodingExternal method runTest.
protected void runTest() throws Throwable {
XMLInputFactory factory = staxImpl.newNormalizedXMLInputFactory();
XMLStreamReader reader = factory.createXMLStreamReader(new ByteArrayInputStream("<root/>".getBytes("ISO-8859-1")), "ISO-8859-1");
assertEquals("ISO-8859-1", reader.getEncoding());
}
use of javax.xml.stream.XMLInputFactory in project webservices-axiom by apache.
the class TestGetEncodingFromDetection method runTest.
protected void runTest() throws Throwable {
XMLInputFactory factory = staxImpl.newNormalizedXMLInputFactory();
XMLStreamReader reader = factory.createXMLStreamReader(new ByteArrayInputStream("<?xml version=\"1.0\"?><root/>".getBytes(javaEncoding)));
String actualEncoding = reader.getEncoding();
assertTrue("Expected one of " + xmlEncodings + ", but got " + actualEncoding, xmlEncodings.contains(actualEncoding));
}
use of javax.xml.stream.XMLInputFactory in project webservices-axiom by apache.
the class TestGetNamespaceURIWithNullNamespace method runTest.
protected void runTest() throws Throwable {
XMLInputFactory factory = staxImpl.newNormalizedXMLInputFactory();
XMLStreamReader reader = factory.createXMLStreamReader(new StringReader("<root><child xmlns=\"\"/></root>"));
int eventType;
while ((eventType = reader.next()) != XMLStreamReader.END_DOCUMENT) {
if (eventType == XMLStreamReader.START_ELEMENT) {
assertNull(reader.getNamespaceURI());
}
}
}
Aggregations