Code example for Attributes2Impl

Methods: addAttributeisDeclaredisSpecifiedgetLengthgetLocalNamegetQNamegetTypegetURIgetValue

0
        // Special case with CDATA 
        attrs.setAttributes(new AttributesImpl(cdata));
        assertEquals(1, attrs.getLength());
        assertEquals(false, attrs.isDeclared(0));
        assertEquals(true, attrs.isSpecified(0));
         
        // null case 
        try { 
            attrs.setAttributes(null);
            fail("NullPointerException expected");
        } catch (NullPointerException e) {
            // Expected 
        } 
    } 
 
    @TestTargetNew( 
        level = TestLevel.COMPLETE, 
        method = "addAttribute", 
        args = { String.class, String.class, String.class, String.class,
                 String.class }
    ) 
    public void testAddAttribute() { 
        Attributes2Impl attrs = new Attributes2Impl();
         
        // Ordinary case 
        attrs.addAttribute("http://yet.another.uri", "doe", "john:doe",
                "string", "abc"); 
         
        assertEquals(1, attrs.getLength());
         
        assertEquals("http://yet.another.uri", attrs.getURI(0));
        assertEquals("doe", attrs.getLocalName(0));
        assertEquals("john:doe", attrs.getQName(0));
        assertEquals("string", attrs.getType(0));
        assertEquals("abc", attrs.getValue(0));
 
        assertEquals(true, attrs.isDeclared(0));
        assertEquals(true, attrs.isSpecified(0));
 
        // CDATA case 
        attrs.addAttribute("http://yet.another.uri", "doe", "jane:doe",
Contextual code suggestions in your IDE  Get Codota for Java