CVS Update: xmlpull-api-v1/src/java/tests/org/xmlpull/v1/tests
Aleksander Andrzej Slominski <[email protected]> Tue, 20 Jan 2004 12:49:19 -0500 (EST)
| Newsgroups | gmane.text.xml.xmlpull.devel |
|---|---|
| Message-ID | <[email protected]> |
aslom 04/01/20 12:49:19
Modified: src/java/tests/org/xmlpull/v1/tests TestSerialize.java
Log:
stronger serializer tests for case when char values < 32
Revision Changes Path
1.5 +35 -0 xmlpull-api-v1/src/java/tests/org/xmlpull/v1/tests/TestSerialize.java
Index: TestSerialize.java
===================================================================
RCS file: /l/extreme/cvspub/xmlpull-api-v1/src/java/tests/org/xmlpull/v1/tests/TestSerialize.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -t -w -r1.4 -r1.5
--- TestSerialize.java 12 Oct 2002 22:17:59 -0000 1.4
+++ TestSerialize.java 20 Jan 2004 17:49:19 -0000 1.5
@@ -210,5 +210,40 @@
}
+ public void testEscaping() throws Exception {
+ XmlSerializer ser = factory.newSerializer();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ser.setOutput(baos, "UTF-8");
+ ser.startDocument("UTF-8", null);
+ ser.startTag("", "foo");
+ String s = "test\u0008\t\r\n";
+ ser.attribute(null, "att", s);
+ ser.text(s);
+ ser.endTag("", "foo");
+ ser.endDocument();
+
+ //check taking input form input stream
+ //byte[] binput = "<foo>test</foo>".getBytes("UTF8");
+
+ byte[] binput = baos.toByteArray();
+ System.out.println(getClass()+" binput="+printable(new String(binput)));
+
+ xpp.setInput(new ByteArrayInputStream( binput ), "UTF-8" );
+ assertEquals("UTF-8", xpp.getInputEncoding());
+
+ //xpp.setInput(new StringReader( "<foo/>" ) );
+ checkParserState(xpp, 0, xpp.START_DOCUMENT, null, null, false, -1);
+ xpp.next();
+ checkParserState(xpp, 1, xpp.START_TAG, "foo", null, false /*empty*/, 1);
+ assertEquals(printable(s), printable(xpp.getAttributeValue(null, "att")));
+ xpp.next();
+ checkParserState(xpp, 1, xpp.TEXT, null, s, false, -1);
+ assertEquals(false, xpp.isWhitespace());
+ xpp.next();
+ checkParserState(xpp, 1, xpp.END_TAG, "foo", null, false, -1);
+ xpp.next();
+ checkParserState(xpp, 0, xpp.END_DOCUMENT, null, null, false, -1);
+ }
}
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/xmlpull-dev/
To unsubscribe from this group, send an email to:
[email protected]
Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/