Package nu.xom

Examples of nu.xom.Serializer


   
    public void testPunctuationInAttributeValueNonUnicode()
      throws IOException, ParsingException

        root.addAttribute(new Attribute("test", "$()*+,="));
        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.write(doc);
        out.close();
        InputStream in = new ByteArrayInputStream(out.toByteArray());
        Document reparsed = parser.build(in);
        String result = reparsed.getRootElement().getAttributeValue("test");
        assertEquals("$()*+,=", result);
View Full Code Here


   
    public void testCRLFInAttributeValueWithIndenting()
      throws IOException, ParsingException

        root.addAttribute(new Attribute("test", "\r\n"));
        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.setIndent(2);
        serializer.write(doc);
        out.close();
        InputStream in = new ByteArrayInputStream(out.toByteArray());
        Document reparsed = parser.build(in);
        String result = reparsed.getRootElement().getAttributeValue("test");
        assertEquals("CRLF unnecessarily escaped", -1, result.indexOf('\r'));
View Full Code Here

    public void testCRLFInAttributeValueWithMaxLength()
      throws IOException, ParsingException {

        root.addAttribute(new Attribute("test", "\r\n"));

        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.setMaxLength(64);
        serializer.write(doc);
        out.close();
        InputStream in = new ByteArrayInputStream(out.toByteArray());
        Document reparsed = parser.build(in);
        String result = reparsed.getRootElement().getAttributeValue("test");
        assertEquals("CRLF unnecessarily escaped", " ", result);
View Full Code Here

   
    public void testCRInTextValueWithLineSeparator()
      throws IOException, ParsingException {

        root.appendChild("\r");
        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.setLineSeparator("\n");
        serializer.write(doc);
        out.close();
        InputStream in = new ByteArrayInputStream(out.toByteArray());
        Document reparsed = parser.build(in);
        String result = reparsed.getValue();
        assertEquals("\n", result);
View Full Code Here

   
    public void testCRLFInTextValueWithLineSeparator()
      throws IOException, ParsingException {  
       
        root.appendChild("test \r\n test");
        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.setLineSeparator("\n");
        serializer.write(doc);
        out.close();
        InputStream in = new ByteArrayInputStream(out.toByteArray());
        Document reparsed = parser.build(in);
        String result = reparsed.getValue();
        assertEquals("test \n test", result);
View Full Code Here

   
    public void testCRInTextWithIndenting()
      throws IOException, ParsingException
       
        root.appendChild("\r");
        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.setIndent(2);
        serializer.write(doc);
        out.close();
        InputStream in = new ByteArrayInputStream(out.toByteArray());
        Document reparsed = parser.build(in);
        String result = reparsed.getValue();
        assertEquals("Carriage return unnecessarily escaped",
View Full Code Here

   
    public void testCRInTextWithMaxLength()
      throws IOException, ParsingException {       

        root.appendChild("\r");
        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.setMaxLength(64);
        serializer.write(doc);
        out.close();
        InputStream in = new ByteArrayInputStream(out.toByteArray());
        Document reparsed = parser.build(in);
        String result = reparsed.getValue();
        assertEquals("Carriage return unnecessarily escaped", "\n", result);
View Full Code Here

   
    public void testTabInAttributeValueWithMaxLength()
      throws IOException, ParsingException
       
        root.addAttribute(new Attribute("test", "\t"));
        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.setMaxLength(64);
        serializer.write(doc);
        out.close();
        InputStream in = new ByteArrayInputStream(out.toByteArray());
        Document reparsed = parser.build(in);
        String result = reparsed.getRootElement().getAttributeValue("test");
        assertEquals("Tab not normalized to space", " ", result);
View Full Code Here

     */
    public void testTabInAttributeValueWithZeroMaxLength()
      throws IOException, ParsingException

        root.addAttribute(new Attribute("test", "\t"));
        Serializer serializer = new Serializer(out, "ISO-8859-1");
        serializer.setMaxLength(0);
        serializer.write(doc);
        out.close();
        InputStream in = new ByteArrayInputStream(out.toByteArray());
        Document reparsed = parser.build(in);
        String result = reparsed.getRootElement().getAttributeValue("test");
        assertEquals("Tab not normalized to space", "\t", result);
View Full Code Here

       
    }
   

    public void testSetMaxLength() {
        Serializer serializer = new Serializer(System.out);
       
        serializer.setMaxLength(72);
        assertEquals(72, serializer.getMaxLength());
        serializer.setMaxLength(720);
        assertEquals(720, serializer.getMaxLength());
        serializer.setMaxLength(1);
        assertEquals(1, serializer.getMaxLength());
        serializer.setMaxLength(0);
        assertEquals(0, serializer.getMaxLength());
        serializer.setMaxLength(-1);
        assertEquals(0, serializer.getMaxLength());
       
    }
View Full Code Here

TOP

Related Classes of nu.xom.Serializer

Copyright © 2018 www.massapicom. 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.