Package org.milyn

Examples of org.milyn.Smooks.filterSource()


    Smooks smooks = new Smooks();
   
    smooks.addVisitor(new TerminateVisitor(), "customer");
    smooks.addVisitor(new SAXVisitBeforeVisitor().setInjectedParam("blah"), "user");
   
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order.xml")));
    assertTrue(SAXVisitBeforeVisitor.visited);
  }

  public void test_terminate_prog_before() {
    Smooks smooks = new Smooks();
View Full Code Here


    Smooks smooks = new Smooks();
   
    smooks.addVisitor(new TerminateVisitor().setTerminateBefore(true), "customer");
    smooks.addVisitor(new SAXVisitBeforeVisitor().setInjectedParam("blah"), "user");
   
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order.xml")));
    assertFalse(SAXVisitBeforeVisitor.visited);
  }

  public void test_terminate_xml_after() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("config-01.xml"));
View Full Code Here

  }

  public void test_terminate_xml_after() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("config-01.xml"));
   
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order.xml")));
    assertTrue(SAXVisitBeforeVisitor.visited);
  }

  public void test_terminate_xml_before() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("config-02.xml"));
View Full Code Here

  }

  public void test_terminate_xml_before() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("config-02.xml"));
   
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order.xml")));
    assertFalse(SAXVisitBeforeVisitor.visited);
  }
}
View Full Code Here

        // Add a DOM-only visitor
        smooks.addVisitor(new ProcessorVisitor1(), "a");

        try {
            smooks.filterSource(new StringSource("<a/>"));
            fail("Expected SmooksException.");
        } catch (SmooksException e) {
            assertEquals("The configured Filter ('SAX') cannot be used with the specified set of Smooks visitors.  The 'DOM' Filter is the only filter that can be used for this set of Visitors.  Turn on Debug logging for more information.", e.getMessage());
        }
    }
View Full Code Here

        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-01.xml"));
        ExecutionContext execContext = smooks.createExecutionContext();
        String input = new String(StreamUtils.readStream(getClass().getResourceAsStream("test-01.xml")));
        StringWriter writer = new StringWriter();

        smooks.filterSource(execContext, new StreamSource(new StringReader(input)), new StreamResult(writer));
        assertEquals(StreamUtils.trimLines(new StringReader(input)).toString(), StreamUtils.trimLines(new StringReader(writer.toString())).toString());
    }

    public void test_reader_stream() throws SAXException, IOException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-01.xml"));
View Full Code Here

            StringWriter writer = new StringWriter();

            // Configure the execution context to generate a report...
            executionContext.setEventListener(new HtmlReportGenerator("target/report/report.html"));

            smooks.filterSource(executionContext, new StreamSource(new InputStreamReader(new ByteArrayInputStream(messageIn), "UTF-8")), new StreamResult(writer));

            return writer.toString();
        } finally {
            smooks.close();
        }
View Full Code Here

        // Add a SAX-only visitor
        smooks.addVisitor(new SAXVisitor01(), "a");

        try {
            smooks.filterSource(new StringSource("<a/>"));
            fail("Expected SmooksException.");
        } catch (SmooksException e) {
            assertEquals("The configured Filter ('DOM') cannot be used with the specified set of Smooks visitors.  The 'SAX' Filter is the only filter that can be used for this set of Visitors.  Turn on Debug logging for more information.", e.getMessage());
        }
    }
View Full Code Here

        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-01.xml"));
        ExecutionContext execContext = smooks.createExecutionContext();
        String input = new String(StreamUtils.readStream(getClass().getResourceAsStream("test-01.xml")));
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();

        smooks.filterSource(execContext, new StreamSource(new StringReader(input)), new StreamResult(outStream));
        assertEquals(StreamUtils.trimLines(new StringReader(input)).toString(), StreamUtils.trimLines(new StringReader(outStream.toString())).toString());
    }

    public void test_stream_stream() throws SAXException, IOException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-01.xml"));
View Full Code Here

        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-01.xml"));
        ExecutionContext execContext = smooks.createExecutionContext();
        String input = new String(StreamUtils.readStream(getClass().getResourceAsStream("test-01.xml")));
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();

        smooks.filterSource(execContext, new StreamSource(new ByteArrayInputStream(input.getBytes())), new StreamResult(outStream));
        assertEquals(StreamUtils.trimLines(new StringReader(input)).toString(), StreamUtils.trimLines(new StringReader(outStream.toString())).toString());
    }

    public void test_stream_writer() throws SAXException, IOException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-01.xml"));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.