public void testApplicationData() throws Exception { Graph graph = new Graph("chain1"); assertNull(graph.getApplicationData("foo")); XppDom xpp3Dom1 = new XppDom(""); XppDom font = new XppDom("font"); font.setValue("big"); xpp3Dom1.addChild(font); graph.setAppData("foo", xpp3Dom1); assertSame(xpp3Dom1, graph.getApplicationData("foo")); XppDom xpp3Dom2 = new XppDom(""); XppDom font2 = new XppDom("font"); font2.setValue("small"); xpp3Dom2.addChild(font2); graph.setAppData("foo", xpp3Dom2); assertSame(xpp3Dom2, graph.getApplicationData("foo")); }
public void testReadFromXMLWithAppData() throws Exception { String expectedXML = "<graph id=\"myOneNodeGraph\">\n" + " <version>1.0</version>\n" + " <node id=\"node1\">\n" + " <operator>Op1</operator>\n" + " <sources/>\n" + " </node>\n" + " <applicationData id=\"foo\">\n" + " <font>Big</font>\n" + " <colour>red</colour>\n" + " </applicationData>\n" + " <applicationData id=\"bar\">\n" + " <textmode>true</textmode>\n" + " </applicationData>\n" + "</graph>"; StringReader reader = new StringReader(expectedXML); Graph graph = GraphIO.read(reader); XppDom fooData = graph.getApplicationData("foo"); assertNotNull(fooData); assertEquals(2, fooData.getChildCount()); assertEquals("Big", fooData.getChild("font").getValue()); assertEquals("red", fooData.getChild("colour").getValue()); XppDom barData = graph.getApplicationData("bar"); assertNotNull(barData); assertEquals(1, barData.getChildCount()); assertEquals("true", barData.getChild("textmode").getValue()); }