com.gargoylesoftware.htmlunit.HttpWebConnection Java Examples
The following examples show how to use
com.gargoylesoftware.htmlunit.HttpWebConnection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DelegatingWebConnectionTests.java From spring-analysis-note with MIT License | 6 votes |
@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("https://code.jquery.com/jquery-1.11.0.min.js"); assertThat(page.getWebResponse().getStatusCode(), equalTo(200)); assertThat(page.getWebResponse().getContentAsString(), not(isEmptyString())); }
Example #2
Source File: DelegatingWebConnectionTests.java From java-technology-stack with MIT License | 6 votes |
@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())); }
Example #3
Source File: HtmlFileInput2Test.java From htmlunit with Apache License 2.0 | 6 votes |
/** * Helper that does some nasty magic. */ private static HttpEntity post(final WebClient client, final MockWebConnection webConnection) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { final Method makeHttpMethod = HttpWebConnection.class.getDeclaredMethod("makeHttpMethod", WebRequest.class, HttpClientBuilder.class); makeHttpMethod.setAccessible(true); final HttpWebConnection con = new HttpWebConnection(client); final Method getHttpClientBuilderMethod = HttpWebConnection.class.getDeclaredMethod("getHttpClientBuilder"); getHttpClientBuilderMethod.setAccessible(true); final HttpClientBuilder builder = (HttpClientBuilder) getHttpClientBuilderMethod.invoke(con); final HttpPost httpPost = (HttpPost) makeHttpMethod.invoke(con, webConnection.getLastWebRequest(), builder); final HttpEntity httpEntity = httpPost.getEntity(); return httpEntity; }
Example #4
Source File: DelegatingWebConnectionTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void verifyExampleInClassLevelJavadoc() throws Exception { Assume.group(TestGroup.PERFORMANCE); WebClient webClient = new WebClient(); MockMvc mockMvc = MockMvcBuilders.standaloneSetup(TestController.class).build(); MockMvcWebConnection mockConnection = new MockMvcWebConnection(mockMvc); mockConnection.setWebClient(webClient); WebRequestMatcher cdnMatcher = new UrlRegexRequestMatcher(".*?//code.jquery.com/.*"); WebConnection httpConnection = new HttpWebConnection(webClient); WebConnection webConnection = new DelegatingWebConnection(mockConnection, new DelegateWebConnection(cdnMatcher, httpConnection)); webClient.setWebConnection(webConnection); 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())); }