}
public static TestMessageContext getTestContextForXSLTMediator(String bodyText, Map props) throws Exception {
// create a test synapse context
TestMessageContext synCtx = new TestMessageContext();
SynapseConfiguration testConfig = new SynapseConfiguration();
testConfig.setRegistry(new SimpleURLRegistry());
SynapseEnvironment testEnv = new Axis2SynapseEnvironment(new ConfigurationContext(new AxisConfiguration()), testConfig);
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);
synCtx.setEnvironment(testEnv);
SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument();
omDoc.addChild(envelope);
XMLStreamReader parser = XMLInputFactory.newInstance().
createXMLStreamReader(new StringReader(bodyText));
StAXOMBuilder builder = new StAXOMBuilder(parser);
// 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;
}