Search in sources :

Example 1 with InvalidXMLFilterStream

use of com.progress.xref.InvalidXMLFilterStream in project sonar-openedge by Riverside-Software.

the class InvalidXMLFilterStreamTest method testValidFile.

@Test
public void testValidFile() throws IOException {
    InputStream input = new FileInputStream(new File("src/test/resources/file1.xml"));
    InvalidXMLFilterStream input2 = new InvalidXMLFilterStream(input);
    try {
        DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(input2);
    } catch (ParserConfigurationException | SAXException uncaught) {
        throw new RuntimeException(uncaught);
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) InvalidXMLFilterStream(com.progress.xref.InvalidXMLFilterStream) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) File(java.io.File) FileInputStream(java.io.FileInputStream) SAXException(org.xml.sax.SAXException) Test(org.testng.annotations.Test)

Example 2 with InvalidXMLFilterStream

use of com.progress.xref.InvalidXMLFilterStream in project sonar-openedge by Riverside-Software.

the class InvalidXMLFilterStreamTest method testInvalidFile.

@Test
public void testInvalidFile() throws IOException {
    InputStream input = new FileInputStream(new File("src/test/resources/file2.xml"));
    InvalidXMLFilterStream input2 = new InvalidXMLFilterStream(input);
    try {
        Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(input2);
        assertNotNull(doc.getFirstChild());
        assertTrue(doc.getFirstChild().getChildNodes().getLength() > 2);
        Node node = doc.getFirstChild().getChildNodes().item(1);
        assertEquals(node.getAttributes().getNamedItem("File-name").getNodeValue(), "src\\procedures\\ sample\\test7.p");
    } catch (ParserConfigurationException | SAXException uncaught) {
        throw new RuntimeException(uncaught);
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Node(org.w3c.dom.Node) InvalidXMLFilterStream(com.progress.xref.InvalidXMLFilterStream) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Document(org.w3c.dom.Document) File(java.io.File) FileInputStream(java.io.FileInputStream) SAXException(org.xml.sax.SAXException) Test(org.testng.annotations.Test)

Aggregations

InvalidXMLFilterStream (com.progress.xref.InvalidXMLFilterStream)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 Test (org.testng.annotations.Test)2 SAXException (org.xml.sax.SAXException)2 Document (org.w3c.dom.Document)1 Node (org.w3c.dom.Node)1