Class DelegatingWebConnection
java.lang.Object
org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection
- All Implemented Interfaces:
AutoCloseable
,org.htmlunit.WebConnection
Implementation of
WebConnection
that allows delegating to various
WebConnection
implementations.
For example, if you host your JavaScript on the domain code.jquery.com
,
you might want to use the following.
WebClient webClient = new WebClient(); MockMvc mockMvc = ... MockMvcWebConnection mockConnection = new MockMvcWebConnection(mockMvc, 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); WebClient webClient = new WebClient(); webClient.setWebConnection(webConnection);
- Since:
- 4.2
- Author:
- Rob Winch, Sam Brannen
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
The delegate web connection. -
Constructor Summary
ConstructorDescriptionDelegatingWebConnection
(org.htmlunit.WebConnection defaultConnection, List<DelegatingWebConnection.DelegateWebConnection> connections) DelegatingWebConnection
(org.htmlunit.WebConnection defaultConnection, DelegatingWebConnection.DelegateWebConnection... connections) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
org.htmlunit.WebResponse
getResponse
(org.htmlunit.WebRequest request)
-
Constructor Details
-
DelegatingWebConnection
public DelegatingWebConnection(org.htmlunit.WebConnection defaultConnection, List<DelegatingWebConnection.DelegateWebConnection> connections) -
DelegatingWebConnection
public DelegatingWebConnection(org.htmlunit.WebConnection defaultConnection, DelegatingWebConnection.DelegateWebConnection... connections)
-
-
Method Details
-
getResponse
- Specified by:
getResponse
in interfaceorg.htmlunit.WebConnection
- Throws:
IOException
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceorg.htmlunit.WebConnection
-