public void test_XMLAttributes_add_get() { XMLAttributes attrs = new XMLAttributes(); assertTrue( attrs.getLength() == 0 ); assertEquals( true, attrs.isEmpty() ); attrs.add("xmlns", "http://foo.org/"); assertTrue( attrs.getLength() == 1 ); assertTrue( attrs.isEmpty() == false ); attrs.add("foo", "bar"); assertTrue( attrs.getLength() == 2 ); assertTrue( attrs.isEmpty() == false ); assertTrue( attrs.getIndex("xmlns") == 0 ); assertTrue( attrs.getIndex("foo" ) == 1 ); assertTrue( attrs.getIndex("bar" ) == -1 ); assertTrue( attrs.getValue("xmlns") == "http://foo.org/" ); assertTrue( attrs.getValue("foo" ) == "bar" ); assertTrue( attrs.getValue("bar" ) == "" ); assertTrue( attrs.getName(0) == "xmlns" ); assertTrue( attrs.getName(1) == "foo" ); assertTrue( attrs.getName(2) == "" ); }
public void test_XMLAttributes_assignment() { XMLAttributes att1 = new XMLAttributes(); att1.add("xmlns", "http://foo.org/"); assertTrue( att1.getLength() == 1 ); assertTrue( att1.isEmpty() == false ); assertTrue( att1.getIndex("xmlns") == 0 ); assertTrue( att1.getName(0) == "xmlns" ); assertTrue( att1.getValue("xmlns") == "http://foo.org/" ); XMLAttributes att2 = new XMLAttributes(); att2 = att1; assertTrue( att2.getLength() == 1 ); assertTrue( att2.isEmpty() == false ); assertTrue( att2.getIndex("xmlns") == 0 ); assertTrue( att2.getName(0) == "xmlns" ); assertTrue( att2.getValue("xmlns") == "http://foo.org/" ); att2 = null; att1 = null; }