Package org.milyn.payload

Examples of org.milyn.payload.StringResult


        Smooks smooks = new Smooks();

        smooks.setFilterSettings(new FilterSettings().setFilterType(StreamFilterType.SAX).setRewriteEntities(false));

        StringResult stringResult = new StringResult();
        smooks.filterSource(new StringSource("<a attrib=\"an &amp; 'attribute\">Bigger &gt; is better!</a>"), stringResult);
        assertEquals("<a attrib=\"an & 'attribute\">Bigger &#62; is better!</a>", stringResult.getResult());
    }
View Full Code Here


                assertEquals("&tomfennelly", element.getAttribute("attrib"));
                assertEquals("&tomfennelly", element.getTextContent());
            }
        }, "element");

        StringResult serializedRes = new StringResult();
        smooks.filterSource(new StringSource("<element attrib=\"&amp;tomfennelly\">&amp;tomfennelly</element>"), serializedRes);

        assertEquals("<element attrib=\"&amp;tomfennelly\">&amp;tomfennelly</element>", serializedRes.getResult());
    }
View Full Code Here

    public void test_SAX() {
        Smooks smooks = new Smooks();

        smooks.addVisitor(new MockSAX(), "element");

        StringResult serializedRes = new StringResult();
        smooks.filterSource(new StringSource("<element attrib=\"&amp;tomfennelly\">&amp;tomfennelly</element>"), serializedRes);

        assertEquals("<element attrib=\"&amp;tomfennelly\">&amp;tomfennelly</element>", serializedRes.getResult());
    }
View Full Code Here

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

        StringSource stringSource = new StringSource("<a>aa<b>bbb<c />bbb</b>aaa</a>");
        StringResult stringResult = new StringResult();

        smooks.filterSource(smooks.createExecutionContext(), stringSource, stringResult);
       
        assertEquals(stringSource.getSource(), stringResult.getResult());
        assertTrue(SAXVisitBeforeVisitor.visited);
        assertTrue(SAXVisitAfterAndChildrenVisitor.visited);
        assertTrue(SAXVisitAfterAndChildrenVisitor.onChildElement);
        assertTrue(SAXVisitAfterAndChildrenVisitor.onChildText);
        assertTrue(SAXVisitAfterVisitor.visited);
View Full Code Here

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

        StringSource stringSource = new StringSource("<a>aa<b>bbb<c />bbb</b>aaa</a>");
        StringResult stringResult = new StringResult();

        smooks.filterSource(smooks.createExecutionContext(), stringSource, stringResult);

        // The "default.serialization.on" global param is set to "false" in the config, so
        // nothing should get writen to the result because there are no configured
        // serialization Visitors.
        assertEquals("", stringResult.getResult());
       
        assertTrue(SAXVisitBeforeVisitor.visited);
        assertTrue(SAXVisitAfterVisitor.visited);
    }
View Full Code Here

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

        StringSource stringSource = new StringSource("<a>aa<b>bbb<c />bbb</b>aaa</a>");
        StringResult stringResult = new StringResult();

        smooks.filterSource(smooks.createExecutionContext(), stringSource, stringResult);

        // The "default.serialization.on" global param is set to "false" in the config.
        // There's just a single result writing visitor configured on the "c" element...
        assertEquals("Smooks SAX Transforms!!", stringResult.getResult());

        assertTrue(SAXVisitBeforeVisitor.visited);
        assertTrue(SAXVisitAfterVisitor.visited);
    }
View Full Code Here

        validator.validate();
    }

    public void test_digest_01_simple() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("config_01.xml"));
        StringResult result = new StringResult();

        smooks.filterSource(new StringSource("<a><b/><c/><d/></a>"), result);
        assertEquals("<a><c></c><c></c><d></d></a>", result.getResult());
    }
View Full Code Here

        assertEquals("<a><c></c><c></c><d></d></a>", result.getResult());
    }

    public void test_digest_02_simple_import() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("config_02.xml"));
        StringResult result = new StringResult();

        smooks.filterSource(new StringSource("<a><b/><c/></a>"), result);
        assertEquals("<a><c></c><b></b></a>", result.getResult());
    }
View Full Code Here

    public void test_setClassPath() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("test_setClassLoader_01.xml"));
        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        TestClassLoader classLoader = new TestClassLoader(contextClassLoader);
        StringResult result = new StringResult();

        smooks.setClassLoader(classLoader);

        ExecutionContext execCtx = smooks.createExecutionContext();
        assertTrue(classLoader.requests.contains(JavaContentHandlerFactory.class.getName()));
        assertTrue(contextClassLoader == Thread.currentThread().getContextClassLoader());

        classLoader.requests.clear();
        smooks.filterSource(execCtx, new StringSource("<a/>"), result);
        assertEquals("<b></b>", result.getResult());
        //assertTrue(classLoader.requests.contains(XIncludeParserConfiguration.class.getName()));
        assertTrue(contextClassLoader == Thread.currentThread().getContextClassLoader());
    }
View Full Code Here

        test_config_file("configured_different_node_names", smooks);
    }

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

        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("input-message.jsn")), result);

        assertTrue(XMLUnit.compareXML(StreamUtils.readStreamAsString(getClass().getResourceAsStream("indent-expected.xml")), result.toString()).identical());
    }
View Full Code Here

TOP

Related Classes of org.milyn.payload.StringResult

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.