Exemplo n.º 1
0
 public void test_XMLNode_namespace_set_clear()
 {
     XMLTriple triple = new  XMLTriple("test","","");
       XMLAttributes attr = new  XMLAttributes();
       XMLNode node = new XMLNode(triple,attr);
       XMLNamespaces ns = new  XMLNamespaces();
       assertTrue( node.getNamespacesLength() == 0 );
       assertTrue( node.isNamespacesEmpty() == true );
       ns.add( "http://test1.org/", "test1");
       ns.add( "http://test2.org/", "test2");
       ns.add( "http://test3.org/", "test3");
       ns.add( "http://test4.org/", "test4");
       ns.add( "http://test5.org/", "test5");
       node.setNamespaces(ns);
       assertTrue( node.getNamespacesLength() == 5 );
       assertTrue( node.isNamespacesEmpty() == false );
       assertTrue( (  "test1" != node.getNamespacePrefix(0) ) == false );
       assertTrue( (  "test2" != node.getNamespacePrefix(1) ) == false );
       assertTrue( (  "test3" != node.getNamespacePrefix(2) ) == false );
       assertTrue( (  "test4" != node.getNamespacePrefix(3) ) == false );
       assertTrue( (  "test5" != node.getNamespacePrefix(4) ) == false );
       assertTrue( (  "http://test1.org/" != node.getNamespaceURI(0) ) == false );
       assertTrue( (  "http://test2.org/" != node.getNamespaceURI(1) ) == false );
       assertTrue( (  "http://test3.org/" != node.getNamespaceURI(2) ) == false );
       assertTrue( (  "http://test4.org/" != node.getNamespaceURI(3) ) == false );
       assertTrue( (  "http://test5.org/" != node.getNamespaceURI(4) ) == false );
       node.clearNamespaces();
       assertTrue( node.getNamespacesLength() == 0 );
       assertTrue( node.isAttributesEmpty() != false );
       ns = null;
       node = null;
       triple = null;
       attr = null;
 }
Exemplo n.º 2
0
 public void test_XMLNode_namespace_get()
 {
     XMLTriple triple = new  XMLTriple("test","","");
       XMLAttributes attr = new  XMLAttributes();
       XMLNode node = new XMLNode(triple,attr);
       node.addNamespace( "http://test1.org/", "test1");
       node.addNamespace( "http://test2.org/", "test2");
       node.addNamespace( "http://test3.org/", "test3");
       node.addNamespace( "http://test4.org/", "test4");
       node.addNamespace( "http://test5.org/", "test5");
       node.addNamespace( "http://test6.org/", "test6");
       node.addNamespace( "http://test7.org/", "test7");
       node.addNamespace( "http://test8.org/", "test8");
       node.addNamespace( "http://test9.org/", "test9");
       assertTrue( node.getNamespacesLength() == 9 );
       assertTrue( node.getNamespaceIndex( "http://test1.org/") == 0 );
       assertTrue( (  "test2" != node.getNamespacePrefix(1) ) == false );
       assertTrue( ( 		      "test1" != node.getNamespacePrefix( "http://test1.org/") ) == false );
       assertTrue( (  "http://test2.org/" != node.getNamespaceURI(1) ) == false );
       assertTrue( ( 		      "http://test2.org/" != node.getNamespaceURI( "test2") ) == false );
       assertTrue( node.getNamespaceIndex( "http://test1.org/") == 0 );
       assertTrue( node.getNamespaceIndex( "http://test2.org/") == 1 );
       assertTrue( node.getNamespaceIndex( "http://test5.org/") == 4 );
       assertTrue( node.getNamespaceIndex( "http://test9.org/") == 8 );
       assertTrue( node.getNamespaceIndex( "http://testX.org/") == -1 );
       assertTrue( node.hasNamespaceURI( "http://test1.org/") != false );
       assertTrue( node.hasNamespaceURI( "http://test2.org/") != false );
       assertTrue( node.hasNamespaceURI( "http://test5.org/") != false );
       assertTrue( node.hasNamespaceURI( "http://test9.org/") != false );
       assertTrue( node.hasNamespaceURI( "http://testX.org/") == false );
       assertTrue( node.getNamespaceIndexByPrefix( "test1") == 0 );
       assertTrue( node.getNamespaceIndexByPrefix( "test5") == 4 );
       assertTrue( node.getNamespaceIndexByPrefix( "test9") == 8 );
       assertTrue( node.getNamespaceIndexByPrefix( "testX") == -1 );
       assertTrue( node.hasNamespacePrefix( "test1") != false );
       assertTrue( node.hasNamespacePrefix( "test5") != false );
       assertTrue( node.hasNamespacePrefix( "test9") != false );
       assertTrue( node.hasNamespacePrefix( "testX") == false );
       assertTrue( node.hasNamespaceNS( "http://test1.org/", "test1") != false );
       assertTrue( node.hasNamespaceNS( "http://test5.org/", "test5") != false );
       assertTrue( node.hasNamespaceNS( "http://test9.org/", "test9") != false );
       assertTrue( node.hasNamespaceNS( "http://testX.org/", "testX") == false );
       node = null;
       triple = null;
       attr = null;
 }
