Package org.milyn

Examples of org.milyn.Smooks


    protected void setUp() throws Exception {
        ModelCatcher.elements.clear();
    }

    public void test_sax_01() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("node-model-01.xml"));

        smooks.setFilterSettings(FilterSettings.DEFAULT_SAX);

        ExecutionContext executionContext = smooks.createExecutionContext();
        smooks.filterSource(executionContext, new StreamSource(getClass().getResourceAsStream("order-message.xml")), null);

        DOMModel nodeModel = DOMModel.getModel(executionContext);

        assertTrue(
                StreamUtils.compareCharStreams(
View Full Code Here


public class ExportsFunctionalTest
{
    @Test
    public void multipleExportTypes() throws Exception
    {
        Smooks smooks = new Smooks("/org/milyn/payload/exports-01.xml");
        smooks.createExecutionContext();

        Exports exports = Exports.getExports(smooks.getApplicationContext());

        Set<Class<?>> resultTypes = exports.getResultTypes();
        assertTrue(resultTypes.contains(StringResult.class));
        assertTrue(resultTypes.contains(JavaResult.class));
    }
View Full Code Here

        assertTrue(SAXVisitBeforeVisitor.visited);
        assertTrue(SAXVisitAfterVisitor.visited);
    }

    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());
View Full Code Here

* @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a>
*/
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

        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

        smooks.filterSource(new StringSource("<a><b/><c/><d/></a>"), result);
        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

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

    public void test_digest_03_simple_invalid_condition() throws IOException, SAXException {
        try {
            new Smooks(getClass().getResourceAsStream("config_03.xml"));
            fail("Expected SmooksConfigurationException");
        } catch (SmooksConfigurationException e) {
            assertEquals("Failed to construct Smooks instance for processing extended configuration resource '/META-INF/xsd/smooks/test-xsd-03.xsd-smooks.xml'.", e.getMessage());
            assertEquals("Configuration element 'conditions' not supported in an extension configuration.", e.getCause().getMessage());
        }
View Full Code Here

        }
    }

    public void test_digest_04_simple_invalid_profiles() throws IOException, SAXException {
        try {
            new Smooks(getClass().getResourceAsStream("config_04.xml"));
            fail("Expected SmooksConfigurationException");
        } catch (SmooksConfigurationException e) {
            assertEquals("Failed to construct Smooks instance for processing extended configuration resource '/META-INF/xsd/smooks/test-xsd-04.xsd-smooks.xml'.", e.getMessage());
            assertEquals("Configuration element 'profiles' not supported in an extension configuration.", e.getCause().getMessage());
        }
View Full Code Here

            assertEquals("Configuration element 'profiles' not supported in an extension configuration.", e.getCause().getMessage());
        }
    }

    public void test_digest_05_simple_default_1() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("config_05.1.xml"));
        ExecutionContext execContext;
        ContentDeliveryConfig deliveryConf;
        List<SmooksResourceConfiguration> configList;

        // config_05.1.xml defines a default profile of "xxx", so creating the context without specifying
        // a profile should exclude the "aa" resource...
        execContext = smooks.createExecutionContext();
        deliveryConf = execContext.getDeliveryConfig();
        configList = deliveryConf.getSmooksResourceConfigurations("aa");
        assertNull(configList);

        // config_05.1.xml defines a default profile of "xxx", so creating the context by specifying
        // a profile of "xxx" should include the "aa" resource...
        execContext = smooks.createExecutionContext("xxx");
        deliveryConf = execContext.getDeliveryConfig();
        configList = deliveryConf.getSmooksResourceConfigurations("aa");
        assertNotNull(configList);

        // Make sure the resource has the other default settings...
View Full Code Here

        assertEquals("http://an", config.getSelectorNamespaceURI());
        assertNotNull(config.getConditionEvaluator());
    }

    public void test_digest_05_simple_default_2() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("config_05.2.xml"));
        ExecutionContext execContext;
        ContentDeliveryConfig deliveryConf;
        List<SmooksResourceConfiguration> configList;

        // config_05.2.xml defines a name attribute, so that should override the default...
        execContext = smooks.createExecutionContext("xxx");
        deliveryConf = execContext.getDeliveryConfig();
        configList = deliveryConf.getSmooksResourceConfigurations("j");
        assertNotNull(configList);

        // Make sure the resource has the other default settings...
View Full Code Here

TOP

Related Classes of org.milyn.Smooks

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.