Package nu.xom

Examples of nu.xom.Comment


    }

   
    public void testToString() {
       
        Comment c1 = new Comment("content");
        assertEquals("[nu.xom.Comment: content]", c1.toString());         
       
        c1.setValue("012345678901234567890123456789012345678901234567890123456789");
        assertEquals(
          "[nu.xom.Comment: 01234567890123456789012345678901234...]",
          c1.toString()
        );
          
    }
View Full Code Here


    }
   
   
    public void testToStringWithLineFeed() {
       
        Comment c = new Comment("content\ncontent");
        assertEquals("[nu.xom.Comment: content\\ncontent]", c.toString());        
       
    }
View Full Code Here

    }
   
   
    public void testToStringWithLotsOfData() {
       
        Comment c
          = new Comment("content content 012345678901234567890123456789012345678901234567890123456789");
        String s = c.toString();
        assertTrue(s.length() < 72);
       
    }
View Full Code Here

    }


    public void testToXML() {
       
        Comment c1 = new Comment("content");
        assertEquals("<!--content-->", c1.toXML());         
       
        c1.setValue(" 012345678901234567890123456789012345678901234567890123456789 ");
        assertEquals(
          "<!-- 012345678901234567890123456789012345678901234567890123456789 -->",
          c1.toXML()
        );
          
    }
View Full Code Here

    // This is a problem because it cannot be serialized
    // since character and entity references aren't
    // recognized in comment data
    public void testCarriageReturnInCommentData() {
        try {
            new Comment("data\rdata");
            fail("Allowed carriage return in comment");
        }
        catch (IllegalDataException success) {
            assertEquals("data\rdata", success.getData());
            assertNotNull(success.getMessage());  
View Full Code Here

    }
   
   
    public void testSetter() {

        Comment c1 = new Comment("test");
        c1.setValue("legal");
        assertEquals("legal", c1.getValue());
       
        try {
          c1.setValue("test -- test");
          fail("Should raise an IllegalDataException");
        }
        catch (IllegalDataException success) {
            assertEquals("test -- test", success.getData());
            assertNotNull(success.getMessage());  
        }
       
        try {
          c1.setValue("test-");
          fail("Should raise an IllegalDataException");
        }
        catch (IllegalDataException success) {
            assertEquals("test-", success.getData());
            assertNotNull(success.getMessage());  
        }  

        c1.setValue(null);
        assertEquals("", c1.getValue());

     }
View Full Code Here

     }


    public void testEquals() {
       
        Comment c1 = new Comment("test");
        Comment c2 = new Comment("test");
        Comment c3 = new Comment("skjlchsakdjh");

        assertEquals(c1, c1);
        assertEquals(c1.hashCode(), c1.hashCode());
        assertTrue(!c1.equals(c2));
        assertTrue(!c1.equals(c3));
View Full Code Here

    }

   
    public void testCopy() {
       
        Comment c1 = new Comment("test");
        Comment c2 = (Comment) c1.copy();

        assertEquals(c1.getValue(), c2.getValue());
        assertTrue(!c1.equals(c2));
        assertNull(c2.getParent());

    }
View Full Code Here

    // Check passing in a string with broken surrogate pairs
    // and with correct surrogate pairs
    public void testSurrogates() {

        String goodString = "test: \uD8F5\uDF80  ";
        Comment c = new Comment(goodString);
        assertEquals(goodString, c.getValue());

        // Two high-halves
        try {
          new Comment("test: \uD8F5\uDBF0  ");
          fail("Should raise an IllegalCharacterDataException");
        }
        catch (IllegalCharacterDataException success) {
            assertEquals("test: \uD8F5\uDBF0  ", success.getData());
            assertNotNull(success.getMessage());  
        }  

        // Two high-halves
        try {
          new Comment("test: \uD8F5\uD8F5  ");
          fail("Should raise an IllegalCharacterDataException");
        }
        catch (IllegalCharacterDataException success) {
            assertEquals("test: \uD8F5\uD8F5  ", success.getData());
            assertNotNull(success.getMessage());  
        }  

        // One high-half
        try {
           new Comment("test: \uD8F5  ");
           fail("Should raise an IllegalCharacterDataException");
        }
        catch (IllegalCharacterDataException success) {
            assertEquals("test: \uD8F5  ", success.getData());
            assertNotNull(success.getMessage());  
        }  

        // One low half
        try {
            new Comment("test: \uDF80  ");
            fail("Should raise an IllegalCharacterDataException");
         }
        catch (IllegalCharacterDataException success) {
            assertEquals("test: \uDF80  ", success.getData());
            assertNotNull(success.getMessage());  
        }  

        // Low half before high half
        try {
            new Comment("test: \uDCF5\uD8F5  ");
            fail("Should raise an IllegalCharacterDataException");
        }
        catch (IllegalCharacterDataException success) {
            assertEquals("test: \uDCF5\uD8F5  ", success.getData());
            assertNotNull(success.getMessage());  
View Full Code Here

    }

   
    public void testLeafNode() {

        Comment c1 = new Comment("data");
        assertEquals(0, c1.getChildCount());
        try {
            c1.getChild(0);
            fail("Didn't throw IndexOutofBoundsException");
        }
        catch (IndexOutOfBoundsException success) {
            assertNotNull(success.getMessage());
        }
       
        assertNull(c1.getParent());

        Element element = new Element("test");
        element.appendChild(c1);
        assertEquals(element, c1.getParent());
        assertEquals(element.getChild(0), c1);

        element.removeChild(c1);
        assertTrue(element.getChildCount() == 0);
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.