我正在使用 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方法中的有效负载集?注意:这个问题与Can I use Citrus variable in Citrus static response adapter payload 有关吗?