Examples of TestMessageContext


Examples of org.apache.synapse.TestMessageContext

    }

    public static TestMessageContext getTestContextForXSLTMediatorUsingFile(String path, Map props) throws Exception {

        // create a test synapse context
        TestMessageContext synCtx = new TestMessageContext();
        SynapseConfiguration testConfig = new SynapseConfiguration();
        testConfig.setRegistry(new SimpleURLRegistry());

        if (props != null) {
            Iterator iter = props.keySet().iterator();
            while (iter.hasNext()) {
                String key = (String) iter.next();
                testConfig.addEntry(key, (Entry) props.get(key));
            }
        }
        synCtx.setConfiguration(testConfig);

        SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
        OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument();
        omDoc.addChild(envelope);

        //XMLStreamReader parser = XMLInputFactory.newInstance().
        //        createXMLStreamReader(new FileReader(path));
        StAXOMBuilder builder = new StAXOMBuilder(path);

        // set a dummy static message
        OMFactory fac = OMAbstractFactory.getOMFactory();
        envelope.getBody().addChild(fac.createOMText("first text child "));
        envelope.getBody().addChild(builder.getDocumentElement());
        envelope.getBody().addChild(fac.createOMText("second text child "));

        synCtx.setEnvelope(envelope);
        return synCtx;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.