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

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

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

WebClient.setWebConnection介绍

[英]Sets the object that will resolve all URL requests.
[中]设置将解析所有URL请求的对象。

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Set the {@link WebConnection} to be used with the {@link WebClient}.
 * @param webConnection the {@code WebConnection} to use
 */
public void setWebConnection(WebConnection webConnection) {
  Assert.notNull(webConnection, "WebConnection must not be null");
  getWebClient().setWebConnection(webConnection);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Supply the {@code WebClient} that the client {@linkplain #build built}
 * by this builder should delegate to when processing
 * non-{@linkplain WebRequestMatcher matching} requests.
 * @param webClient the {@code WebClient} to delegate to for requests
 * that do not match; never {@code null}
 * @return this builder for further customization
 * @see #build()
 */
public MockMvcWebClientBuilder withDelegate(WebClient webClient) {
  Assert.notNull(webClient, "WebClient must not be null");
  webClient.setWebConnection(createConnection(webClient));
  this.webClient = webClient;
  return this;
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void contextPathNull() throws IOException {
  this.webClient.setWebConnection(new MockMvcWebConnection(this.mockMvc, this.webClient));
  Page page = this.webClient.getPage("http://localhost/context/a");
  assertThat(page.getWebResponse().getStatusCode(), equalTo(200));
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void contextPathEmpty() throws IOException {
  this.webClient.setWebConnection(new MockMvcWebConnection(this.mockMvc, this.webClient, ""));
  Page page = this.webClient.getPage("http://localhost/context/a");
  assertThat(page.getWebResponse().getStatusCode(), equalTo(200));
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void contextPathExplicit() throws IOException {
  this.webClient.setWebConnection(new MockMvcWebConnection(this.mockMvc, this.webClient, "/context"));
  Page page = this.webClient.getPage("http://localhost/context/a");
  assertThat(page.getWebResponse().getStatusCode(), equalTo(200));
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void forward() throws IOException {
  this.webClient.setWebConnection(new MockMvcWebConnection(this.mockMvc, this.webClient, ""));
  Page page = this.webClient.getPage("http://localhost/forward");
  assertThat(page.getWebResponse().getContentAsString(), equalTo("hello"));
}

代码示例来源: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: apache/servicemix-bundles

/**
 * Set the {@link WebConnection} to be used with the {@link WebClient}.
 * @param webConnection the {@code WebConnection} to use
 */
public void setWebConnection(WebConnection webConnection) {
  Assert.notNull(webConnection, "WebConnection must not be null");
  this.webClient.setWebConnection(webConnection);
}

代码示例来源:origin: net.disy.htmlunit/htmlunit

/**
 * Constructs a WebConnection object wrapping the connection of the WebClient and places itself as
 * connection of the WebClient.
 * @param webClient the WebClient which WebConnection should be wrapped
 * @throws IllegalArgumentException if the WebClient is <code>null</code>
 */
public WebConnectionWrapper(final WebClient webClient) throws IllegalArgumentException {
  if (webClient == null) {
    throw new IllegalArgumentException("WebClient can't be null");
  }
  wrappedWebConnection_ = webClient.getWebConnection();
  webClient.setWebConnection(this);
}

代码示例来源:origin: net.sourceforge.htmlunit/htmlunit

/**
 * Constructs a WebConnection object wrapping the connection of the WebClient and places itself as
 * connection of the WebClient.
 * @param webClient the WebClient which WebConnection should be wrapped
 * @throws IllegalArgumentException if the WebClient is {@code null}
 */
public WebConnectionWrapper(final WebClient webClient) throws IllegalArgumentException {
  if (webClient == null) {
    throw new IllegalArgumentException("WebClient can't be null");
  }
  wrappedWebConnection_ = webClient.getWebConnection();
  webClient.setWebConnection(this);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test

/**
 * Set the {@link WebConnection} to be used with the {@link WebClient}.
 * @param webConnection the {@code WebConnection} to use
 */
public void setWebConnection(WebConnection webConnection) {
  Assert.notNull(webConnection, "WebConnection must not be null");
  getWebClient().setWebConnection(webConnection);
}

代码示例来源:origin: org.jenkins-ci/htmlunit

/**
 * Constructs a WebConnection object wrapping the connection of the WebClient and places itself as
 * connection of the WebClient.
 * @param webClient the WebClient which WebConnection should be wrapped
 * @throws IllegalArgumentException if the WebClient is <code>null</code>
 */
public WebConnectionWrapper(final WebClient webClient) throws IllegalArgumentException {
  if (webClient == null) {
    throw new IllegalArgumentException("WebClient can't be null");
  }
  wrappedWebConnection_ = webClient.getWebConnection();
  webClient.setWebConnection(this);
}

代码示例来源:origin: org.jvnet.hudson/htmlunit

/**
 * Constructs a WebConnection object wrapping the connection of the WebClient and places itself as
 * connection of the WebClient.
 * @param webClient the WebClient which WebConnection should be wrapped
 * @throws IllegalArgumentException if the WebClient is <code>null</code>
 */
public WebConnectionWrapper(final WebClient webClient) throws IllegalArgumentException {
  if (webClient == null) {
    throw new IllegalArgumentException("WebClient can't be null");
  }
  wrappedWebConnection_ = webClient.getWebConnection();
  webClient.setWebConnection(this);
}

代码示例来源:origin: com.github.seykron/htmlunit-maven-plugin

/** {@inheritDoc}
 */
@Override
protected WebClient modifyWebClient(final WebClient theClient) {
 theClient.setWebConnection(createConnectionWrapper(theClient));
 initializeWebClientConfiguration(theClient);
 configureWebClient(theClient);
 return theClient;
};

代码示例来源:origin: com.github.searls/jasmine-maven-plugin

@Override
 protected HtmlPage initialValue() {
  MockWebConnection webConnection = new MockWebConnection();
  WebClient webClient = new WebClient();
  webClient.setWebConnection(webConnection);
  try {
   HtmlPage page = webClient.getPage(WebClient.URL_ABOUT_BLANK);
   page.executeJavaScript(ioUtilsWrapper.toString("/vendor/js/coffee-script.js"));
   return page;
  } catch (IOException e) {
   throw new RuntimeException(e);
  }
 }
};

代码示例来源:origin: com.github.albfernandez.test-jsf/jsf-test-scriptunit

private void setupWebClient() {
  webClient = new WebClient(browser);
  mockConnection = new MockWebConnection();
  webClient.setWebConnection(mockConnection);
  webClient.setAjaxController(new NicelyResynchronizingAjaxController());
}

代码示例来源:origin: aharin/inproctester

public InProcessHtmlUnitDriver(InProcConnection inProcConnection) {
  getWebClient().setWebConnection(new InProcessWebConnection(inProcConnection, getWebClient().getCookieManager()));
}

代码示例来源:origin: com.thoughtworks.inproctester/inproctester-webdriver

public InProcessHtmlUnitDriver(InProcConnection inProcConnection) {
  getWebClient().setWebConnection(new InProcessWebConnection(inProcConnection, getWebClient().getCookieManager()));
}

代码示例来源:origin: com.thoughtworks.inproctester/jerseytester-webdriver

private void setWebConnection(Client jerseyClient) {
    getWebClient().setWebConnection(new JerseyClientWebConnection(jerseyClient, getWebClient().getCookieManager()));
  }
}

代码示例来源:origin: com.atlassian.confluence/jwebunit-confluence-plugin

@Override
protected WebClient createWebClient() {
  WebClient webClient = new WebClient(GLOBAL_CONFIG.getBrowserVersion());
  webClient.setWebConnection(new ConfluenceWebConnection(webClient, MAX_CONNECTIONS, GLOBAL_CONFIG));
  webClient.setCache(WEBCLIENT_REQUEST_CACHE);
  webClient.getOptions().setTimeout(GLOBAL_CONFIG.getHttpRequestTimeoutMillis());
  webClient.getOptions().setCssEnabled(false);
  webClient.getOptions().setPrintContentOnFailingStatusCode(false);
  return webClient;
}

相关文章

微信公众号

最新文章

更多

WebClient类方法