Can I use Citrus variable in Citrus static response adapter payload?(我可以在 Citrus 静态响应适配器有效负载中使用 Citrus 变量吗?)
问题描述
我正在使用静态响应端点适配器返回从资源文件中获取的模拟服务响应:
I am using static response endpoint adapter to return a mock service response taken from a resource file:
private void setAdapterResponse(StaticResponseEndpointAdapter adapter, String response) throws IOException{
URL url = Resources.getResource(response);
adapter.setMessagePayload(Resources.toString(url, Charsets.UTF_8));
}
@Autowired
private Endpoint helloSoapClient;
@Autowired
private WebServiceServer helloMockService;
@Autowired
private StaticResponseEndpointAdapter helloResponseAdapter;
@CitrusTest(name = "HELLO_WORLD")
public void sendAndReceiveMessage() throws IOException{
variable("randomRequestIdentifier", "9978111203033");
variable("constantDate", "201301010000");
setAdapterResponse(helloResponseAdapter, "templates/helloResponses/ReqIdGenerator.xml");
send(helloSoapClient)
.payload(new ClassPathResource("templates/helloRequests/HelloRequest028.xml"));
receive(helloSoapClient)
.payload(new ClassPathResource("templates/helloResponses/HelloResponse028.xml"));
}
private void setAdapterResponse(StaticResponseEndpointAdapter adapter, String response) throws IOException{
URL url = Resources.getResource(response);
adapter.setMessagePayload(Resources.toString(url, Charsets.UTF_8));
}
文件templates/helloResponses/ReqIdGenerator.xml 内容为:
the file templates/helloResponses/ReqIdGenerator.xml contents is:
<xml>
<id>${randomRequestIdentifier}</id>
</xml>
我认为应该将变量替换为其当前值.我错了吗?是否有内置机制来支持 Citrus 端点响应中的变量?
I thought that variable should be replaced with its current value. Am I wrong? Is there a build-in mechanism to support variables in Citrus Endpoint Responses?
推荐答案
目前静态响应适配器和端点适配器一般不支持测试变量.
The static response adapter and endpoint adapters in general do not support test variables at the moment.
编辑:从 Citrus 2.6.2 开始,您可以在静态响应适配器中使用测试变量.请参阅此处的文档:http://www.citrusframework.org/reference/html/endpoint-adapter.html#static-response-endpoint-adapter
这篇关于我可以在 Citrus 静态响应适配器有效负载中使用 Citrus 变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我可以在 Citrus 静态响应适配器有效负载中使用


- 转换 ldap 日期 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 获取数字的最后一位 2022-01-01