Package org.opennms.core.test.rest
Class AbstractSpringJerseyRestTestCase
- java.lang.Object
-
- org.opennms.core.test.rest.AbstractSpringJerseyRestTestCase
-
- Direct Known Subclasses:
AbstractSpringJerseyRestJsonTestCase
public abstract class AbstractSpringJerseyRestTestCase extends Object
- Author:
- Mathew Brozowski
-
-
Field Summary
Fields Modifier and Type Field Description static String
ACCEPT
static String
contextPath
static String
CXF_REST_V1_CONTEXT_PATH
static String
CXF_REST_V2_CONTEXT_PATH
static String
DELETE
static String
GET
static String
POST
static String
PUT
protected javax.servlet.ServletContext
servletContext
protected org.springframework.web.context.WebApplicationContext
webApplicationContext
-
Constructor Summary
Constructors Constructor Description AbstractSpringJerseyRestTestCase()
AbstractSpringJerseyRestTestCase(String cxfContextPath)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
afterServletDestroy()
By default, don't do anything.protected void
afterServletStart()
By default, don't do anything.protected void
beforeServletDestroy()
By default, don't do anything.protected void
beforeServletStart()
By default, don't do anything.protected static void
cleanUpImports()
protected void
createCategory()
protected void
createIpInterface()
protected void
createNode()
protected void
createNode(int statusCode)
protected org.springframework.mock.web.MockHttpServletRequest
createRequest(String requestType, String urlPath)
protected static org.springframework.mock.web.MockHttpServletRequest
createRequest(javax.servlet.ServletContext context, String requestType, String urlPath)
protected static org.springframework.mock.web.MockHttpServletRequest
createRequest(javax.servlet.ServletContext context, String requestType, String urlPath, String username, Collection<String> roles)
protected static org.springframework.mock.web.MockHttpServletRequest
createRequest(javax.servlet.ServletContext context, String requestType, String urlPath, Map<String,String> parameterMap, String username, Collection<String> roles)
protected static org.springframework.mock.web.MockHttpServletResponse
createResponse()
protected void
createService()
protected void
createSnmpInterface()
protected void
dispatch(org.springframework.mock.web.MockHttpServletRequest request, org.springframework.mock.web.MockHttpServletResponse response)
org.springframework.web.context.ContextLoaderListener
getContextListener()
javax.servlet.http.HttpServlet
getDispatcher()
javax.servlet.Filter
getFilter()
protected <T> T
getJsonObject(org.codehaus.jackson.map.ObjectMapper mapper, String url, Map<String,String> parameterMap, int expectedStatus, Class<T> expectedClass)
protected static String
getQueryString(Map<?,?> parameters)
org.springframework.mock.web.MockServletConfig
getServletConfig()
protected static String
getUser()
protected static Collection<String>
getUserRoles()
protected <T> T
getXmlObject(JAXBContext context, String url, int expectedStatus, Class<T> expectedClass)
protected <T> T
getXmlObject(JAXBContext context, String url, Map<String,String> parameterMap, int expectedStatus, Class<T> expectedClass)
protected static Map<String,String>
parseParamData(String data)
protected void
putXmlObject(JAXBContext context, String url, int expectedStatus, Object object)
protected org.springframework.mock.web.MockHttpServletResponse
sendData(String requestType, String contentType, String url, String data, int statusCode)
protected org.springframework.mock.web.MockHttpServletResponse
sendPost(String url, String xml, int statusCode)
protected org.springframework.mock.web.MockHttpServletResponse
sendPost(String url, String xml, int statusCode, String expectedUrlSuffix)
protected org.springframework.mock.web.MockHttpServletResponse
sendPut(String url, String formData, int statusCode)
protected org.springframework.mock.web.MockHttpServletResponse
sendPut(String url, String formData, int statusCode, String expectedUrlSuffix)
protected String
sendRequest(String requestType, String url, int expectedStatus)
protected String
sendRequest(String requestType, String url, Map<?,?> parameters, int expectedStatus)
protected String
sendRequest(String requestType, String url, Map<?,?> parameters, int expectedStatus, String expectedUrlSuffix)
protected String
sendRequest(org.springframework.mock.web.MockHttpServletRequest request, int expectedStatus)
protected String
sendRequest(org.springframework.mock.web.MockHttpServletRequest request, int expectedStatus, String expectedUrlSuffix)
void
setContextListener(org.springframework.web.context.ContextLoaderListener contextListener)
void
setDispatcher(javax.servlet.http.HttpServlet dispatcher)
void
setFilter(javax.servlet.Filter filter)
void
setServletConfig(org.springframework.mock.web.MockServletConfig servletConfig)
void
setUp()
protected static void
setUser(String user, String[] roles)
protected String
stringifyResponse(org.springframework.mock.web.MockHttpServletResponse response)
void
tearDown()
-
-
-
Field Detail
-
CXF_REST_V1_CONTEXT_PATH
public static final String CXF_REST_V1_CONTEXT_PATH
- See Also:
- Constant Field Values
-
CXF_REST_V2_CONTEXT_PATH
public static final String CXF_REST_V2_CONTEXT_PATH
- See Also:
- Constant Field Values
-
GET
public static String GET
-
POST
public static String POST
-
DELETE
public static String DELETE
-
PUT
public static String PUT
-
ACCEPT
public static String ACCEPT
-
contextPath
public static String contextPath
-
servletContext
@Autowired protected javax.servlet.ServletContext servletContext
-
webApplicationContext
@Autowired protected org.springframework.web.context.WebApplicationContext webApplicationContext
-
-
Constructor Detail
-
AbstractSpringJerseyRestTestCase
public AbstractSpringJerseyRestTestCase()
-
AbstractSpringJerseyRestTestCase
public AbstractSpringJerseyRestTestCase(String cxfContextPath)
-
-
Method Detail
-
cleanUpImports
protected static void cleanUpImports()
-
beforeServletStart
protected void beforeServletStart() throws Exception
By default, don't do anything.- Throws:
Exception
-
afterServletStart
protected void afterServletStart() throws Exception
By default, don't do anything.- Throws:
Exception
-
beforeServletDestroy
protected void beforeServletDestroy() throws Exception
By default, don't do anything.- Throws:
Exception
-
afterServletDestroy
protected void afterServletDestroy() throws Exception
By default, don't do anything.- Throws:
Exception
-
dispatch
protected void dispatch(org.springframework.mock.web.MockHttpServletRequest request, org.springframework.mock.web.MockHttpServletResponse response) throws Exception
- Throws:
Exception
-
createRequest
protected org.springframework.mock.web.MockHttpServletRequest createRequest(String requestType, String urlPath)
-
createResponse
protected static org.springframework.mock.web.MockHttpServletResponse createResponse()
-
createRequest
protected static org.springframework.mock.web.MockHttpServletRequest createRequest(javax.servlet.ServletContext context, String requestType, String urlPath)
-
createRequest
protected static org.springframework.mock.web.MockHttpServletRequest createRequest(javax.servlet.ServletContext context, String requestType, String urlPath, Map<String,String> parameterMap, String username, Collection<String> roles)
-
createRequest
protected static org.springframework.mock.web.MockHttpServletRequest createRequest(javax.servlet.ServletContext context, String requestType, String urlPath, String username, Collection<String> roles)
-
getUser
protected static String getUser()
-
getUserRoles
protected static Collection<String> getUserRoles()
-
sendPost
protected org.springframework.mock.web.MockHttpServletResponse sendPost(String url, String xml, int statusCode) throws Exception
- Throws:
Exception
-
sendPost
protected org.springframework.mock.web.MockHttpServletResponse sendPost(String url, String xml, int statusCode, String expectedUrlSuffix) throws Exception
- Throws:
Exception
-
sendPut
protected org.springframework.mock.web.MockHttpServletResponse sendPut(String url, String formData, int statusCode) throws Exception
- Parameters:
url
-formData
-statusCode
-expectedUrlSuffix
-- Throws:
Exception
-
sendPut
protected org.springframework.mock.web.MockHttpServletResponse sendPut(String url, String formData, int statusCode, String expectedUrlSuffix) throws Exception
- Parameters:
url
-formData
-statusCode
-expectedUrlSuffix
-- Throws:
Exception
-
sendData
protected org.springframework.mock.web.MockHttpServletResponse sendData(String requestType, String contentType, String url, String data, int statusCode) throws Exception
- Parameters:
requestType
-contentType
-url
-data
-statusCode
-- Throws:
Exception
-
stringifyResponse
protected String stringifyResponse(org.springframework.mock.web.MockHttpServletResponse response)
-
parseParamData
protected static Map<String,String> parseParamData(String data) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
sendRequest
protected String sendRequest(String requestType, String url, Map<?,?> parameters, int expectedStatus) throws Exception
- Throws:
Exception
-
sendRequest
protected String sendRequest(String requestType, String url, Map<?,?> parameters, int expectedStatus, String expectedUrlSuffix) throws Exception
- Throws:
Exception
-
sendRequest
protected String sendRequest(String requestType, String url, int expectedStatus) throws Exception
- Throws:
Exception
-
sendRequest
protected String sendRequest(org.springframework.mock.web.MockHttpServletRequest request, int expectedStatus) throws Exception, UnsupportedEncodingException
-
sendRequest
protected String sendRequest(org.springframework.mock.web.MockHttpServletRequest request, int expectedStatus, String expectedUrlSuffix) throws Exception, UnsupportedEncodingException
-
getJsonObject
protected <T> T getJsonObject(org.codehaus.jackson.map.ObjectMapper mapper, String url, Map<String,String> parameterMap, int expectedStatus, Class<T> expectedClass) throws Exception
- Throws:
Exception
-
getXmlObject
protected <T> T getXmlObject(JAXBContext context, String url, Map<String,String> parameterMap, int expectedStatus, Class<T> expectedClass) throws Exception
- Throws:
Exception
-
getXmlObject
protected <T> T getXmlObject(JAXBContext context, String url, int expectedStatus, Class<T> expectedClass) throws Exception
- Throws:
Exception
-
putXmlObject
protected void putXmlObject(JAXBContext context, String url, int expectedStatus, Object object) throws Exception
- Throws:
Exception
-
setContextListener
public void setContextListener(org.springframework.web.context.ContextLoaderListener contextListener)
-
getContextListener
public org.springframework.web.context.ContextLoaderListener getContextListener()
-
setServletConfig
public void setServletConfig(org.springframework.mock.web.MockServletConfig servletConfig)
-
getServletConfig
public org.springframework.mock.web.MockServletConfig getServletConfig()
-
setFilter
public void setFilter(javax.servlet.Filter filter)
-
getFilter
public javax.servlet.Filter getFilter()
-
setDispatcher
public void setDispatcher(javax.servlet.http.HttpServlet dispatcher)
-
getDispatcher
public javax.servlet.http.HttpServlet getDispatcher()
-
-