Exemplo n.º 3
0
 public void test_XMLNode_namespace_remove_by_prefix()
 {
     XMLTriple triple = new  XMLTriple("test","","");
       XMLAttributes attr = new  XMLAttributes();
       XMLNode node = new XMLNode(triple,attr);
       node.addNamespace( "http://test1.org/", "test1");
       node.addNamespace( "http://test2.org/", "test2");
       node.addNamespace( "http://test3.org/", "test3");
       node.addNamespace( "http://test4.org/", "test4");
       node.addNamespace( "http://test5.org/", "test5");
       assertTrue( node.getNamespacesLength() == 5 );
       node.removeNamespace( "test1");
       assertTrue( node.getNamespacesLength() == 4 );
       node.removeNamespace( "test2");
       assertTrue( node.getNamespacesLength() == 3 );
       node.removeNamespace( "test3");
       assertTrue( node.getNamespacesLength() == 2 );
       node.removeNamespace( "test4");
       assertTrue( node.getNamespacesLength() == 1 );
       node.removeNamespace( "test5");
       assertTrue( node.getNamespacesLength() == 0 );
       node.addNamespace( "http://test1.org/", "test1");
       node.addNamespace( "http://test2.org/", "test2");
       node.addNamespace( "http://test3.org/", "test3");
       node.addNamespace( "http://test4.org/", "test4");
       node.addNamespace( "http://test5.org/", "test5");
       assertTrue( node.getNamespacesLength() == 5 );
       node.removeNamespace( "test5");
       assertTrue( node.getNamespacesLength() == 4 );
       node.removeNamespace( "test4");
       assertTrue( node.getNamespacesLength() == 3 );
       node.removeNamespace( "test3");
       assertTrue( node.getNamespacesLength() == 2 );
       node.removeNamespace( "test2");
       assertTrue( node.getNamespacesLength() == 1 );
       node.removeNamespace( "test1");
       assertTrue( node.getNamespacesLength() == 0 );
       node.addNamespace( "http://test1.org/", "test1");
       node.addNamespace( "http://test2.org/", "test2");
       node.addNamespace( "http://test3.org/", "test3");
       node.addNamespace( "http://test4.org/", "test4");
       node.addNamespace( "http://test5.org/", "test5");
       assertTrue( node.getNamespacesLength() == 5 );
       node.removeNamespace( "test3");
       assertTrue( node.getNamespacesLength() == 4 );
       node.removeNamespace( "test1");
       assertTrue( node.getNamespacesLength() == 3 );
       node.removeNamespace( "test4");
       assertTrue( node.getNamespacesLength() == 2 );
       node.removeNamespace( "test5");
       assertTrue( node.getNamespacesLength() == 1 );
       node.removeNamespace( "test2");
       assertTrue( node.getNamespacesLength() == 0 );
       node = null;
       triple = null;
       attr = null;
 }
Exemplo n.º 4
0
 public void test_XMLNode_namespace_add()
 {
     XMLTriple triple = new  XMLTriple("test","","");
       XMLAttributes attr = new  XMLAttributes();
       XMLNode node = new XMLNode(triple,attr);
       assertTrue( node.getNamespacesLength() == 0 );
       assertTrue( node.isNamespacesEmpty() == true );
       node.addNamespace( "http://test1.org/", "test1");
       assertTrue( node.getNamespacesLength() == 1 );
       assertTrue( node.isNamespacesEmpty() == false );
       node.addNamespace( "http://test2.org/", "test2");
       assertTrue( node.getNamespacesLength() == 2 );
       assertTrue( node.isNamespacesEmpty() == false );
       node.addNamespace( "http://test1.org/", "test1a");
       assertTrue( node.getNamespacesLength() == 3 );
       assertTrue( node.isNamespacesEmpty() == false );
       node.addNamespace( "http://test1.org/", "test1a");
       assertTrue( node.getNamespacesLength() == 3 );
       assertTrue( node.isNamespacesEmpty() == false );
       assertTrue( ! (node.getNamespaceIndex( "http://test1.org/") == -1) );
       node = null;
       triple = null;
       attr = null;
 }