spring-test-mvc-htmlunit

org.springframework.test.web.servlet.htmlunit
Class MockMvcWebConnection

java.lang.Object
  extended by org.springframework.test.web.servlet.htmlunit.MockMvcWebConnection
All Implemented Interfaces:
com.gargoylesoftware.htmlunit.WebConnection

public final class MockMvcWebConnection
extends java.lang.Object
implements com.gargoylesoftware.htmlunit.WebConnection

Allows MockMvc to transform a WebRequest into a WebResponse. This is the core integration with HTML Unit.

Example usage can be seen below:

 MockMvc mockMvc = ...
 MockMvcWebConnection webConnection = new MockMvcWebConnection(mockMvc);
 WebClient webClient = new WebClient();
 webClient.setWebConnection(webConnection);

 ... use webClient as normal ...
 

Currently the WebConnection assumes that the first path segment is the context root of the application. For example, the URL http://localhost/context/test/this would use /context as the context root.

Author:
Rob Winch
See Also:
MockMvcHtmlUnitDriver, GebSpecTestExecutionListener

Constructor Summary
MockMvcWebConnection(org.springframework.test.web.servlet.MockMvc mockMvc)
           
 
Method Summary
 com.gargoylesoftware.htmlunit.WebResponse getResponse(com.gargoylesoftware.htmlunit.WebRequest webRequest)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockMvcWebConnection

public MockMvcWebConnection(org.springframework.test.web.servlet.MockMvc mockMvc)
Method Detail

getResponse

public com.gargoylesoftware.htmlunit.WebResponse getResponse(com.gargoylesoftware.htmlunit.WebRequest webRequest)
                                                      throws java.io.IOException
Specified by:
getResponse in interface com.gargoylesoftware.htmlunit.WebConnection
Throws:
java.io.IOException

spring-test-mvc-htmlunit