Package org.milyn

Examples of org.milyn.Smooks


  protected void setUp() throws Exception {
    SAXVisitBeforeVisitor.visited = false;
  }

  public void test_terminate_prog_after() {
    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);
  }
View Full Code Here


    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order.xml")));
    assertTrue(SAXVisitBeforeVisitor.visited);
  }

  public void test_terminate_prog_before() {
    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);
  }
View Full Code Here

    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"));
   
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order.xml")));
    assertTrue(SAXVisitBeforeVisitor.visited);
  }
View Full Code Here

    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"));
   
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order.xml")));
    assertFalse(SAXVisitBeforeVisitor.visited);
  }
View Full Code Here

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

    public void test_setting_sax() {
        Smooks smooks = new Smooks();

        // Set the Smooks instnace to use the SAX filter...
        smooks.setFilterSettings(FilterSettings.DEFAULT_SAX);

        // 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

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

    public void test_reader_writer() throws SAXException, IOException {
        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());
    }
View Full Code Here

*/
public class ReaderConfigTest extends TestCase {

    public void test_01() throws IOException, SAXException {
        // Should allow reader config without a defined reader class i.e. config the default...
        new Smooks(getClass().getResourceAsStream("config_01.xml"));
    }
View Full Code Here

    private static byte[] messageIn = readInputMessage();

    protected static String runSmooksTransform() throws IOException, SAXException, SmooksException {

        Smooks smooks = new Smooks("smooks-config.xml");

        try {
            ExecutionContext executionContext = smooks.createExecutionContext();
            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

        // Should allow reader config without a defined reader class i.e. config the default...
        new Smooks(getClass().getResourceAsStream("config_01.xml"));
    }

    public void test_02() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("config_02.xml"));
        SmooksResourceConfiguration readerConfig = AbstractParser.getSAXParserConfiguration(smooks.createExecutionContext("A").getDeliveryConfig());

        assertEquals("com.ZZZZReader", readerConfig.getResource());

        assertEquals("A", readerConfig.getTargetProfile());
View Full Code Here

            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());
        }
    }

    public void test_setting_dom() {
        Smooks smooks = new Smooks();

        // Set the Smooks instnace to use the DOM filter...
        smooks.setFilterSettings(FilterSettings.DEFAULT_DOM);

        // 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

TOP

Related Classes of org.milyn.Smooks

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.