}
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;
}