net.sf.javaprinciples
Class ServletSupport

java.lang.Object
  extended by net.sf.javaprinciples.ServletSupport

public class ServletSupport
extends Object


Field Summary
protected  javax.servlet.ServletConfig config
           
static String CONTEXT_PATH
           
protected  org.springframework.web.servlet.FrameworkServlet d
           
static String UNIT_CORRELATIONID
           
static String UNIT_LOCALID
           
 
Constructor Summary
ServletSupport()
           
 
Method Summary
 void assertResponse(org.springframework.mock.web.MockHttpServletResponse response, String filename)
          Assert the response content against the content in the supplied file.
 void assertResponseToContent(org.springframework.mock.web.MockHttpServletResponse response, String expectedResponseContent)
          Assert the response content against the content in the supplied file.
 org.springframework.mock.web.MockHttpServletRequest createMockGetRequest(String uri)
           
 org.springframework.mock.web.MockHttpServletRequest createMockPostRequest(String uri)
           
 org.springframework.mock.web.MockHttpServletRequest createMockPutRequest(String uri)
           
 org.springframework.mock.web.MockHttpServletRequest createMockRequest(String uri, String httpMethod)
           
 org.springframework.mock.web.MockHttpServletResponse dispatch(javax.servlet.http.HttpServletRequest request)
           
static String documentToString(Document xmlDocument)
           
 org.springframework.web.context.WebApplicationContext getWebApplicationContext()
           
 byte[] loadContent(String filename)
          Load content from the specified file using the classloader.
static Document loadXmlDocument(String pathToResource)
           
 void setFrameworkServlet(org.springframework.web.servlet.FrameworkServlet dispatcher)
           
 void setup(org.springframework.context.ApplicationContext applicationContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNIT_LOCALID

public static final String UNIT_LOCALID
See Also:
Constant Field Values

UNIT_CORRELATIONID

public static final String UNIT_CORRELATIONID
See Also:
Constant Field Values

CONTEXT_PATH

public static final String CONTEXT_PATH
See Also:
Constant Field Values

config

protected javax.servlet.ServletConfig config

d

protected org.springframework.web.servlet.FrameworkServlet d
Constructor Detail

ServletSupport

public ServletSupport()
Method Detail

setFrameworkServlet

public void setFrameworkServlet(org.springframework.web.servlet.FrameworkServlet dispatcher)

setup

public void setup(org.springframework.context.ApplicationContext applicationContext)
           throws javax.servlet.ServletException
Throws:
javax.servlet.ServletException

getWebApplicationContext

public org.springframework.web.context.WebApplicationContext getWebApplicationContext()

createMockPostRequest

public org.springframework.mock.web.MockHttpServletRequest createMockPostRequest(String uri)

createMockGetRequest

public org.springframework.mock.web.MockHttpServletRequest createMockGetRequest(String uri)

createMockPutRequest

public org.springframework.mock.web.MockHttpServletRequest createMockPutRequest(String uri)

createMockRequest

public org.springframework.mock.web.MockHttpServletRequest createMockRequest(String uri,
                                                                             String httpMethod)

loadContent

public byte[] loadContent(String filename)
Load content from the specified file using the classloader.

Parameters:
filename -
Returns:

assertResponse

public void assertResponse(org.springframework.mock.web.MockHttpServletResponse response,
                           String filename)
Assert the response content against the content in the supplied file.

Parameters:
response - The mock response containing the byte data.
filename - The name of the file containing the expectation.

assertResponseToContent

public void assertResponseToContent(org.springframework.mock.web.MockHttpServletResponse response,
                                    String expectedResponseContent)
Assert the response content against the content in the supplied file.

Parameters:
response - The mock response containing the byte data.
expectedResponseContent - The expected content of the given response.

dispatch

public org.springframework.mock.web.MockHttpServletResponse dispatch(javax.servlet.http.HttpServletRequest request)
                                                              throws javax.servlet.ServletException,
                                                                     IOException
Throws:
javax.servlet.ServletException
IOException

loadXmlDocument

public static Document loadXmlDocument(String pathToResource)
                                throws SAXException,
                                       IOException,
                                       ParserConfigurationException
Throws:
SAXException
IOException
ParserConfigurationException

documentToString

public static String documentToString(Document xmlDocument)
                               throws TransformerFactoryConfigurationError,
                                      TransformerException
Throws:
TransformerFactoryConfigurationError
TransformerException


Copyright © 2013. All Rights Reserved.