1
1
/*
2
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
42
42
43
43
/*
44
44
* @test
45
- * @bug 6347190 8139584
45
+ * @bug 6347190 8139584 8216408
46
46
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
47
47
* @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.XMLStreamWriterTest
48
48
* @run testng/othervm stream.XMLStreamWriterTest.XMLStreamWriterTest
49
- * @summary Test StAX Writer won't insert comment into element inside .
49
+ * @summary Tests XMLStreamWriter .
50
50
*/
51
51
@ Listeners ({jaxp .library .BasePolicy .class })
52
52
public class XMLStreamWriterTest {
@@ -94,12 +94,14 @@ public void testCreateStartDocument_DOMWriter()
94
94
}
95
95
96
96
/**
97
- * Test of main method, of class TestXMLStreamWriter .
97
+ * Verifies that the StAX Writer won't insert comment into the element tag .
98
98
*/
99
99
@ Test
100
100
public void testWriteComment () {
101
101
try {
102
- String xml = "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?><a:html href=\" http://java.sun.com\" ><!--This is comment-->java.sun.com</a:html>" ;
102
+ String xml = "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>"
103
+ + "<a:html href=\" http://java.sun.com\" >"
104
+ + "<!--This is comment-->java.sun.com</a:html>" ;
103
105
XMLOutputFactory f = XMLOutputFactory .newInstance ();
104
106
// f.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES,
105
107
// Boolean.TRUE);
@@ -122,4 +124,18 @@ public void testWriteComment() {
122
124
}
123
125
}
124
126
127
+ /**
128
+ * @bug 8216408
129
+ * Verifies that setDefaultNamespace accepts null.
130
+ *
131
+ * @throws Exception
132
+ */
133
+ @ Test
134
+ public void testSetDefaultNamespace () throws Exception {
135
+ XMLOutputFactory f = XMLOutputFactory .newFactory ();
136
+ f .setProperty (XMLOutputFactory .IS_REPAIRING_NAMESPACES , true );
137
+ StringWriter sw = new StringWriter ();
138
+ XMLStreamWriter xsw = f .createXMLStreamWriter (sw );
139
+ xsw .setDefaultNamespace (null );
140
+ }
125
141
}
0 commit comments