public void test_XMLNode_removeNamespaces()
 {
     XMLTriple triple = new  XMLTriple("test","","");
       XMLAttributes attr = new  XMLAttributes();
       XMLNode node = new XMLNode(triple,attr);
       XMLNamespaces nms;
       int i = node.addNamespace( "http://test1.org/", "test1");
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       nms = node.getNamespaces();
       assertTrue( nms.getLength() == 1 );
       i = node.addNamespace( "http://test2.org/", "test2");
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       nms = node.getNamespaces();
       assertTrue( nms.getLength() == 2 );
       i = node.removeNamespace(7);
       assertTrue( i == libsbml.LIBSBML_INDEX_EXCEEDS_SIZE );
       nms = node.getNamespaces();
       assertTrue( nms.getLength() == 2 );
       i = node.removeNamespace( "name7");
       assertTrue( i == libsbml.LIBSBML_INDEX_EXCEEDS_SIZE );
       nms = node.getNamespaces();
       assertTrue( nms.getLength() == 2 );
       i = node.removeNamespace(0);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       nms = node.getNamespaces();
       assertTrue( nms.getLength() == 1 );
       i = node.removeNamespace( "test2");
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       nms = node.getNamespaces();
       assertTrue( nms.getLength() == 0 );
       triple = null;
       attr = null;
       node = null;
 }
Example #2
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;
 }