< prev index next >
test/jaxp/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/XMLStreamWriterTest.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -40,15 +40,15 @@
import org.testng.annotations.Test;
import org.w3c.dom.Document;
/*
* @test
- * @bug 6347190 8139584
+ * @bug 6347190 8139584 8216408
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
* @run testng/othervm -DrunSecMngr=true stream.XMLStreamWriterTest.XMLStreamWriterTest
* @run testng/othervm stream.XMLStreamWriterTest.XMLStreamWriterTest
- * @summary Test StAX Writer won't insert comment into element inside.
+ * @summary Tests XMLStreamWriter.
*/
@Listeners({jaxp.library.BasePolicy.class})
public class XMLStreamWriterTest {
/**
* @bug 8139584
@@ -92,16 +92,18 @@
Assert.assertEquals(doc.getXmlVersion(), "1.0");
Assert.assertTrue(doc.getXmlStandalone());
}
/**
- * Test of main method, of class TestXMLStreamWriter.
+ * Verifies that the StAX Writer won't insert comment into the element tag.
*/
@Test
public void testWriteComment() {
try {
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><a:html href=\"http://java.sun.com\"><!--This is comment-->java.sun.com</a:html>";
+ String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ + "<a:html href=\"http://java.sun.com\">"
+ + "<!--This is comment-->java.sun.com</a:html>";
XMLOutputFactory f = XMLOutputFactory.newInstance();
// f.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES,
// Boolean.TRUE);
StringWriter sw = new StringWriter();
XMLStreamWriter writer = f.createXMLStreamWriter(sw);
@@ -120,6 +122,20 @@
} catch (Exception ex) {
Assert.fail("Exception: " + ex.getMessage());
}
}
+ /**
+ * @bug 8216408
+ * Verifies that setDefaultNamespace accepts null.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testSetDefaultNamespace() throws Exception {
+ XMLOutputFactory f = XMLOutputFactory.newFactory();
+ f.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
+ StringWriter sw = new StringWriter();
+ XMLStreamWriter xsw = f.createXMLStreamWriter(sw);
+ xsw.setDefaultNamespace(null);
+ }
}
< prev index next >