Package org.milyn.payload

Examples of org.milyn.payload.JavaResult


        execute_01_test(smooks);
    }

    private void execute_01_test(Smooks smooks) {
        JavaResult result = new JavaResult();
        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("../order-01.xml")), result);

        Order order = (Order) result.getBean("order");
        int identity = System.identityHashCode(order);

        assertEquals("Order:" + identity + "[header[null, 123123, Joe, false, Order:" + identity + "]\n" +
                "orderItems[[{productId: 111, quantity: 2, price: 8.9}, {productId: 222, quantity: 7, price: 5.2}]]\n" +
                "norderItemsArray[[{productId: 111, quantity: 2, price: 8.9}, {productId: 222, quantity: 7, price: 5.2}]]]", order.toString());
View Full Code Here


                            .bindTo("price", "order-item/price", new DoubleDecoder()))
                );

        smooks.addVisitor(orderBean);

        JavaResult result = new JavaResult();
        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("../order-01.xml")), result);

        Map order = (Map) result.getBean("order");

        HashMap headerMap = (HashMap) order.get("header");
        assertEquals("Joe", headerMap.get("customerName"));
        assertEquals(123123, headerMap.get("customerNumber"));
        assertEquals("", headerMap.get("privatePerson"));
View Full Code Here

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

        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order-01.xml")), result);

        ExtendedOrder order = (ExtendedOrder) result.getBean("order");

        assertEquals("[{productId: 111, quantity: 2, price: 8.9}, {productId: 222, quantity: 7, price: 5.2}]", order.getOrderItems().toString());
  }
View Full Code Here

        Smooks smooks = new Smooks(getClass().getResourceAsStream("xmlconfig_01.xml"));
        execSmooksArrays(smooks);
    }

    private void execSmooksArrays(Smooks smooks) {
        JavaResult result = new JavaResult();
        ExecutionContext execContext = smooks.createExecutionContext();

        //execContext.setEventListener(new ExecListener());
        smooks.filterSource(execContext, new StreamSource(getClass().getResourceAsStream("order-01.xml")), result);

        Order order = (Order) result.getBean("order");
        int identity = System.identityHashCode(order);

        assertEquals("Order:" + identity + "[header[null]\n" +
                     "orderItems[null]\n" +
                     "norderItemsArray[[{productId: 111, quantity: null, price: 0.0}, {productId: 222, quantity: null, price: 0.0}]]]", order.toString());
View Full Code Here

        test(StreamFilterType.SAX);
    }

    private void test(StreamFilterType filterType) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("config_01.xml"));
        JavaResult result = new JavaResult();

        smooks.setFilterSettings(new FilterSettings(filterType));
        smooks.filterSource(new StringSource("<root><a><b>1</b></a></root>"), result);
        assertNotNull(result.getBean("root"));
        assertNull(result.getBean("a"));
        assertNull(result.getBean("b"));
    }
View Full Code Here

      test_01(FilterSettings.DEFAULT_SAX);
    }

    public void test_01(FilterSettings filterSettings) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("test_bean_01.xml"));
        JavaResult result = new JavaResult();

        smooks.setFilterSettings(filterSettings);

        ExecutionContext execContext = smooks.createExecutionContext();
        //execContext.setEventListener(new HtmlReportGenerator("/zap/report.html"));
        smooks.filterSource(execContext, new StreamSource(getInput("order-01.xml")), result);

        ExtendedOrder order = (ExtendedOrder) result.getBean("order");
        BeanBindingExtendedConfigTest.assertOrderOK(order, true);
       
        assertNull(result.getBean("headerBean"));
        assertNull(result.getBean("headerBeanHash"));
        assertNull(result.getBean("orderItemList"));
        assertNull(result.getBean("orderItemArray"));
        assertNull(result.getBean("orderItem"));
    }
View Full Code Here

*/
public class ListOfListsTest extends TestCase {

    public void test() throws IOException, SAXException {             
        Smooks smooks = new Smooks(getClass().getResourceAsStream("list-of-lists-config.xml"));
        JavaResult javaResult = new JavaResult();

        smooks.filterSource(smooks.createExecutionContext(), new StreamSource(getClass().getResourceAsStream("list-of-lists-message.xml")), javaResult);
        assertEquals(getExpectedOrderArray(), javaResult.getBean("order"));
    }
View Full Code Here

      test_02(FilterSettings.DEFAULT_SAX);
    }
   
    public void test_02(FilterSettings filterSettings) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("test_bean_02.xml"));
        JavaResult result = new JavaResult();

        smooks.setFilterSettings(filterSettings);

        ExecutionContext execContext = smooks.createExecutionContext();
        //execContext.setEventListener(new HtmlReportGenerator("/zap/report.html"));
        smooks.filterSource(execContext, new StreamSource(getInput("order-01.xml")), result);

        ExtendedOrder order = (ExtendedOrder) result.getBean("order");
        BeanBindingExtendedConfigTest.assertOrderOK(order, true);
       
        assertNotNull(result.getBean("headerBean"));
        assertNull(result.getBean("headerBeanHash"));
        assertNull(result.getBean("orderItemList"));
        assertNull(result.getBean("orderItemArray"));
        assertNull(result.getBean("orderItem"));
    }
View Full Code Here

*/
public class GetBeanByTypeTest extends TestCase {

    public void test() throws IOException, SAXException {
        Smooks smooks = new Smooks(RetainBeanTest.class.getResourceAsStream("test_bean_01.xml"));
        JavaResult result = new JavaResult();

        ExecutionContext execContext = smooks.createExecutionContext();
        smooks.filterSource(execContext, new StreamSource(getInput("order-01.xml")), result);

        ExtendedOrder order = result.getBean(ExtendedOrder.class);
        assertNotNull(order);
        BeanBindingExtendedConfigTest.assertOrderOK(order, true);
       
        order = execContext.getBeanContext().getBean(ExtendedOrder.class);
        assertNotNull(order);
View Full Code Here

                .setDecoder(new IntegerDecoder()));
    smooks.addVisitor(new Value("privatePerson", "privatePerson")
                .setDecoder(new BooleanDecoder())
                .setDefaultValue("true"));

    JavaResult result = new JavaResult();
        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("../order-01.xml")), result);

        assertEquals("Joe", result.getBean("customerName"));
    assertEquals(123123, result.getBean("customerNumber"));
    assertEquals(Boolean.TRUE, result.getBean("privatePerson"));
  }
View Full Code Here

TOP

Related Classes of org.milyn.payload.JavaResult

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.