public final class DelegatingWebConnection
extends java.lang.Object
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);
Modifier and Type | Class and Description |
---|---|
static class |
DelegatingWebConnection.DelegateWebConnection |
Modifier and Type | Field and Description |
---|---|
private java.util.List<DelegatingWebConnection.DelegateWebConnection> |
connections |
private WebConnection |
defaultConnection |
Constructor and Description |
---|
DelegatingWebConnection(WebConnection defaultConnection,
DelegatingWebConnection.DelegateWebConnection... connections) |
DelegatingWebConnection(WebConnection defaultConnection,
java.util.List<DelegatingWebConnection.DelegateWebConnection> connections) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
WebResponse |
getResponse(WebRequest request) |
private final java.util.List<DelegatingWebConnection.DelegateWebConnection> connections
private final WebConnection defaultConnection
public DelegatingWebConnection(WebConnection defaultConnection, java.util.List<DelegatingWebConnection.DelegateWebConnection> connections)
public DelegatingWebConnection(WebConnection defaultConnection, DelegatingWebConnection.DelegateWebConnection... connections)