Package org.milyn.edisax

Examples of org.milyn.edisax.MockContentHandler


* @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a>
*/
public class FieldRepeatTest extends TestCase {

  public void test() throws IOException, SAXException, EDIConfigurationException {
    MockContentHandler handler;
    EdifactModel msg1 = EDIParser.parseMappingModel(getClass().getResourceAsStream("edi-to-xml-mapping.xml"));
   
    EDIParser parser = new EDIParser();
    parser.setMappingModel(msg1);

    handler = new MockContentHandler();
    parser.setContentHandler(handler)

    parser.parse(new InputSource(getClass().getResourceAsStream("edi-input.txt")));   
   
        XMLUnit.setIgnoreWhitespace( true );
View Full Code Here


   
    UNEdifactInterchangeParser parser = new UNEdifactInterchangeParser();
    parser.setMappingsRegistry(new DefaultMappingsRegistry(model1, model2));
    parser.ignoreNewLines(true);

    MockContentHandler handler;
   
    handler = new MockContentHandler();
        NamespaceDeclarationStack namespaceDeclarationStack = new NamespaceDeclarationStack(parser);
        parser.setContentHandler(new NamespaceAwareHandler(handler, namespaceDeclarationStack));

    try {
      parser.parse(new InputSource(getClass().getResourceAsStream("unedifact-msg-03.edi")));
View Full Code Here

   
    UNEdifactInterchangeParser parser = new UNEdifactInterchangeParser();
    parser.setMappingsRegistry(new DefaultMappingsRegistry(model1, model2));
    parser.ignoreNewLines(true);

    MockContentHandler handler;
   
    // Test message 01 - no UNA segment...
    handler = new MockContentHandler();
        NamespaceDeclarationStack namespaceDeclarationStack = new NamespaceDeclarationStack(parser);
        parser.setContentHandler(new NamespaceAwareHandler(handler, namespaceDeclarationStack));
    parser.parse(new InputSource(getClass().getResourceAsStream("unedifact-msg-05.edi")));
//    System.out.println(handler.xmlMapping);
        XMLUnit.setIgnoreWhitespace( true );
View Full Code Here

    private EdifactModel msg1;
    private MockContentHandler handler;

    public void setUp() throws IOException, SAXException {
        msg1 = EDIParser.parseMappingModel(getClass().getResourceAsStream("edi-to-xml-mapping.xml"));
        handler = new MockContentHandler();
    }
View Full Code Here

    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()));
View Full Code Here

* @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a>
*/
public class IgnoreUnmappedFieldsTest extends TestCase {

  public void test() throws IOException, SAXException, EDIConfigurationException {
    MockContentHandler handler;
    EdifactModel msg1 = EDIParser.parseMappingModel(getClass().getResourceAsStream("edi-to-xml-mapping.xml"));
   
    EDIParser parser = new EDIParser();
    parser.setMappingModel(msg1);

    handler = new MockContentHandler();
    parser.setContentHandler(handler)

    parser.parse(new InputSource(getClass().getResourceAsStream("edi-input.txt")));   
   
        XMLUnit.setIgnoreWhitespace( true );
View Full Code Here

TOP

Related Classes of org.milyn.edisax.MockContentHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.