Package org.milyn.payload

Examples of org.milyn.payload.StringSource


    }

    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
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.
View Full Code Here

*/
public class DynamicVisitorTest extends TestCase {
   
    public void test() {
        Smooks smooks = new Smooks();
        StringSource source = new StringSource("<a><b><c>c1</c><d>c2</d><e>c3</e></b></a>");

        SmooksUtil.registerResource(new SmooksResourceConfiguration("b", DynamicVisitorLoader.class.getName()), smooks);
        smooks.filterSource(source);

        assertEquals("<b><c>c1</c><d>c2</d><e>c3</e></b>", DynamicVisitorLoader.visitor.stuff.toString());
View Full Code Here

    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

    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

        // Add a DOM-only visitor
        smooks.addVisitor(new ProcessorVisitor1(), "a");

        try {
            smooks.filterSource(new StringSource("<a/>"));
            fail("Expected SmooksException.");
        } catch (SmooksException e) {
            assertEquals("The configured Filter ('SAX') cannot be used with the specified set of Smooks visitors.  The 'DOM' Filter is the only filter that can be used for this set of Visitors.  Turn on Debug logging for more information.", e.getMessage());
        }
    }
View Full Code Here

        // Add a SAX-only visitor
        smooks.addVisitor(new SAXVisitor01(), "a");

        try {
            smooks.filterSource(new StringSource("<a/>"));
            fail("Expected SmooksException.");
        } catch (SmooksException e) {
            assertEquals("The configured Filter ('DOM') cannot be used with the specified set of Smooks visitors.  The 'SAX' Filter is the only filter that can be used for this set of Visitors.  Turn on Debug logging for more information.", e.getMessage());
        }
    }
View Full Code Here

        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

        TestDOMVisitorAfter visitor2 = new TestDOMVisitorAfter();

        smooks.addVisitor(visitor1, "c/xxx");
        smooks.addVisitor(visitor2, "c");

        smooks.filterSource(new StringSource("<a><xxx/><xxx/><c><xxx/><xxx/></c></a>"));

        assertEquals(2, visitor1.callCount);
        assertEquals(1, visitor2.callCount);
    }
View Full Code Here

TOP

Related Classes of org.milyn.payload.StringSource

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.