I am trying to mock a html which includes frames using wiremock. These html files on resources/html folder. The html class is below,
<!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>
What I was trying to do is:
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);
}
and what I get it:
So my question is, how can I add these frames on Wiremock?

Aucun commentaire:
Enregistrer un commentaire