org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection Java Examples

The following examples show how to use org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection. 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 vote down vote up
@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 vote down vote up
@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: DelegatingWebConnectionTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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()));
}
 
Example #4
Source File: MockMvcWebConnectionBuilderSupport.java    From spring-analysis-note with MIT License 5 votes vote down vote up
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);
}
 
Example #5
Source File: DelegatingWebConnectionTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Before
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));
}
 
Example #6
Source File: MockMvcWebConnectionBuilderSupport.java    From java-technology-stack with MIT License 5 votes vote down vote up
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);
}
 
Example #7
Source File: DelegatingWebConnectionTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Before
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));
}
 
Example #8
Source File: DelegatingWebConnectionTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	request = new WebRequest(new URL("http://localhost/"));
	WebResponseData data = new WebResponseData("".getBytes("UTF-8"), 200, "", Collections.<NameValuePair> emptyList());
	expectedResponse = new WebResponse(data, request, 100L);
	webConnection = new DelegatingWebConnection(defaultConnection,
		new DelegateWebConnection(matcher1, connection1), new DelegateWebConnection(matcher2, connection2));
}