SpecificationLoader { private static NamespaceContextImpl getNamespaceMap(XmlObject object) { Map<String, String> namespaces = getNamespaceMap(object.getDomNode()); NamespaceContextImpl result = new NamespaceContextImpl(); for(Entry<String, String> namespaceEntry : namespaces.entrySet()) { result.setNamespace(namespaceEntry.getKey(), namespaceEntry.getValue()); } return result; } SpecificationLoader(BPELUnitRunner runner); TestSuite loadTestSuite(File suite); static Definition loadWsdlDefinition(String baseDir,
			String wsdlFileName, String partnerName); static Definition loadWsdlDefinition(String wsdlFileName,
			String partnerName);  }
@Test public void test_getNamespaceMap_TopLevel() throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); String xml = "<a xmlns:a=\"a\" xmlns:b=\"b\" xmlns=\"c\"><A xmlns:a=\"A\" /></a>"; Document document = db.parse(new InputSource(new StringReader(xml))); Map<String, String> namespaceMap = SpecificationLoader.getNamespaceMap(document.getDocumentElement()); assertEquals("a", namespaceMap.get("a")); assertEquals("b", namespaceMap.get("b")); assertEquals("c", namespaceMap.get("")); }
@Test public void test_getNamespaceMap_NestedElement() throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); String xml = "<a xmlns:a=\"a\" xmlns:b=\"b\" xmlns=\"c\"><A xmlns:a=\"A\" /></a>"; Document document = db.parse(new InputSource(new StringReader(xml))); Map<String, String> namespaceMap = SpecificationLoader.getNamespaceMap(document.getDocumentElement().getFirstChild()); assertEquals("A", namespaceMap.get("a")); assertEquals("b", namespaceMap.get("b")); assertEquals("c", namespaceMap.get("")); }