Package org.milyn.payload

Examples of org.milyn.payload.StringSource


    @Test
    public void testConfig01() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("config-01.xml"));

        try {
            smooks.filterSource(new StringSource("<root><a>1</a><a>2</a><a>3</a></root>"));

            assertEquals("1", getFileContents(file1));
            assertEquals("2", getFileContents(file2));
            assertEquals("3", getFileContents(file3));
        } finally {
View Full Code Here


            smooks.addVisitor(new Bean(HashMap.class, "object").bindTo("a", "a"));
            smooks.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("${object.a}").setUsage(OutputTo.stream("fileOS"))), "a");
            smooks.addVisitor(new FileOutputStreamResource().setFileNamePattern("${object.a}.xml").setDestinationDirectoryPattern("target/config-01-test/${object.a}").setResourceName("fileOS"), "a");

            smooks.filterSource(new StringSource("<root><a>1</a><a>2</a><a>3</a></root>"));

            assertEquals("1", getFileContents(file1));
            assertEquals("2", getFileContents(file2));
            assertEquals("3", getFileContents(file3));
        } finally {
View Full Code Here

                    .setFileNamePattern(outputFileName)
                    .setDestinationDirectoryPattern(destinationDir.getAbsolutePath())
                    .setResourceName(outputStreamRef)
                    , "a");

            smooks.filterSource(new StringSource("<root><a>1</a><a>2</a><a>3</a></root>"));

            assertEquals("123", getFileContents(outputFile));
        } finally {
            smooks.close();
            outputFile.delete();
View Full Code Here

    @SuppressWarnings("unchecked")
  private void test_appContextTime(Smooks smooks) throws IOException, SAXException, InterruptedException {
        ExecutionContext execContext = smooks.createExecutionContext();
        BeanContext beanContext = execContext.getBeanContext();

        smooks.filterSource(execContext, new StringSource("<doc/>"), null);
        List orders11 = (List) beanContext.getBean("orders1");
        List orders12 = (List) beanContext.getBean("orders2");

        smooks.filterSource(execContext, new StringSource("<doc/>"), null);
        List orders21 = (List) beanContext.getBean("orders1");
        List orders22 = (List) beanContext.getBean("orders2");

        assertTrue(orders11 != orders21);
        assertTrue(orders12 == orders22); // order12 should come from the app context cache

        // timeout the cached resultset...
        Thread.sleep(2050);

        smooks.filterSource(execContext, new StringSource("<doc/>"), null);
        List orders31 = (List) beanContext.getBean("orders1");
        List orders32 = (List) beanContext.getBean("orders2");

        assertTrue(orders11 != orders31);
        assertTrue(orders12 != orders32); // order12 shouldn't come from the app context cache - timed out ala TTL

        smooks.filterSource(execContext, new StringSource("<doc/>"), null);
        List orders41 = (List) beanContext.getBean("orders1");
        List orders42 = (List) beanContext.getBean("orders2");

        assertTrue(orders31 != orders41);
        assertTrue(orders32 == orders42); // order42 should come from the app context cache
View Full Code Here

        try {
            ExecutionContext execContext = smooks.createExecutionContext();
            BeanContext beanContext = execContext.getBeanContext();

            smooks.filterSource(execContext, new StringSource("<doc/>"), null);
            Map<String, Object> myOrder = (Map<String, Object>) beanContext.getBean("myOrder");

            assertEquals("{ORDERNUMBER=2, CUSTOMERNUMBER=2, PRODUCTCODE=456}", myOrder.toString());
        } finally {
            smooks.close();
View Full Code Here

        try {
            ExecutionContext execContext = smooks.createExecutionContext();
            BeanContext beanContext = execContext.getBeanContext();

            smooks.filterSource(execContext, new StringSource("<doc/>"), null);
            Map<String, Object> myOrder = (Map<String, Object>) beanContext.getBean("myOrder");

            assertEquals(null, myOrder);
        } finally {
            smooks.close();
View Full Code Here

            BeanId requiredOrderNumId = beanIdStore.register("requiredOrderNum");

            beanContext.addBean(requiredOrderNumId, 9999, null);
            try {
                smooks.filterSource(execContext, new StringSource("<doc/>"), null);
                fail("Expected DataSelectionException");
            } catch(SmooksException e) {
                assertEquals("Order with ORDERNUMBER=9999 not found in Database", e.getCause().getMessage());
            }
        } finally {
View Full Code Here

    public void test(String config) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream(config));
        StringResult result = new StringResult();

        smooks.filterSource(new StringSource("<x/>"), result);
        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>Hi there!", result.getResult());
    }
View Full Code Here

                from(fromEndpoint).process(smooksProcessor);
            }
        });
        context.start();
        sendBody(fromEndpoint, new StringSource("<coords><coord x='1' y='2' /><coord x='3' y='4' /></coords>"));

        final List<Coordinate> bodies = getBodies(getMockEndpoint(toEndpoint).getExchanges());
        assertThat(bodies, hasItems(new Coordinate(1, 2), new Coordinate(3, 4)));
    }
View Full Code Here

            public void configure() throws Exception {
                from(fromEndpoint).to("smooks://bean_routing_01.xml");
            }
        });
        context.start();
        sendBody(fromEndpoint, new StringSource("<coords><coord x='1' y='2' /><coord x='300' y='400' /></coords>"));

        final Message messageB = getExchange(getMockEndpoint("mock:b"));
        assertThat((Coordinate) messageB.getBody(), is(new Coordinate(1, 2)));

        final Message messageC = getExchange(getMockEndpoint("mock:c"));
View Full Code Here

TOP

Related Classes of org.milyn.payload.StringSource

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.