spring-framework / org.springframework.test.web.servlet.htmlunit / DelegatingWebConnection

DelegatingWebConnection

class DelegatingWebConnection : 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); 

Author
Rob Winch

Author
Sam Brannen

Since
4.2

Constructors

<init>

DelegatingWebConnection(defaultConnection: WebConnection, connections: MutableList<DelegateWebConnection>)
DelegatingWebConnection(defaultConnection: WebConnection, vararg connections: DelegateWebConnection)

Functions

close

fun close(): Unit

getResponse

fun getResponse(request: WebRequest): WebResponse