SpecificationReader { protected Architecture<Resource, Link> toArchitecture(nu.xom.Element eArch) throws IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { Architecture<Resource, Link> architecture = new Architecture<Resource, Link>(); nu.xom.Elements eResources = eArch.getChildElements("resource", SpecificationWriter.NS); for (nu.xom.Element eResource : iterable(eResources)) { Resource resource = toNode(eResource, null); architecture.addVertex(resource); } nu.xom.Elements eLinks = eArch.getChildElements("link", SpecificationWriter.NS); for (nu.xom.Element eLink : iterable(eLinks)) { parseLink(eLink, architecture); } return architecture; }  Specification read(String filename); Specification read(File file); Specification read(InputStream in); Specification toSpecification(nu.xom.Element eSpecification);  }
@Test public void toArchitectureTest() throws ValidityException, ParsingException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { nu.xom.Element eArch = new nu.xom.Element("architecture", SpecificationWriter.NS); nu.xom.Element r1 = new nu.xom.Element("resource", SpecificationWriter.NS); r1.addAttribute(new Attribute("id", "r1")); eArch.appendChild(r1); nu.xom.Element r2 = new nu.xom.Element("resource", SpecificationWriter.NS); r2.addAttribute(new Attribute("id", "r2")); eArch.appendChild(r2); nu.xom.Element l = new nu.xom.Element("link", SpecificationWriter.NS); l.addAttribute(new Attribute("id", "l")); l.addAttribute(new Attribute("source", "r1")); l.addAttribute(new Attribute("destination", "r2")); eArch.appendChild(l); SpecificationReader r = new SpecificationReader(); Architecture<Resource, Link> architecture = r.toArchitecture(eArch); Assert.assertNotNull(architecture.getVertex("r1")); Assert.assertNotNull(architecture.getVertex("r2")); Assert.assertNotNull(architecture.getEdge("l")); }