Package org.milyn.container

Examples of org.milyn.container.ExecutionContext


*/
public class ContentDeliveryConfigBuilderTest extends TestCase {

    public void test_sax() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-sax.xml"));
        ExecutionContext execContext = smooks.createExecutionContext();

        assertTrue(execContext.getDeliveryConfig() instanceof SAXContentDeliveryConfig);
        SAXContentDeliveryConfig config = (SAXContentDeliveryConfig) execContext.getDeliveryConfig();

        // Should be 5: 4 configured + 2 auto-installed
        assertEquals(7, config.getVisitBefores().getCount());
        assertTrue(config.getVisitBefores().getMappings("b").get(0).getContentHandler() instanceof SAXVisitor01);
        assertTrue(config.getVisitBefores().getMappings("b").get(0).getContentHandler() instanceof SAXVisitor01);
View Full Code Here


        assertTrue(config.getVisitAfters().getMappings("b").get(0).getContentHandler() instanceof SAXVisitor01);
    }

    public void test_dom() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-dom.xml"));
        ExecutionContext execContext = smooks.createExecutionContext();

        assertTrue(execContext.getDeliveryConfig() instanceof DOMContentDeliveryConfig);
        DOMContentDeliveryConfig config = (DOMContentDeliveryConfig) execContext.getDeliveryConfig();

        assertEquals(1, config.getAssemblyVisitBefores().getCount());
        assertEquals(1, config.getAssemblyVisitAfters().getCount());
        assertEquals(2, config.getProcessingVisitBefores().getCount());
        assertEquals(2, config.getProcessingVisitAfters().getCount());
View Full Code Here

        assertEquals(4, config.getSerailizationVisitors().getCount());
    }

    public void test_dom_sax_1() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-dom-sax-1.xml"));
        ExecutionContext execContext = smooks.createExecutionContext();

        // Should default to SAX
        assertTrue(execContext.getDeliveryConfig() instanceof SAXContentDeliveryConfig);
    }
View Full Code Here

        assertTrue(execContext.getDeliveryConfig() instanceof SAXContentDeliveryConfig);
    }

    public void test_dom_sax_2() throws IOException, SAXException {
        Smooks smooks;
        ExecutionContext execContext;

        smooks = new Smooks(getClass().getResourceAsStream("smooks-config-dom-sax-2.1.xml"));
        execContext = smooks.createExecutionContext();
        assertTrue(execContext.getDeliveryConfig() instanceof SAXContentDeliveryConfig);

        smooks = new Smooks(getClass().getResourceAsStream("smooks-config-dom-sax-2.2.xml"));
        execContext = smooks.createExecutionContext();
        assertTrue(execContext.getDeliveryConfig() instanceof DOMContentDeliveryConfig);

        smooks = new Smooks(getClass().getResourceAsStream("smooks-config-dom-sax-2.3.xml"));
        try {
            smooks.createExecutionContext();
            fail("Expected SmooksException");
View Full Code Here

    public void test_dom_sax_3() throws IOException, SAXException {
        String origDefault = System.setProperty(Filter.STREAM_FILTER_TYPE, StreamFilterType.DOM.toString());

        try {
            Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config-dom-sax-1.xml"));
            ExecutionContext execContext = smooks.createExecutionContext();

            // Should default to DOM
            assertTrue(execContext.getDeliveryConfig() instanceof DOMContentDeliveryConfig);
        } finally {
            if(origDefault != null) {
                System.setProperty(Filter.STREAM_FILTER_TYPE, origDefault);
            } else {
                System.getProperties().remove(Filter.STREAM_FILTER_TYPE);
View Full Code Here

    public ElementVisitEvent(Object element, ContentHandlerConfigMap configMapping, VisitSequence sequence) {
        super(element);
        this.configMapping = configMapping;
        this.sequence = sequence;
        ExecutionContext executionContext = Filter.getCurrentExecutionContext();
        try {
            executionContextState = MultiLineToStringBuilder.toString(executionContext);

        } catch (Exception e) {
            StringWriter exceptionWriter = new StringWriter();
View Full Code Here

        }
    }

    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...
        SmooksResourceConfiguration config = configList.get(0);
View Full Code Here

        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...
        SmooksResourceConfiguration config = configList.get(0);
View Full Code Here

    protected static String runSmooksTransform() throws IOException, SAXException, SmooksException {

        Smooks smooks = new Smooks("smooks-config.xml");

        try {
            ExecutionContext executionContext = smooks.createExecutionContext();
            StringWriter writer = new StringWriter();

            // Configure the execution context to generate a report...
            executionContext.setEventListener(new HtmlReportGenerator("target/report/report.html"));

            smooks.filterSource(executionContext, new StreamSource(new InputStreamReader(new ByteArrayInputStream(messageIn), "UTF-8")), new StreamResult(writer));

            return writer.toString();
        } finally {
View Full Code Here

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

TOP

Related Classes of org.milyn.container.ExecutionContext

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.