Citrus-Framework:可以使用Java DSL从服务器模拟发送SOAP附件吗?

时间:2018-01-15 14:04:53

标签: simulation mtom citrus-framework

对于 Citrus Framework 的组件测试,我模拟通过 SOAP 调用的后端系统

<citrus-ws:server id="backendSimulationServer"
                port="8080"
                auto-start="true"
                interceptors="serverInterceptors"
                timeout="5000"/>

我从组件获取SOAP请求并发回响应。

    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"))
    );

但现在我必须使用 MTOM附件回复回复请求。我发现在.attachment上使用soap().client()的柑橘示例,但 .attachment不可用用于我的服务器模拟。

这是可以使用Java DSL还是我在XML DSL中重写测试用例来实现这一目标?

1 个答案:

答案 0 :(得分:0)

Citrus中的服务器组件也可以使用SOAP附件和启用MTOM的方法。这应该适合你:

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>");