use of org.apache.synapse.config.xml.HeaderMediatorFactory in project wso2-synapse by wso2.
the class HeaderMediatorTest method testEmbeddedXml.
public void testEmbeddedXml() throws Exception {
String simpleHeader = "<header name=\"m:simpleHeader\" value=\"Simple Header\" xmlns:m=\"http://org.synapse.example\"/>";
String complexHeader = "<header><m:complexHeader xmlns:m=\"http://org.synapse.example\"><property key=\"k1\" value=\"v1\"/><property key=\"k2\" value=\"v2\"/></m:complexHeader></header>";
String removeHeader = "<header name=\"m:complexHeader\" action=\"remove\" xmlns:m=\"http://org.synapse.example\"/>";
HeaderMediatorFactory fac = new HeaderMediatorFactory();
try {
// Adding headers.
MessageContext synCtx = TestUtils.getTestContext("<empty/>");
HeaderMediator headerMediator = (HeaderMediator) fac.createMediator(AXIOMUtil.stringToOM(simpleHeader), new Properties());
headerMediator.mediate(synCtx);
headerMediator = (HeaderMediator) fac.createMediator(AXIOMUtil.stringToOM(complexHeader), new Properties());
headerMediator.mediate(synCtx);
// Removing headers.
headerMediator = (HeaderMediator) fac.createMediator(AXIOMUtil.stringToOM(removeHeader), new Properties());
headerMediator.mediate(synCtx);
} catch (XMLStreamException e) {
fail("Error while parsing header mediator configuration: inline XML scenario. " + e.getMessage());
}
}
Aggregations