CVS Update: xmlpull-api-v1/src/java/tests/org/xmlpull/v1/tests
Aleksander Andrzej Slominski <[email protected]> Sat, 22 Apr 2006 18:27:51 -0400 (EDT)
| Newsgroups | gmane.text.xml.xmlpull.devel |
|---|---|
| Message-ID | <[email protected]> |
aslom 06/04/22 18:27:51
Modified: src/java/tests/org/xmlpull/v1/tests TestSerializeWithNs.java
Log:
checking for case when attribute namespace could eb interpreted to be default ("")
Revision Changes Path
1.21 +40 -4 xmlpull-api-v1/src/java/tests/org/xmlpull/v1/tests/TestSerializeWithNs.java
Index: TestSerializeWithNs.java
===================================================================
RCS file: /l/extreme/cvspub/xmlpull-api-v1/src/java/tests/org/xmlpull/v1/tests/TestSerializeWithNs.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -t -w -r1.20 -r1.21
--- TestSerializeWithNs.java 28 Feb 2005 20:18:30 -0000 1.20
+++ TestSerializeWithNs.java 22 Apr 2006 22:27:51 -0000 1.21
@@ -669,6 +669,42 @@
testSetPrefix(null);
}
+ public void testAttrPrefix(String prefix, boolean extraPrefix) throws Exception {
+ XmlSerializer ser = factory.newSerializer();
+ StringWriter sw = new StringWriter();
+ ser.setOutput(sw);
+ final String NS = "http://example.com/test";
+ ser.setPrefix(prefix, NS);
+ if(extraPrefix) ser.setPrefix("p1", NS);
+ ser.startTag(NS, "foo");
+ ser.attribute(NS, "attr", "aar");
+ ser.endDocument();
+
+ String serialized = sw.toString();
+ //System.out.println(getClass()+" sw="+sw);
+ xpp.setInput(new StringReader(serialized));
+
+ checkParserStateNs(xpp, 0, XmlPullParser.START_DOCUMENT, null, 0, null, null, null, false, -1);
+ xpp.next();
+ String expectedPrefix = (prefix != null && prefix.length() == 0) ? null : prefix;
+ if(extraPrefix) expectedPrefix = "p1";
+ int nsCount = 1;
+ if(extraPrefix) ++nsCount;
+ if(expectedPrefix == null) ++nsCount;
+ checkParserStateNs(xpp, 1, XmlPullParser.START_TAG, expectedPrefix, nsCount, NS, "foo", null, xpp.isEmptyElementTag() /*empty*/, 1);
+ checkAttribNs(xpp, 0, NS, "attr", "aar");
+ }
+
+ public void testAttrPrefix() throws Exception {
+ testAttrPrefix("ns", false);
+ testAttrPrefix("", false);
+ testAttrPrefix(null, false);
+ testAttrPrefix("ns", true);
+ testAttrPrefix("", true);
+ testAttrPrefix(null, true);
+ }
+
+
/** setPrefix check that prefix is not duplicated ... */
public void testSetPrefixAdv() throws Exception {
//TODO check redeclaring defult namespace
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/