Package nu.xom

Examples of nu.xom.Text


       
        String data = "<root><?target data?></root>";  
        Builder builder = new Builder(new NodeFactory() {
           
            public Nodes makeProcessingInstruction(String target, String data) {
                return new Nodes(new Text(data));  
            }
           
        });
        Document doc = builder.build(data, "http://www.example.org/");
        Element root = doc.getRootElement();
View Full Code Here


        super(name);
    }

   
    public void testConstructor() {      
        Text a1 = new Text("test");
        assertEquals("test", a1.getValue());
    }
View Full Code Here

          " <![CDATA[ CDATA end: ]]>"
          " &amp; "
          " ampersands & &&& &name; " 
        };

        Text t = new Text("name");
       
        // Things that shouldn't cause an exception
        for (int i = 0; i < legal.length; i++) {
            t.setValue(legal[i]);  
            assertEquals(legal[i], t.getValue());
        }
       
        t.setValue(null);
        assertEquals("", t.getValue());
       
        try {
            t.setValue("test \u0000 test ");
            fail("Should raise an IllegalCharacterDataException");
        }
        catch (IllegalCharacterDataException success) {
            assertEquals("test \u0000 test ", success.getData());
            assertNotNull(success.getMessage());
View Full Code Here

          " quotes \" \" quotes",
          " single \'\' quotes",
          " both double and single \"\'\"\' quotes" 
        };

        Text t = new Text("name");
       
        // Things that shouldn't cause an exception
        for (int i = 0; i < easyCases.length; i++) {
            t.setValue(easyCases[i]);  
            assertEquals(easyCases[i], t.toXML());
        }
       
        t.setValue("<>");
        assertEquals("&lt;&gt;", t.toXML());
        t.setValue("&amp;");
        assertEquals("&amp;amp;", t.toXML());
        t.setValue("]]>");
        assertEquals("]]&gt;", t.toXML());
        t.setValue("\r");
        assertEquals("&#x0D;", t.toXML());
       
    }
View Full Code Here

   
    public void testPunctuationCharactersInToXML() {
       
        String data = "=,.!@#$%^*()_-\"'[]{}+/?;:`|\\";
        Text t = new Text(data);
        assertEquals(data, t.toXML());
       
    }
View Full Code Here

    }

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

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

    }

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

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

    }
View Full Code Here

    }


    public void testCopyisNotACDATASection() {
       
        Text c1 = new Text("test");
        Node c2 = c1.copy();
        assertEquals(Text.class, c2.getClass());

    }
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  ";
        Text c = new Text(goodString);
        assertEquals(goodString, c.getValue());

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

        // Two high-halves
        try {
            new Text("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 Text("test: \uD8F5  ");
            fail("Should raise an IllegalCharacterDataException");
        }
        catch (IllegalCharacterDataException success) {
            assertNotNull(success.getMessage());
            assertEquals("test: \uD8F5  ", success.getData());
        }

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

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

            for (char low = '\uDC00'; low <= '\uDFFF'; low++) {
                sb.setLength(0);
                sb.append(high);
                sb.append(low);
                String s = sb.toString();
                Text t = new Text(s);
                assertEquals(s, t.getValue());
            }
        }
       
    }
View Full Code Here

TOP

Related Classes of nu.xom.Text

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.