com.gargoylesoftware.htmlunit.WebClient.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(178)

本文整理了Java中com.gargoylesoftware.htmlunit.WebClient.<init>()方法的一些代码示例,展示了WebClient.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.<init>()方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.WebClient
类名称:WebClient
方法名:<init>

WebClient.<init>介绍

[英]Creates a web client instance using the browser version returned by BrowserVersion#getDefault().
[中]使用BrowserVersion#getDefault()返回的浏览器版本创建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
  @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: 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: 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 = 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: 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 = 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: 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(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: 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(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
@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: 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");
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@Test(groups = INTEGRATION)
@SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "ac")
public void testApplicationScopeActiveDuringServletContextListenerInvocation() throws Exception {
  WebClient webClient = new WebClient();
  webClient.setThrowExceptionOnFailingStatusCode(true);
  webClient.getPage(contextPath + "TestServlet?test=servletContextListener");
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@Test(groups = { INTEGRATION, PERSISTENCE })
@SpecAssertion(section = FIELDS_INITIALIZER_METHODS_EE, id = "br")
public void testFilterInitCalledAfterPersistenceResourceInjection() throws Exception {
  WebClient webClient = new WebClient();
  webClient.setThrowExceptionOnFailingStatusCode(true);
  webClient.getPage(contextPath + "TestFilter?test=persistence");
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@Test
@SpecAssertion(section = ACTIVATING_REQUEST_CONTEXT, id = "db")
public void requestContextCannotBeActivatedTwice() throws Exception {
  WebClient webClient = new WebClient();
  TextPage results = webClient.getPage(contextPath + "test");
  assertTrue(results.getContent().contains("Activated: false"));
  assertTrue(results.getContent().contains("Active: true"));
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@Test(groups = INTEGRATION)
@SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "ad")
public void testApplicationScopeActiveDuringHttpSessionListenerInvocation() throws Exception {
  WebClient webClient = new WebClient();
  webClient.setThrowExceptionOnFailingStatusCode(true);
  webClient.getPage(contextPath + "TestServlet?test=httpSessionListener");
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@Test(groups = { INTEGRATION, PERSISTENCE })
@SpecAssertion(section = FIELDS_INITIALIZER_METHODS_EE, id = "bo")
public void testServletInitCalledAfterPersistenceResourceInjection() throws Exception {
  WebClient webClient = new WebClient();
  webClient.setThrowExceptionOnFailingStatusCode(true);
  webClient.getPage(contextPath + "Test/Servlet?test=persistence");
}

代码示例来源: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"));
}

相关文章

微信公众号

最新文章

更多

WebClient类方法