Package org.milyn.payload

Examples of org.milyn.payload.JavaResult


    }

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

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

        Person person = (Person) result.getBean("person");
        assertEquals("(Linda, Coughlan, Ireland, Female, 22)", person.toString());
    }
View Full Code Here


    }

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

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

        List<Person> people = (List<Person>) result.getBean("people");
        assertEquals(
                "[(Tom, Fennelly, Ireland, Male, 4), (Mike, Fennelly, Ireland, Male, 2), (Linda, Coughlan, Ireland, Female, 22)]",
                people.toString());
    }
View Full Code Here

        Smooks smooks = new Smooks();

        smooks.setReaderConfig(new CSVRecordParserConfigurator("firstname,lastname,$ignore$,gender,age,country")
                .setBinding(new Binding("people", Person.class, BindingType.LIST)));

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

        List<Person> people = (List<Person>) result.getBean("people");
        assertEquals(
                "[(Tom, Fennelly, Ireland, Male, 4), (Mike, Fennelly, Ireland, Male, 2), (Linda, Coughlan, Ireland, Female, 22)]",
                people.toString());
    }
View Full Code Here

        Smooks smooks = new Smooks();

        smooks.setReaderConfig(new CSVRecordParserConfigurator("firstname,lastname,$ignore$,gender,age,country")
                .setBinding(new Binding("person", Person.class, BindingType.SINGLE)));

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

        Person person = (Person) result.getBean("person");
        assertEquals("(Linda, Coughlan, Ireland, Female, 22)", person.toString());
    }
View Full Code Here

        Smooks smooks = new Smooks();

        smooks.setReaderConfig(new CSVRecordParserConfigurator("firstname,lastname,$ignore$,gender,age,country")
                .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;

        assertEquals(3, people.size());

        person = people.get(0);
View Full Code Here

        smooks.setFilterSettings(filterSettings);
        test_13(smooks);
    }

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

        Map<Integer, Person> people = (Map<Integer, Person>) result.getBean("people");
        Person person;

        person = people.get(4);
        assertEquals("(Tom, Fennelly, Ireland, Male, 4)", person.toString());
        person = people.get(2);
View Full Code Here

    test_01_map_binding(smooks);
  }

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

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

    person = people.get("Maurice");
    assertEquals("Maurice", person.get("firstname"));
    assertEquals("Zeijen", person.get("lastname"));
View Full Code Here

        AssertArgument.isNotNull(writer, "writer");

        Object rootBean;

        if(modelRoot instanceof JavaResult) {
            JavaResult javaResult = (JavaResult) modelRoot;
            Map<String, Object> beanMap = javaResult.getResultMap();

            if(beanMap.isEmpty()) {
                throw new IOException("Unable to serialize empty JavaResult Model.");
            } else if(beanMap.size() > 1) {
                throw new IOException("Unable to serialize JavaResult Model that contains more than 1 bean instance.");
View Full Code Here

        smooks.setFilterSettings(filterSettings);
        test_14(smooks);
    }

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

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

        person = people.get("Tom");
        assertEquals("Tom", person.get("firstname"));
        assertEquals("Fennelly", person.get("lastname"));
View Full Code Here

    test_01_list_binding(smooks);
  }

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

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

    person = people.get(0);
    assertEquals("Maurice", person.get("firstname"));
    assertEquals("Zeijen", person.get("lastname"));
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.