Package nu.xom

Examples of nu.xom.ProcessingInstruction


    }

   
    public void testCanonicalizeProcessingInstruction() throws IOException {
    
        ProcessingInstruction pi = new ProcessingInstruction("target", "value \n value");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(pi);
        }
View Full Code Here


   
    private ProcessingInstruction pi;
   
   
    protected void setUp() {
        pi = new ProcessingInstruction("test", "test")
    }
View Full Code Here

    }

   
    public void testToStringWithLineFeed() {
       
        ProcessingInstruction p
          = new ProcessingInstruction("test", "content\ncontent");
        assertEquals(
          "[nu.xom.ProcessingInstruction: target=\"test\"; data=\"content\\ncontent\"]",
          p.toString()
        );         
       
    }
View Full Code Here

    }
   
   
    public void testToStringWithLotsOfData() {
       
        ProcessingInstruction p
          = new ProcessingInstruction("target",
          "content content 012345678901234567890123456789012345678901234567890123456789");
        String s = p.toString();
        assertTrue(s.endsWith("...\"]"));
       
    }
View Full Code Here

        assertEquals("test", pi.getValue());
        assertEquals("test", pi.getTarget());

        try {
          new ProcessingInstruction("test:test", "test");
          fail("Processing instruction targets cannot contain colons");
        }
        catch (IllegalTargetException success) {
            assertNotNull(success.getMessage());
            assertEquals("test:test", success.getData());
        }
       
        try {
          new ProcessingInstruction("", "test");
          fail("Processing instruction targets cannot be empty");
        }
        catch (IllegalTargetException success) {
            assertNotNull(success.getMessage());
            assertEquals("", success.getData());
        }
       
        try {
           new ProcessingInstruction(null, "test");
           fail("Processing instruction targets cannot be empty");
        }
        catch (IllegalTargetException success) {
            assertNotNull(success.getMessage());
            assertNull(success.getData());
        }
       
        try {
           new ProcessingInstruction("12345", "test");
           fail("Processing instruction targets must be NCNames");
        }
        catch (IllegalTargetException success) {
            assertEquals("12345", success.getData());           
        }
       
        // test empty data allowed
        pi = new ProcessingInstruction("test", "");
        assertEquals("", pi.getValue());
        assertEquals("<?test?>", pi.toXML());

    }
View Full Code Here

    }   
   
   
    public void testCopyConstructor() {
       
        ProcessingInstruction instruction1 = new ProcessingInstruction("target", "data");  
        ProcessingInstruction instruction2 = new ProcessingInstruction(instruction1);
       
        assertEquals(instruction1.getTarget(), instruction2.getTarget());
        assertEquals(instruction1.getValue(), instruction2.getValue());
        assertEquals(instruction1.toXML(), instruction2.toXML());
          
    }
View Full Code Here

    }


    public void testEquals() {
       
        ProcessingInstruction pi1
          = new ProcessingInstruction("test", "afaf");
        ProcessingInstruction pi2
          = new ProcessingInstruction("test", "afaf");
        ProcessingInstruction pi3
          = new ProcessingInstruction("tegggst", "afaf");
        ProcessingInstruction pi4
          = new ProcessingInstruction("test", "1234");

        assertEquals(pi1, pi1);
        assertEquals(pi1.hashCode(), pi1.hashCode());
        assertTrue(!pi1.equals(pi2));
        assertTrue(!pi1.equals(pi3));
View Full Code Here

   
    public void testCopy() {
       
        Element test = new Element("test");
        test.appendChild(pi);
        ProcessingInstruction c2 = (ProcessingInstruction) pi.copy();

        assertEquals(pi, c2);
        assertEquals(pi.getValue(), c2.getValue());
        assertTrue(!pi.equals(c2));
        assertNull(c2.getParent());
       
    }
View Full Code Here

    // since character and entity references aren't
    // recognized in comment data
    public void testCarriageReturnInProcessingInstructionData() {
       
        try {
            new ProcessingInstruction("target", "data\rdata");
            fail("Allowed carriage return in processing instruction data");
        }
        catch (IllegalDataException success) {
            assertEquals("data\rdata", success.getData());
            assertNotNull(success.getMessage());  
View Full Code Here

       
    }

   
    public void testAllowReservedCharactersInData() {
        ProcessingInstruction pi = new ProcessingInstruction("target", "<test>&amp;&greater;");
        String xml = pi.toXML();
        assertEquals("<?target <test>&amp;&greater;?>", xml)
    }
View Full Code Here

TOP

Related Classes of nu.xom.ProcessingInstruction

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.