【发布时间】:2020-09-22 09:21:35
【问题描述】:
我正在尝试使用wiremock 模拟一个包含框架的html。这些 html 文件位于 resources/html 文件夹中。 html类如下,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<HTML>
<HEAD>
<TITLE>A simple frameset document</TITLE>
</HEAD>
<frameset cols="20%, 80%" rows="100">
<frame id="leftFrame" src="/frame1.html">
<frame id="mainFrame" src="/frame2.html">
</frameset>
</HTML>
我想做的是:
public MockUtils(String folder, String fileName) throws IOException {
wireMockServer = new WireMockServer(options().port(8081));
wireMockServer.stubFor(
get(urlPathMatching("/([a-z]*)"))
.willReturn(
aResponse()
.withBodyFile("framesample.html")
.withBody(prepareResponse(fileName, folder))));
wireMockServer.start();
}
private static String prepareResponse(String path, String folder) throws IOException {
return getResourceAsString(folder + "/" + path);
}
private static String getResourceAsString(String name) throws IOException {
return Resources.toString(Resources.getResource(name), Charsets.UTF_8);
}
我得到了什么:
所以我的问题是,如何在 Wiremock 上添加这些框架?
【问题讨论】:
标签: java html testing frame wiremock