package omino.utilities; import junit.framework.TestCase; public class TestOmNode extends TestCase { public void testCreate() { OmNode o = OmNode.create("top"); assertNotNull("create",o); } public void testAddChild() { OmNode o = OmNode.create("top"); assertNotNull("create",o); OmNode c = OmNode.create("x","3"); o.addChild(c); int a = o.getChildren().size(); assertEquals("child count",1,a); } public void testSetValue() { OmNode o = OmNode.create("top"); assertNotNull("create",o); o.setValue("x","3"); o.setValue("y","4"); o.setValue("x","24"); int a = o.getChildren().size(); assertEquals("child count",2,a); assertEquals("getValue","24",o.getValue("x")); assertEquals("getValue","4",o.getValue("y")); } public void testSetValueDotted() { OmNode o = OmNode.create("top"); o.setValue("a.b","fish"); OmNode a = o.getChild("a"); assertNotNull("a created on the way to a.b",a); OmNode b = a.getChild(0); assertNotNull("b created on the way to a.b",b); String s1 = a.getValue("b"); String s2 = o.getValue("a.b"); String s3 = b.getValue(); assertEquals("a.b = fish","fish",s1); assertEquals("a.b = fish","fish",s2); assertEquals("a.b = fish","fish",s3); } public void testToXml() { OmNode a = OmNode.create("top"); a.setValue("a.b.c","fish"); a.setValue("a.b.d","frog"); OmSystem.printf(a.toXml()); } }