是否可以为 Citrus 静态响应适配器响应模板应用字典?
Is it possible to apply dictionaries for Citrus static response adapter response template?
我正在使用 Citrus 静态响应适配器来模拟服务,我需要为每个测试用例更改其有效负载中的值。理想情况下,我会考虑为每个测试用例使用字典。有我当前场景的示例:
@Autowired
@Qualifier("checkRegistrationEndpointAdapter")
public StaticResponseEndpointAdapter checkRegistrationEndpointAdapter;
protected void setAdapterResponse(StaticResponseEndpointAdapter adapter, String filenamepath){
URL url = this.getClass().getResource(filenamepath);
String payload = null;
try {
payload = Resources.toString(url, Charsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}
adapter.setMessagePayload(payload);
}
@CitrusTest
public void TestCase02() throws IOException {
http()
.client(CLIENT)
.post()
.payload(new ClassPathResource("templates/thisStartRequestMsg.xml", getClass()))
.dictionary("TC02");
http()
.client(CLIENT)
.response()
.messageType("xml")
.payload(new ClassPathResource("templates/thisStartResponseMsg.xml", getClass()));
action(new AbstractTestAction() {
@Override
public void doExecute(TestContext testContext) {
setAdapterResponse(checkRegistrationEndpointAdapter, "templates/check-registration-v1CheckRegistrationResponseMsg.xml");
}
});
http()
.client(CLIENT)
.response()
.messageType("xml")
.payload(new ClassPathResource("templates/check-registration-v1CheckRegistrationRequestMsg.xml", getClass()))
.dictionary("TC02");
}
如何将字典应用于 setAdapterResponse 方法中设置的负载?
注意:此问题涉及
静态响应适配器目前不支持数据字典。我想知道你为什么在静态响应适配器上投入这么多精力?为什么不使用完整的 Citrus http 服务器功能来接收请求并在测试用例中提供响应?
我正在使用 Citrus 静态响应适配器来模拟服务,我需要为每个测试用例更改其有效负载中的值。理想情况下,我会考虑为每个测试用例使用字典。有我当前场景的示例:
@Autowired
@Qualifier("checkRegistrationEndpointAdapter")
public StaticResponseEndpointAdapter checkRegistrationEndpointAdapter;
protected void setAdapterResponse(StaticResponseEndpointAdapter adapter, String filenamepath){
URL url = this.getClass().getResource(filenamepath);
String payload = null;
try {
payload = Resources.toString(url, Charsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}
adapter.setMessagePayload(payload);
}
@CitrusTest
public void TestCase02() throws IOException {
http()
.client(CLIENT)
.post()
.payload(new ClassPathResource("templates/thisStartRequestMsg.xml", getClass()))
.dictionary("TC02");
http()
.client(CLIENT)
.response()
.messageType("xml")
.payload(new ClassPathResource("templates/thisStartResponseMsg.xml", getClass()));
action(new AbstractTestAction() {
@Override
public void doExecute(TestContext testContext) {
setAdapterResponse(checkRegistrationEndpointAdapter, "templates/check-registration-v1CheckRegistrationResponseMsg.xml");
}
});
http()
.client(CLIENT)
.response()
.messageType("xml")
.payload(new ClassPathResource("templates/check-registration-v1CheckRegistrationRequestMsg.xml", getClass()))
.dictionary("TC02");
}
如何将字典应用于 setAdapterResponse 方法中设置的负载?
注意:此问题涉及
静态响应适配器目前不支持数据字典。我想知道你为什么在静态响应适配器上投入这么多精力?为什么不使用完整的 Citrus http 服务器功能来接收请求并在测试用例中提供响应?