我正在从https://github.com/tomakehurst/wiremock/tree/master/sample-war实现此项目的servlet上运行Wiremock,>
我能够将其部署到Tomcat中并正常工作。
现在,我想在此服务器上启用Response Templating,以便可以使用车把模板来调整响应正文。我看到了一些与Junit规则有关的解决方案,directly setting this up from the code以及来自独立服务器的解决方案,但是都找不到从Servlet启用响应模板的解决方案。
如何从Wiremock Servlet启用它?
我正在通过https://github.com/tomakehurst/wiremock/tree/master/sample-war在实现该项目的servlet上运行Wiremock,我能够将其部署到Tomcat中并工作。现在,我要...
好吧,终于找到了答案,您需要创建扩展ServletContextListener的自定义列表器,然后以编程方式设置响应模板。
[如果您想在docker上使用Wiremock,我这里有一个示例docker-compose.yaml,其中包含详细的日志记录和模板。
我通过扩展和覆盖WireMockWebContextListener