Package org.milyn.payload

Examples of org.milyn.payload.JavaSource


        Object result = null;
        try {
            StringResult stringResult = new StringResult();
            ExecutionContext executionContext = this.smooks.createExecutionContext();

            this.smooks.filter( new JavaSource( object ),
                                stringResult,
                                executionContext );

            result = stringResult.getResult();
        } catch ( Exception e ) {
View Full Code Here


        Object result = null;
        try {
            StringResult stringResult = new StringResult();
            ExecutionContext executionContext = this.smooks.createExecutionContext();

            this.smooks.filter( new JavaSource( object ),
                                stringResult,
                                executionContext );

            result = stringResult.getResult();
        } catch ( Exception e ) {
View Full Code Here

        Object result = null;
        try {
            StringResult stringResult = new StringResult();
            ExecutionContext executionContext = this.smooks.createExecutionContext();

            this.smooks.filter( new JavaSource( object ),
                                stringResult,
                                executionContext );

            result = stringResult.getResult();
        } catch ( Exception e ) {
View Full Code Here

        test("smooks-config-inc-encl-doc-off.xml", SOURCE_2, EXPECTED_2);
    }

    public void test_beanSetting() {
        MyBean1 pojo = new MyBean1();
        JavaSource source;

        source = new JavaSource(pojo);
        assertEquals(pojo, source.getBeans().get("myBean1"));

        source = new JavaSource("blah", pojo);
        assertEquals(pojo, source.getBeans().get("blah"));

        Map beans = new HashMap();
        beans.put("abcd", pojo);
        source = new JavaSource(beans);
        assertEquals(pojo, source.getBeans().get("abcd"));       
    }
View Full Code Here

    public void test_streamingOff_01() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-eventstream-off.xml"));
        StringResult result = new StringResult();

        smooks.filterSource(new JavaSource(new MyBean1()), result);
        assertEquals("<nullsource-document />", result.getResult());
    }
View Full Code Here

        assertEquals("<nullsource-document />", result.getResult());
    }

    public void test_streamingOff_02() throws IOException, SAXException {
        Smooks smooks = new Smooks();
        JavaSource javaSource = new JavaSource(new MyBean1());
        StringResult result = new StringResult();

        // Turn streaming off via the JavaSource...
        javaSource.setEventStreamRequired(false);

        smooks.filterSource(javaSource, result);
        assertEquals("<nullsource-document />", result.getResult());
    }
View Full Code Here

    public void test_streamingOn_01() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-eventstream-on.xml"));
        StringResult result = new StringResult();

        smooks.filterSource(new JavaSource(new MyBean1()));
        assertNotSame("<nullsource-document></nullsource-document>", result.getResult());
    }
View Full Code Here

        assertNotSame("<nullsource-document></nullsource-document>", result.getResult());
    }

    public void test_streamingOn_02() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-eventstream-on.xml"));
        JavaSource javaSource = new JavaSource(new MyBean1());

        // Explicitly configure it on... should cause an erros because it is explicitly
        // configured 'on' in the config...
        javaSource.setEventStreamRequired(false);

        try {
            smooks.filterSource(javaSource);
        } catch(SmooksException e) {
            assertEquals("Invalid Smooks configuration.  Feature '" + JavaSource.FEATURE_GENERATE_EVENT_STREAM + "' is explicitly configured 'on' in the Smooks configuration, while the supplied JavaSource has explicitly configured event streaming to be off (through a call to JavaSource.setEventStreamRequired).", e.getCause().getMessage());
View Full Code Here

    }

    private void test(String config, List<Object> sourceObjects, String expected) throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream(config));
        ExecutionContext execContext = smooks.createExecutionContext();
        JavaSource source = new JavaSource(sourceObjects);
        StringWriter result = new StringWriter();

        smooks.filterSource(execContext, source, new StreamResult(result));
        assertEquals(expected, result.toString());
    }
View Full Code Here

        JavaResult javaResult = (JavaResult) result;
        beanMap = javaResult.getResultMap();
    }

    if(source instanceof JavaSource) {
        JavaSource javaSource = (JavaSource) source;
        Map<String, Object> sourceBeans = javaSource.getBeans();

        if(sourceBeans != null) {
            if(beanMap != null) {
                beanMap.putAll(sourceBeans);
            } else {
View Full Code Here

TOP

Related Classes of org.milyn.payload.JavaSource

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.