/** * 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); }
/** * 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; }
@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)); }
@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)); }
@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)); }
@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")); }
@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())); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** {@inheritDoc} */ @Override protected WebClient modifyWebClient(final WebClient theClient) { theClient.setWebConnection(createConnectionWrapper(theClient)); initializeWebClientConfiguration(theClient); configureWebClient(theClient); return theClient; };
@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); } } };
private void setupWebClient() { webClient = new WebClient(browser); mockConnection = new MockWebConnection(); webClient.setWebConnection(mockConnection); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); }
public InProcessHtmlUnitDriver(InProcConnection inProcConnection) { getWebClient().setWebConnection(new InProcessWebConnection(inProcConnection, getWebClient().getCookieManager())); }
public InProcessHtmlUnitDriver(InProcConnection inProcConnection) { getWebClient().setWebConnection(new InProcessWebConnection(inProcConnection, getWebClient().getCookieManager())); }
private void setWebConnection(Client jerseyClient) { getWebClient().setWebConnection(new JerseyClientWebConnection(jerseyClient, getWebClient().getCookieManager())); } }
@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; }