Package org.milyn.payload

Examples of org.milyn.payload.JavaResult


    }

    public void test_15() throws SmooksException, IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-extended-config-11.xml"));

        JavaResult result = new JavaResult();
        try {
            smooks.filterSource(new StreamSource(getClass().getResourceAsStream("input-message-05.csv")), result);
            fail("Expected SmooksConfigurationException");
        } catch (SmooksConfigurationException e) {
            assertEquals("Invalid field name 'xxxx'.  Valid names: [firstname, lastname, gender, age, country].",
View Full Code Here


    test_01_single_binding(smooks);
  }

  private void test_01_single_binding(Smooks smooks) {
    JavaResult result = new JavaResult();
    smooks.filterSource(new StreamSource(getClass().getResourceAsStream("/input-message-01.txt")), result);

    @SuppressWarnings("unchecked")
        Map<String, String> person = (Map<String, String>) result.getBean("person");

    assertEquals("Sanne", person.get("firstname"));
    assertEquals("Fries", person.get("lastname"));
    assertEquals("F", person.get("gender"));
    assertEquals("022", person.get("age"));
View Full Code Here

        Smooks smooks = new Smooks();

        smooks.setReaderConfig(new CSVRecordParserConfigurator("firstname?upper_case,lastname?uncap_first,$ignore$5")
                .setBinding(new Binding("people", HashMap.class, BindingType.LIST)));

        JavaResult result = new JavaResult();
        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("input-message-05.csv")), result);

        List<Map> people = (List<Map>) result.getBean("people");
        Map person;

        person = people.get(0);
        assertEquals("TOM", person.get("firstname"));
        assertEquals("fennelly", person.get("lastname"));
View Full Code Here

public class ValueBinderExtendedConfigTest extends TestCase {

  public void test_01() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("test_value_01.xml"));
    JavaResult result = new JavaResult();
    ExecutionContext execContext = smooks.createExecutionContext();

    //execContext.setEventListener(new HtmlReportGenerator("target/report/ValueBinderExtendedConfigTest-report.html"));

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

    assertEquals("Joe", result.getBean("customerName"));
    assertEquals(123123, result.getBean("customerNumber"));
    assertEquals(Boolean.TRUE, result.getBean("privatePerson"));
    assertEquals(1163616328000L, ((Date) result.getBean("date")).getTime());

    assertNull(result.getBean("product"));
  }
View Full Code Here

  }

  public void test_01_other() throws IOException, SAXException {
    Smooks smooks = new Smooks(getClass().getResourceAsStream("test_value_01.xml"));

    JavaResult result = new JavaResult();
    ExecutionContext execContext = smooks.createExecutionContext("other");

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

    assertEquals(222, result.getBean("product"));
  }
View Full Code Here

    }

    public List bind(Reader csvStream) {
        AssertArgument.isNotNull(csvStream, "csvStream");

        JavaResult javaResult = new JavaResult();

        smooks.filterSource(new StreamSource(csvStream), javaResult);

        return (List) javaResult.getBean(beanId);
    }
View Full Code Here

    }

    public Map bind(Reader csvStream) {
        AssertArgument.isNotNull(csvStream, "csvStream");

        JavaResult javaResult = new JavaResult();

        smooks.filterSource(new StreamSource(csvStream), javaResult);

        return (Map) javaResult.getBean(beanId);
    }
View Full Code Here

    private void runSmooks(String config) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream(config));

        for(int i = 0; i < NUM_WARMUPS; i++) {
            JavaResult javaResult = new JavaResult();
            smooks.filterSource(new StreamSource(getMessageReader()), javaResult);
        }

        long start = System.currentTimeMillis();
        JavaResult javaResult = null;
        for(int i = 0; i < NUM_ITERATIONS; i++) {
            javaResult = new JavaResult();
            smooks.filterSource(new StreamSource(getMessageReader()), javaResult);
        }
        System.out.println(config + " took: " + (System.currentTimeMillis() - start));
        List orderItems = (List) javaResult.getBean("orderItemList");
        if(orderItems != null) {
          System.out.println("Num order items: " + orderItems.size());
        }
    }
View Full Code Here

        test_templated_ext_12_13("scripted-ext-13.xml", StreamFilterType.SAX);
    }

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

        smooks.setFilterSettings(new FilterSettings(filterType));
        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order-message.xml")), result);
        Map orderItems = (Map) result.getBean("orderItems");
        Map orderItem;

        orderItem = (Map) orderItems.get("111");
        assertEquals("2", orderItem.get("quantity"));
        assertEquals("8.90", orderItem.get("price"));
View Full Code Here

        d03bHarness.assertXMLOK(getClass().getResourceAsStream("PAXLST.edi"), getClass().getResourceAsStream("PAXLST.xml"));
    }

    @Test
    public void test_PAXLST_test_fragment_split() throws IOException, SAXException {
        JavaResult result = new JavaResult();

        d03bHarness.smooksFilterSource("/org/milyn/edi/test/unedifact/d03b/smooks-unedifact-split.xml", new StreamSource(getClass().getResourceAsStream("PAXLST.edi")), result);

        String expectedXML = StreamUtils.readStreamAsString(getClass().getResourceAsStream("PAXLST_frag.xml"));
        XMLUnit.setIgnoreWhitespace(true);
        XMLUnit.compareXML(expectedXML, (String) result.getBean("PAXLST_frag"));
    }
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.