For a component test with Citrus Framework I simulate a backend system that is called through SOAP.
<citrus-ws:server id="backendSimulationServer"
port="8080"
auto-start="true"
interceptors="serverInterceptors"
timeout="5000"/>
I get SOAP requests from the component and send back responses.
runner.receive(action -> action.endpoint("backendSimulationServer")
.name("search-request")
.payload(new ClassPathResource("testfiles/search-request-expectation.xml"))
);
runner.send(action -> action.endpoint("backendSimulationServer")
.name("search-response")
.payload(new ClassPathResource("testfiles/search-response.xml"))
);
But now I have to answer to a request with an MTOM attachment response. I found the citrus example that uses .attachment
on a soap().client()
, but .attachment
is not available for my server simulation.
Is this possible with Java DSL or do I re-write the testcase in XML DSL to achieve this?
Both SOAP attachment and MTOM enabled methods are also available on server components in Citrus. This should do the trick for you:
soap().server(soapMtomServer)
.send()
.mtomEnabled(true)
.attachment("IMAGE", "application/octet-stream", new ClassPathResource("com/consol/citrus/hugeImageData.png"))
.payload("<image:addImage xmlns:image=\"http://www.citrusframework.org/imageService/\">" +
"<image>cid:IMAGE</image>" +
"</image:addImage>");