Class DelegatingWebConnection
- java.lang.Object
- org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection
- All Implemented Interfaces:
com.gargoylesoftware.htmlunit.WebConnection,AutoCloseable
public final class DelegatingWebConnection extends Object implements com.gargoylesoftware.htmlunit.WebConnection
Implementation ofWebConnectionthat allows delegating to variousWebConnectionimplementations.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
Nested Classes Modifier and Type Class Description static classDelegatingWebConnection.DelegateWebConnection
Constructor Summary
Constructors Constructor Description DelegatingWebConnection(com.gargoylesoftware.htmlunit.WebConnection defaultConnection, List<DelegatingWebConnection.DelegateWebConnection> connections)DelegatingWebConnection(com.gargoylesoftware.htmlunit.WebConnection defaultConnection, DelegatingWebConnection.DelegateWebConnection... connections)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()com.gargoylesoftware.htmlunit.WebResponsegetResponse(com.gargoylesoftware.htmlunit.WebRequest request)
Constructor Detail
DelegatingWebConnection
public DelegatingWebConnection(com.gargoylesoftware.htmlunit.WebConnection defaultConnection, List<DelegatingWebConnection.DelegateWebConnection> connections)
DelegatingWebConnection
public DelegatingWebConnection(com.gargoylesoftware.htmlunit.WebConnection defaultConnection, DelegatingWebConnection.DelegateWebConnection... connections)
Method Detail
getResponse
public com.gargoylesoftware.htmlunit.WebResponse getResponse(com.gargoylesoftware.htmlunit.WebRequest request) throws IOException
- Specified by:
getResponsein interfacecom.gargoylesoftware.htmlunit.WebConnection- Throws:
IOException
close
public void close()
- Specified by:
closein interfaceAutoCloseable