Package nu.xom

Examples of nu.xom.Comment


    }

   
    public void testGetDocument() {

        Comment c1 = new Comment("data");
        assertNull(c1.getDocument());
        Element root = new Element("root");
        root.appendChild(c1);
        assertNull(c1.getDocument());
        Document doc = new Document(root);
        assertEquals(doc, c1.getDocument());

    }
View Full Code Here


    }

   
    public void testAllowReservedCharactersInData() {
        Comment comment = new Comment("<test>&amp;&greater;");
        String xml = comment.toXML();
        assertEquals("<!--<test>&amp;&greater;-->", xml)
    }
View Full Code Here


    public void testForbidIllegalCharactersInComments() {
       
        try {
            new Comment(" \u0001 ");
            fail("Allowed C0 control in comment");
        }
        catch (IllegalCharacterDataException success) {
            assertEquals(" \u0001 ", success.getData());
            assertNotNull(success.getMessage());
View Full Code Here


    public void testForbidUnmatchedSurrogatesInComments() {
       
        try {
            new Comment(" \uD800 ");
            fail("Allowed unmatched high surrogate in comment");
        }
        catch (IllegalCharacterDataException success) {
            assertEquals(" \uD800 ", success.getData());
            assertNotNull(success.getMessage());
View Full Code Here

         
    }

   
    public void testCommentDataCanStartWithAHyphen() {
        Comment c = new Comment("- - ");
        assertEquals("- - ", c.getValue());
    }
View Full Code Here

       
        DocType type1 = new DocType("root");      
        doc.setDocType(type1);
        assertEquals(type1, doc.getDocType());
       
        doc.insertChild(new Comment("test"), 0);

        DocType type2 = new DocType("root", "http://www.example.com/");      
        doc.setDocType(type2);
        assertEquals(type2, doc.getDocType());
        assertEquals(1, doc.indexOf(type2));
View Full Code Here

   
    public void testInsertionAllowed() {
       
        Document doc = new Document(new Element("root"));
        Comment original = new Comment("original");
        doc.insertChild(original, 0);
       
        Element temp = new Element("temp");
        Comment c2 = new Comment("new comment");
        temp.appendChild(c2);
       
        try {
            doc.replaceChild(original, c2);
            fail("Missed multiple parent exception");
View Full Code Here

       
        Element oldRoot = new Element("oldRoot");
        Document doc = new Document(oldRoot);
       
        try {
            doc.replaceChild(oldRoot, new Comment("c"));
            fail("Replaced root with comment");
        }
        catch (WellformednessException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

    }

   
    public void testReplaceNonDocTypeWithDocTypeUsingReplaceChild() {
       
        Comment c = new Comment("Not a doctype");
        DocType newDocType = new DocType("new");
        doc.insertChild(c, 0);
        doc.replaceChild(c, newDocType);
        assertEquals(newDocType, doc.getDocType());
        assertNull(c.getParent());
        assertEquals(doc, newDocType.getParent());
       
    }
View Full Code Here

       
    }

   
    public void testDetach() {
        Comment comment
          = new Comment("This will be attached then detached");
        doc.appendChild(comment);
        assertEquals(doc, comment.getParent());
        comment.detach();
        assertNull(comment.getParent());
    }
View Full Code Here

TOP

Related Classes of nu.xom.Comment

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.