use of com.gargoylesoftware.htmlunit.WebResponse in project spring-boot by spring-projects.
the class LocalHostWebClientTests method mockConnection.
private WebConnection mockConnection() throws MalformedURLException, IOException {
WebConnection connection = mock(WebConnection.class);
WebResponse response = new StringWebResponse("test", new URL("http://localhost"));
given(connection.getResponse((WebRequest) any())).willReturn(response);
return connection;
}
use of com.gargoylesoftware.htmlunit.WebResponse in project sling by apache.
the class MetricWebConsolePluginTest method webConsolePlugin.
@Test
public void webConsolePlugin() throws Exception {
MetricRegistry reg1 = new MetricRegistry();
reg1.meter("test1").mark(5);
reg1.timer("test2").time().close();
reg1.histogram("test3").update(743);
reg1.counter("test4").inc(9);
reg1.registerAll(new JvmAttributeGaugeSet());
context.registerService(MetricRegistry.class, reg1, regProps("foo"));
activatePlugin();
StringWriter sw = new StringWriter();
HttpServletResponse response = mock(HttpServletResponse.class);
when(response.getWriter()).thenReturn(new PrintWriter(sw));
plugin.doGet(mock(HttpServletRequest.class), response);
WebClient client = new WebClient();
WebResponse resp = new StringWebResponse(sw.toString(), WebClient.URL_ABOUT_BLANK);
HtmlPage page = HTMLParser.parseHtml(resp, client.getCurrentWindow());
assertTable("data-meters", page);
assertTable("data-counters", page);
assertTable("data-timers", page);
assertTable("data-histograms", page);
assertTable("data-gauges", page);
}
Aggregations