use of org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection in project spring-security by spring-projects.
the class WebTestClientHtmlUnitDriverBuilder method build.
public WebDriver build() {
WebConnectionHtmlUnitDriver driver = new WebConnectionHtmlUnitDriver();
WebClient webClient = driver.getWebClient();
WebTestClientWebConnection webClientConnection = new WebTestClientWebConnection(this.webTestClient, webClient);
WebConnection connection = new DelegatingWebConnection(driver.getWebConnection(), new DelegateWebConnection(new HostRequestMatcher("localhost"), webClientConnection));
driver.setWebConnection(connection);
return driver;
}
use of org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection in project spring-framework by spring-projects.
the class MockMvcWebConnectionBuilderSupport method createConnection.
private WebConnection createConnection(WebClient webClient, WebConnection defaultConnection) {
WebConnection connection = new MockMvcWebConnection(this.mockMvc, webClient, this.contextPath);
if (this.alwaysUseMockMvc) {
return connection;
}
List<DelegateWebConnection> delegates = new ArrayList<>(this.requestMatchers.size());
for (WebRequestMatcher matcher : this.requestMatchers) {
delegates.add(new DelegateWebConnection(matcher, connection));
}
return new DelegatingWebConnection(defaultConnection, delegates);
}
use of org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection in project spring-framework by spring-projects.
the class DelegatingWebConnectionTests method verifyExampleInClassLevelJavadoc.
@Test
@EnabledForTestGroups(LONG_RUNNING)
public void verifyExampleInClassLevelJavadoc() throws Exception {
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()).isEqualTo(200);
assertThat(page.getWebResponse().getContentAsString()).isNotEmpty();
}
use of org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection in project spring-framework by spring-projects.
the class DelegatingWebConnectionTests method setup.
@BeforeEach
public void setup() throws Exception {
request = new WebRequest(new URL("http://localhost/"));
WebResponseData data = new WebResponseData("".getBytes("UTF-8"), 200, "", Collections.emptyList());
expectedResponse = new WebResponse(data, request, 100L);
webConnection = new DelegatingWebConnection(defaultConnection, new DelegateWebConnection(matcher1, connection1), new DelegateWebConnection(matcher2, connection2));
}
Aggregations