SPIDIntegrationUtil { public Element xmlStringToElement(String xmlData) throws SAXException, IOException, ParserConfigurationException { InputStream xmlByteArrayInputStream = new ByteArrayInputStream(xmlData.getBytes()); Element node = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(xmlByteArrayInputStream).getDocumentElement(); return node; } SPIDIntegrationUtil(); String encodeAndPrintAuthnRequest(AuthnRequest authnRequest); String printAuthnRequest(AuthnRequest authnRequest); Element xmlStringToElement(String xmlData); Credential getCredential(); KeyStore getKeyStore(); Signature getSignature();  }
@Test public void xmlStringToXMLObjectTest() { ClassLoader classLoader = getClass().getClassLoader(); File xmlFile = new File(classLoader.getResource("metadata/idp/telecom-metadata.xml").getFile()); try (Scanner scanner = new Scanner(xmlFile)) { String xmlData = scanner.useDelimiter("\\Z").next(); Element node = spidIntegrationUtil.xmlStringToElement(xmlData); Assert.assertEquals("md:EntityDescriptor", node.getNodeName()); } catch (SAXException | IOException | ParserConfigurationException e) { e.printStackTrace(); Assert.fail(); } }