Package nu.xom

Examples of nu.xom.Serializer


   
    public void testNFCInAttribute() throws IOException {
       
        root.addAttribute(new Attribute("c\u0327", "c\u0327")); // c with combining cedilla
        Serializer serializer = new Serializer(out);
        serializer.setUnicodeNormalizationFormC(true);
        serializer.write(doc);
        serializer.flush();
        out.close();
        String result = new String(out.toByteArray(), "UTF-8");
        assertEquals(
          "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
          + "<root \u00E7=\"\u00E7\"/>\r\n",
View Full Code Here


   
    public void testNFCInElementName() throws IOException {
       
        Element root = new Element("c\u0327"); // c with combining cedilla
        Document doc = new Document(root);
        Serializer serializer = new Serializer(out);
        serializer.setUnicodeNormalizationFormC(true);
        serializer.write(doc);
        serializer.flush();
        out.close();
        String result = new String(out.toByteArray(), "UTF-8");
        assertEquals(
          "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
          + "<\u00E7/>\r\n",
View Full Code Here

    public void testNFCInComment() throws IOException {
       
        Element root = new Element("a");
        Document doc = new Document(root);
        doc.insertChild(new Comment("c\u0327hat"), 0); // c with combining cedilla
        Serializer serializer = new Serializer(out);
        serializer.setUnicodeNormalizationFormC(true);
        serializer.write(doc);
        serializer.flush();
        out.close();
        String result = new String(out.toByteArray(), "UTF-8");
        assertEquals(
          "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
          + "<!--\u00E7hat-->\r\n"
View Full Code Here

   
    public void testNFCInProcessingInstruction() throws IOException {
       
        doc.appendChild(new ProcessingInstruction("c\u0327hat", "c\u0327hat"));
        Serializer serializer = new Serializer(out);
        serializer.setUnicodeNormalizationFormC(true);
        serializer.write(doc);
        serializer.flush();
        out.close();
        String result = new String(out.toByteArray(), "UTF-8");
        assertEquals(
          "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
          + "<root/>\r\n"
View Full Code Here

   
    public void testNFCInElementContentWithNonUnicodeEncoding()
      throws IOException {
       
        root.appendChild("c\u0327"); // c with combining cedilla
        Serializer serializer = new Serializer(out, "ISO-8859-5");
        serializer.setUnicodeNormalizationFormC(true);
        serializer.write(doc);
        serializer.flush();
        out.close();
        String result = new String(out.toByteArray(), "ISO-8859-5");
        assertEquals(
          "<?xml version=\"1.0\" encoding=\"ISO-8859-5\"?>\r\n"
          + "<root>&#xE7;</root>\r\n",
View Full Code Here

   
    public void testNFCFollowingEntityReference()
      throws IOException {
       
        root.appendChild("<\u0338"); // < followed by not
        Serializer serializer = new Serializer(out);
        serializer.setUnicodeNormalizationFormC(true);
        serializer.write(doc);
        serializer.flush();
        out.close();
        String result = new String(out.toByteArray(), "UTF-8");
        assertEquals(
          "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
          + "<root>\u226E</root>\r\n",
View Full Code Here

   
    public void testNFCWithSetOutputStream()
      throws IOException {
       
        root.appendChild("c\u0327"); // c with combining cedilla
        Serializer serializer = new Serializer(new ByteArrayOutputStream(), "ISO-8859-5");
        serializer.setUnicodeNormalizationFormC(true);
        serializer.write(doc);
        serializer.setOutputStream(out);
        serializer.write(doc);         
        serializer.flush();
        out.close();
        String result = new String(out.toByteArray(), "ISO-8859-5");
        assertEquals(
          "<?xml version=\"1.0\" encoding=\"ISO-8859-5\"?>\r\n"
          + "<root>&#xE7;</root>\r\n",
View Full Code Here

   
    public void testNFCWithKoreanCharacter()
      throws IOException {
       
        root.appendChild("\u1111\u1171\u11B6"); // see p. 88 of Unicode 4.0 book
        Serializer serializer = new Serializer(new ByteArrayOutputStream());
        serializer.setUnicodeNormalizationFormC(true);
        serializer.write(doc);
        serializer.setOutputStream(out);
        serializer.write(doc);         
        serializer.flush();
        out.close();
        String result = new String(out.toByteArray(), "UTF-8");
        assertEquals(
          "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
          + "<root>\uD4DB</root>\r\n",
View Full Code Here

   
   
    public void testNullOutputStream() {
       
        try {
            new Serializer(null);
            fail("Allowed null output stream");  
        }  
        catch (NullPointerException success) {
            assertNotNull(success.getMessage());  
        }
View Full Code Here

   
    public void testNullOutputStreamWithEncoding()
      throws UnsupportedEncodingException {
       
        try {
            new Serializer(null, "UTF-8");
            fail("Allowed null output stream");  
        }  
        catch (NullPointerException success) {
            assertNotNull(success.getMessage());  
        }
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.