本文整理了Java中com.gargoylesoftware.htmlunit.WebClient.getPage()
方法的一些代码示例,展示了WebClient.getPage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.getPage()
方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.WebClient
类名称:WebClient
方法名:getPage
[英]Convenient method to load a web request into the current top WebWindow.
[中]将web请求加载到当前顶部web窗口的便捷方法。
代码示例来源:origin: spring-projects/spring-framework
@Test
public void verifyExampleInClassLevelJavadoc() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
WebClient webClient = new WebClient();
MockMvc mockMvc = MockMvcBuilders.standaloneSetup().build();
MockMvcWebConnection mockConnection = new MockMvcWebConnection(mockMvc, webClient);
WebRequestMatcher cdnMatcher = new UrlRegexRequestMatcher(".*?//code.jquery.com/.*");
WebConnection httpConnection = new HttpWebConnection(webClient);
webClient.setWebConnection(
new DelegatingWebConnection(mockConnection, new DelegateWebConnection(cdnMatcher, httpConnection)));
Page page = webClient.getPage("http://code.jquery.com/jquery-1.11.0.min.js");
assertThat(page.getWebResponse().getStatusCode(), equalTo(200));
assertThat(page.getWebResponse().getContentAsString(), not(isEmptyString()));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = INTEGRATION)
@SpecAssertion(section = FIELDS_INITIALIZER_METHODS_EE, id = "br")
public void testFilterInitCalledAfterResourceInjection() throws Exception {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(true);
webClient.getPage(contextPath + "TestFilter?test=resource");
webClient.getPage(contextPath + "TestFilter?test=ejb");
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = INTEGRATION)
@SpecAssertion(section = FIELDS_INITIALIZER_METHODS_EE, id = "bo")
public void testServletInitCalledAfterResourceInjection() throws Exception {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(true);
webClient.getPage(contextPath + "Test/Servlet?test=resource");
webClient.getPage(contextPath + "Test/Servlet?test=ejb");
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Runs the sanity check.
* @throws Exception if anything goes wrong
*/
private static void runSanityCheck() throws Exception {
try (WebClient webClient = new WebClient()) {
final HtmlPage page = webClient.getPage("http://htmlunit.sourceforge.net/index.html");
page.executeJavaScript("document.location");
System.out.println("Sanity check complete.");
}
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertion(section = CONVERSATION_CONTEXT_EE, id = "bd")
public void testLifecycleEventFired() throws Exception {
WebClient webClient = new WebClient();
// Begin new long-running conversation
TextPage page = webClient.getPage(contextPath + "test?action=begin");
assertTrue(page.getContent().contains("cid:" + ConversationScopedBean.CID));
// Invalidate HTTP session - destroy non-attached long-running conversation
page = webClient.getPage(contextPath + "test?action=invalidate");
// Get the info
page = webClient.getPage(contextPath + "test?action=info");
assertTrue(page.getContent().contains("destroyed cid:" + ConversationScopedBean.CID));
}
代码示例来源:origin: weld/core
public static JsonObject getPageAsJSONObject(String path, URL url, WebClient client) throws IOException {
if (client == null) {
client = new WebClient();
}
JsonReader jsonReader = Json.createReader(client.getPage(url.toString().concat(path)).getWebResponse().getContentAsStream());
return jsonReader.readObject();
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = INTEGRATION)
@SpecAssertion(section = SESSION_CONTEXT_EE, id = "ae")
public void testSessionScopeActiveDuringServletRequestListenerCall() throws Exception {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(true);
// Create session
webClient.getPage(contextPath + "introspect");
// Invalidate session
webClient.getPage(contextPath + "introspect?mode=invalidate");
// Verify result
TextPage page = webClient.getPage(contextPath + "introspect?mode=verify");
assertTrue(Boolean.valueOf(page.getContent()));
}
代码示例来源:origin: weld/core
@Test
public void testOnStartAsyncCalledSuccesfully() throws Exception {
WebClient webClient = new WebClient();
webClient.getPage(getPath(AsyncServlet.TEST_LOOP));
Page results = webClient.getPage(contextPath + "Status");
assertTrue(results.getWebResponse().getContentAsString().contains("onComplete: true"));
assertTrue(results.getWebResponse().getContentAsString().contains("onStartAsync: true"));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "ga")
public void testInitializedApplicationScopedEventObserved() throws IOException {
WebClient client = new WebClient();
TextPage page1 = client.getPage(context + "/" + TEST1_ARCHIVE_NAME + "/ping");
TextPage page2 = client.getPage(context + "/" + TEST2_ARCHIVE_NAME + "/ping");
Assert.assertTrue(page1.getContent().toString().contains(ObserverNames.OBSERVER2_NAME));
Assert.assertTrue(page2.getContent().toString().contains(ObserverNames.OBSERVER3_NAME));
}
}
代码示例来源:origin: weld/core
@Test
@Ignore //enable when WELD-1774 is fixed
public void testOnErrorCalledSuccesfully() throws Exception {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.getPage(getPath(AsyncServlet.TEST_ERROR));
Page results = webClient.getPage(contextPath + "Status");
assertTrue(results.getWebResponse().getContentAsString(), results.getWebResponse().getContentAsString().contains("onError: true"));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test
@SpecAssertion(section = OBSERVER_ORDERING, id = "b")
public void testContextLifecycleEventOrdering() throws IOException {
WebClient client = new WebClient();
TextPage page = client.getPage(contextPath);
Assert.assertTrue(page.getContent().toString().contains("Initialized observer sequence: " + seq));
TextPage page2 = client.getPage(contextPath);
Assert.assertTrue(page2.getContent().toString().contains("Initialized observer sequence: " + seq + seq));
Assert.assertTrue(page2.getContent().toString().contains("Destroyed observer sequence: " + seq));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = {INTEGRATION, ASYNC_SERVLET})
@SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "ae")
public void testApplicationContextActiveOnComplete() throws Exception {
WebClient webClient = new WebClient();
// make async request
webClient.getPage(getPath(AsyncServlet.TEST_COMPLETE));
// check the status servlet results
TextPage results = webClient.getPage(contextPath + "Status");
assertTrue(results.getContent().contains("onComplete: true"));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = {INTEGRATION, ASYNC_SERVLET})
@SpecAssertion(section = REQUEST_CONTEXT_EE, id = "ad")
public void testRequestContextActiveOnStartAsync() throws Exception {
WebClient webClient = new WebClient();
webClient.getPage(getPath(AsyncServlet.TEST_LOOP));
TextPage results = webClient.getPage(contextPath + "Status");
assertTrue(results.getContent().contains("onStartAsync: true"));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = {INTEGRATION, ASYNC_SERVLET})
@SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "ae")
public void testApplicationContextActiveOnStartAsync() throws Exception {
WebClient webClient = new WebClient();
webClient.getPage(getPath(AsyncServlet.TEST_LOOP));
TextPage results = webClient.getPage(contextPath + "Status");
assertTrue(results.getContent().contains("onStartAsync: true"));
assertTrue(results.getContent().contains("onComplete: true"));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = {INTEGRATION, ASYNC_SERVLET})
@SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "ae")
public void testApplicationContextActiveOnTimeout() throws Exception {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.getPage(getPath(AsyncServlet.TEST_TIMEOUT));
TextPage results = webClient.getPage(contextPath + "Status");
assertTrue(results.getContent().contains("onTimeout: true"));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = INTEGRATION)
@SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "aa")
public void testApplicationScopeActiveDuringServiceMethod() throws Exception {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(true);
webClient.getPage(contextPath + "TestServlet?test=servlet");
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = INTEGRATION)
@SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "af")
public void testApplicationScopeActiveDuringServletRequestListenerInvocation() throws Exception {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(true);
webClient.getPage(contextPath + "TestServlet?test=servletRequestListener");
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = {INTEGRATION, ASYNC_SERVLET})
@SpecAssertion(section = REQUEST_CONTEXT_EE, id = "ad")
public void testRequestContextActiveOnError() throws Exception {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.getPage(getPath(AsyncServlet.TEST_ERROR));
TextPage results = webClient.getPage(contextPath + "Status");
assertTrue(results.getContent().contains("onError: true"));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = {INTEGRATION, ASYNC_SERVLET})
@SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "ae")
public void testApplicationContextActiveOnError() throws Exception {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.getPage(getPath(AsyncServlet.TEST_ERROR));
TextPage results = webClient.getPage(contextPath + "Status");
assertTrue(results.getContent().contains("onError: true"));
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Test(groups = INTEGRATION)
@SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "ab")
public void testApplicationScopeActiveDuringDoFilterMethod() throws Exception {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(true);
webClient.getPage(contextPath + "SimplePage.html");
}
内容来源于网络,如有侵权,请联系作者删除!