parser.setMappingsRegistry(new DefaultMappingsRegistry("mapping-models.zip", URI.create("./target")));
testExchanges(parser);
}
private void testExchanges(UNEdifactInterchangeParser parser) throws IOException, SAXException {
MockContentHandler handler;
// Test message 01 - no UNA segment...
handler = new MockContentHandler();
parser.setContentHandler(handler);
parser.parse(new InputSource(getClass().getResourceAsStream("unedifact-msg-01.edi")));
//System.out.println(handler.xmlMapping);
XMLUnit.setIgnoreWhitespace( true );
XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("unedifact-msg-expected.xml")), new StringReader(handler.xmlMapping.toString()));
// Test message 01 - has a UNA segment...
handler = new MockContentHandler();
parser.setContentHandler(handler);
parser.parse(new InputSource(getClass().getResourceAsStream("unedifact-msg-02.edi")));
XMLUnit.setIgnoreWhitespace( true );
XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("unedifact-msg-expected.xml")), new StringReader(handler.xmlMapping.toString()));