Examples of StAXStreamOutputter


Examples of org.jdom2.output.StAXStreamOutputter

    public void test_HighSurrogateAttPair() throws JDOMException, IOException, XMLStreamException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root att=\"&#x10000; &#x10000;\" />"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos, "ISO-8859-1");
      outputter.output(doc, xsw);
      String xml = baos.toString();
      assertEquals("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + format.getLineSeparator() +
                   "<root att=\"&#xd800;&#xdc00; &#xd800;&#xdc00;\"/>" + format.getLineSeparator(), xml);
    }
View Full Code Here

Examples of org.jdom2.output.StAXStreamOutputter

    public void test_HighSurrogateAttPairDecimal() throws JDOMException, IOException, XMLStreamException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root att=\"&#x10000; &#65536;\" />"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos, "ISO-8859-1");
      outputter.output(doc, xsw);
      String xml = baos.toString();
      assertEquals("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + format.getLineSeparator() +
                   "<root att=\"&#xd800;&#xdc00; &#xd800;&#xdc00;\"/>" + format.getLineSeparator(), xml);
    }
View Full Code Here

Examples of org.jdom2.output.StAXStreamOutputter

    public void test_RawSurrogatePair() throws JDOMException, IOException, XMLStreamException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root>\uD800\uDC00</root>"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos, "ISO-8859-1");
      outputter.output(doc, xsw);
      String xml = baos.toString();
      assertEquals("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + format.getLineSeparator() +
                   "<root>&#xd800;&#xdc00;</root>" + format.getLineSeparator(), xml);
    }
View Full Code Here

Examples of org.jdom2.output.StAXStreamOutputter

    public void test_RawSurrogatePairUTF8() throws JDOMException, IOException, XMLStreamException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root>\uD800\uDC00</root>"));
      Format format = Format.getCompactFormat().setEncoding("UTF-8");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      StringWriter baos = new StringWriter();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos);
      outputter.output(doc, xsw);
      String xml = baos.toString();
      assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + format.getLineSeparator() +
                   "<root>\uD800\uDC00</root>" + format.getLineSeparator(), xml);
    }
View Full Code Here

Examples of org.jdom2.output.StAXStreamOutputter

      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root></root>"));
      Text t = new UncheckedJDOMFactory().text("\uD800\uDBFF");
      doc.getRootElement().setContent(t);
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos);
      try {
        outputter.output(doc, xsw);
        fail("Illegal surrogate pair output should have thrown an exception");
      }
      catch (XMLStreamException e) {
        // do nothing
      } catch (Exception e) {
View Full Code Here

Examples of org.jdom2.output.StAXStreamOutputter

    }
   
   
  @Test
  public void testStAXStreamOutputter() {
    StAXStreamOutputter out = new StAXStreamOutputter();
    TestFormat.checkEquals(out.getFormat(), Format.getRawFormat());
  }
View Full Code Here

Examples of org.jdom2.output.StAXStreamOutputter

  @Test
  public void testStAXStreamOutputterFormat() {
    Format mine = Format.getCompactFormat();
    mine.setEncoding("US-ASCII");
    StAXStreamOutputter out = new StAXStreamOutputter(mine);
    TestFormat.checkEquals(mine, out.getFormat());
  }
View Full Code Here

Examples of org.jdom2.output.StAXStreamOutputter

  public void testStAXStreamOutputterXMLOutputProcessor() {
    StAXStreamProcessor xoutp = new AbstractStAXStreamProcessor() {
      // nothing;
    };
    // double-constrcut it.
    StAXStreamOutputter out = new StAXStreamOutputter(xoutp);
    TestFormat.checkEquals(Format.getRawFormat(), out.getFormat());
    assertTrue(xoutp == out.getStAXStream());
  }
View Full Code Here

Examples of org.jdom2.output.StAXStreamOutputter

  @Test
  public void testFormat() {
    Format mine = Format.getCompactFormat();
    mine.setEncoding("US-ASCII");
    // double-constcut it.
    StAXStreamOutputter out = new StAXStreamOutputter();
    TestFormat.checkEquals(Format.getRawFormat(), out.getFormat());
    out.setFormat(mine);
    TestFormat.checkEquals(mine, out.getFormat());
  }
View Full Code Here

Examples of org.jdom2.output.StAXStreamOutputter

  public void testStAXStreamOutputProcessor() {
    StAXStreamProcessor xoutp = new AbstractStAXStreamProcessor() {
      // nothing;
    };
    // double-constcut it.
    StAXStreamOutputter out = new StAXStreamOutputter();
    StAXStreamProcessor xop = out.getStAXStream();
    out.setStAXStreamProcessor(xoutp);
    assertTrue(xoutp != xop);
    assertTrue(xoutp == out.getStAXStream());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.