< prev index next >

test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/AttributeEscapeTest.java

Print this page




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package stream.XMLStreamWriterTest;
  25 
  26 import java.io.IOException;
  27 import java.io.StringReader;
  28 import java.io.StringWriter;
  29 
  30 import javax.xml.parsers.DocumentBuilderFactory;
  31 import javax.xml.parsers.ParserConfigurationException;
  32 import javax.xml.stream.XMLOutputFactory;
  33 import javax.xml.stream.XMLStreamException;
  34 import javax.xml.stream.XMLStreamWriter;
  35 
  36 import org.testng.Assert;

  37 import org.testng.annotations.Test;
  38 import org.xml.sax.InputSource;
  39 import org.xml.sax.SAXException;
  40 
  41 /*
  42  * @summary Test XMLStreamWriter shall escape the illegal characters.
  43  */

  44 public class AttributeEscapeTest {
  45 
  46     /**
  47      * XML content for testing the escaping of <, >, &, ', ".
  48      */
  49     private static final String XML_CONTENT = "Testing escaping: lt=<, gt=>, amp=&, apos=', dquote=\"";
  50 
  51     @Test
  52     public void testCR6420953() {
  53 
  54         try {
  55             XMLOutputFactory xof = XMLOutputFactory.newInstance();
  56             StringWriter sw = new StringWriter();
  57             XMLStreamWriter w = xof.createXMLStreamWriter(sw);
  58 
  59             w.writeStartDocument();
  60             w.writeStartElement("element");
  61 
  62             w.writeDefaultNamespace(XML_CONTENT);
  63             w.writeNamespace("prefix", XML_CONTENT);




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package stream.XMLStreamWriterTest;
  25 
  26 import java.io.IOException;
  27 import java.io.StringReader;
  28 import java.io.StringWriter;
  29 
  30 import javax.xml.parsers.DocumentBuilderFactory;
  31 import javax.xml.parsers.ParserConfigurationException;
  32 import javax.xml.stream.XMLOutputFactory;
  33 import javax.xml.stream.XMLStreamException;
  34 import javax.xml.stream.XMLStreamWriter;
  35 
  36 import org.testng.Assert;
  37 import org.testng.annotations.Listeners;
  38 import org.testng.annotations.Test;
  39 import org.xml.sax.InputSource;
  40 import org.xml.sax.SAXException;
  41 
  42 /*
  43  * @summary Test XMLStreamWriter shall escape the illegal characters.
  44  */
  45 @Listeners({jaxp.library.BasePolicy.class})
  46 public class AttributeEscapeTest {
  47 
  48     /**
  49      * XML content for testing the escaping of <, >, &, ', ".
  50      */
  51     private static final String XML_CONTENT = "Testing escaping: lt=<, gt=>, amp=&, apos=', dquote=\"";
  52 
  53     @Test
  54     public void testCR6420953() {
  55 
  56         try {
  57             XMLOutputFactory xof = XMLOutputFactory.newInstance();
  58             StringWriter sw = new StringWriter();
  59             XMLStreamWriter w = xof.createXMLStreamWriter(sw);
  60 
  61             w.writeStartDocument();
  62             w.writeStartElement("element");
  63 
  64             w.writeDefaultNamespace(XML_CONTENT);
  65             w.writeNamespace("prefix", XML_CONTENT);


< prev index next >