org.springframework.test.web.servlet.phpunit

Class DelegatingWebConnection

  • java.lang.Object
    • org.springframework.test.web.servlet.phpunit.DelegatingWebConnection
  • All Implemented Interfaces:
    com.gargoylesoftware.phpunit.WebConnection, java.lang.AutoCloseable


    public final class DelegatingWebConnection
    extends java.lang.Object
    implements com.gargoylesoftware.phpunit.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
    • Method Detail

      • getResponse

        public com.gargoylesoftware.phpunit.WebResponse getResponse(com.gargoylesoftware.phpunit.WebRequest request)
                                                              throws java.io.IOException
        Specified by:
        getResponse in interface com.gargoylesoftware.phpunit.WebConnection
        Throws:
        java.io.IOException
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable