Package org.nuxeo.ecm.restapi.test
Class BaseTest
- java.lang.Object
-
- org.nuxeo.ecm.restapi.test.BaseTest
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classBaseTest.RequestType
-
Field Summary
Fields Modifier and Type Field Description protected com.sun.jersey.api.client.Clientclientprotected com.fasterxml.jackson.databind.ObjectMappermapperprotected com.sun.jersey.api.client.WebResourceserviceprotected ServletContainerFeatureservletContainerFeatureCoreSessionsession
-
Constructor Summary
Constructors Constructor Description BaseTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassertEntityEqualsDoc(InputStream in, DocumentModel doc)protected voidassertNodeEqualsDoc(com.fasterxml.jackson.databind.JsonNode node, DocumentModel note)voiddoAfter()voiddoBefore()protected voidfetchInvalidations()Fetch session invalidations.protected StringgetBaseURL()protected StringgetErrorMessage(com.fasterxml.jackson.databind.JsonNode node)protected List<com.fasterxml.jackson.databind.JsonNode>getLogEntries(com.fasterxml.jackson.databind.JsonNode node)protected CloseableClientResponsegetResponse(BaseTest.RequestType requestType, String path)protected CloseableClientResponsegetResponse(BaseTest.RequestType requestType, String path, com.sun.jersey.multipart.MultiPart mp)protected CloseableClientResponsegetResponse(BaseTest.RequestType requestType, String path, com.sun.jersey.multipart.MultiPart mp, Map<String,String> headers)protected CloseableClientResponsegetResponse(BaseTest.RequestType requestType, String path, String data)protected CloseableClientResponsegetResponse(BaseTest.RequestType requestType, String path, String data, Map<String,String> headers)protected CloseableClientResponsegetResponse(BaseTest.RequestType requestType, String path, String data, javax.ws.rs.core.MultivaluedMap<String,String> queryParams, com.sun.jersey.multipart.MultiPart mp, Map<String,String> headers, String... acceptedTypes)protected CloseableClientResponsegetResponse(BaseTest.RequestType requestType, String path, Map<String,String> headers)protected CloseableClientResponsegetResponse(BaseTest.RequestType requestType, String path, javax.ws.rs.core.MultivaluedMap<String,String> queryParams)protected com.fasterxml.jackson.databind.JsonNodegetResponseAsJson(BaseTest.RequestType responseType, String url)protected com.fasterxml.jackson.databind.JsonNodegetResponseAsJson(BaseTest.RequestType responseType, String url, javax.ws.rs.core.MultivaluedMap<String,String> queryParams)protected StringgetRestApiUrl()protected com.sun.jersey.api.client.WebResourcegetServiceFor(String username, String password)Returns aWebResourceto perform REST API calls with the given credentials.protected com.sun.jersey.api.client.WebResourcegetServiceFor(String resource, String username, String password)Returns aWebResourceto perform calls on the given resource with the given credentials.protected booleanhasErrorMessage(com.fasterxml.jackson.databind.JsonNode node)protected javax.ws.rs.core.MultivaluedMap<String,String>multiOf(String k1, String v1)Builds and returns aMultivaluedMapfilled with the given simple values.protected javax.ws.rs.core.MultivaluedMap<String,String>multiOf(String k1, String v1, String k2, String v2)Builds and returns aMultivaluedMapfilled with the given simple values.protected javax.ws.rs.core.MultivaluedMap<String,String>multiOf(Map<String,String> map)Builds and returns aMultivaluedMapfilled with the given simple values.protected voidsetJSONContentTypeIfAbsent(com.sun.jersey.api.client.WebResource.Builder builder, Map<String,String> headers)
-
-
-
Field Detail
-
servletContainerFeature
@Inject protected ServletContainerFeature servletContainerFeature
-
mapper
protected com.fasterxml.jackson.databind.ObjectMapper mapper
-
client
protected com.sun.jersey.api.client.Client client
-
service
protected com.sun.jersey.api.client.WebResource service
-
session
@Inject public CoreSession session
-
-
Constructor Detail
-
BaseTest
public BaseTest()
-
-
Method Detail
-
getBaseURL
protected String getBaseURL()
-
getRestApiUrl
protected String getRestApiUrl()
-
getServiceFor
protected com.sun.jersey.api.client.WebResource getServiceFor(String username, String password)
Returns aWebResourceto perform REST API calls with the given credentials.Since 9.3, uses the Apache HTTP client, more reliable and much more configurable than the one from the JDK.
- Since:
- 5.7.3
-
getServiceFor
protected com.sun.jersey.api.client.WebResource getServiceFor(String resource, String username, String password)
Returns aWebResourceto perform calls on the given resource with the given credentials.Uses the Apache HTTP client, more reliable and much more configurable than the one from the JDK.
- Since:
- 9.3
-
getResponse
protected CloseableClientResponse getResponse(BaseTest.RequestType requestType, String path)
-
getResponse
protected CloseableClientResponse getResponse(BaseTest.RequestType requestType, String path, Map<String,String> headers)
-
getResponse
protected CloseableClientResponse getResponse(BaseTest.RequestType requestType, String path, com.sun.jersey.multipart.MultiPart mp)
-
getResponse
protected CloseableClientResponse getResponse(BaseTest.RequestType requestType, String path, com.sun.jersey.multipart.MultiPart mp, Map<String,String> headers)
-
getResponse
protected CloseableClientResponse getResponse(BaseTest.RequestType requestType, String path, javax.ws.rs.core.MultivaluedMap<String,String> queryParams)
-
getResponse
protected CloseableClientResponse getResponse(BaseTest.RequestType requestType, String path, String data)
-
getResponse
protected CloseableClientResponse getResponse(BaseTest.RequestType requestType, String path, String data, Map<String,String> headers)
-
getResponse
protected CloseableClientResponse getResponse(BaseTest.RequestType requestType, String path, String data, javax.ws.rs.core.MultivaluedMap<String,String> queryParams, com.sun.jersey.multipart.MultiPart mp, Map<String,String> headers, String... acceptedTypes)
-
setJSONContentTypeIfAbsent
protected void setJSONContentTypeIfAbsent(com.sun.jersey.api.client.WebResource.Builder builder, Map<String,String> headers)
- Since:
- 9.3
-
getResponseAsJson
protected com.fasterxml.jackson.databind.JsonNode getResponseAsJson(BaseTest.RequestType responseType, String url) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
getResponseAsJson
protected com.fasterxml.jackson.databind.JsonNode getResponseAsJson(BaseTest.RequestType responseType, String url, javax.ws.rs.core.MultivaluedMap<String,String> queryParams) throws com.fasterxml.jackson.core.JsonProcessingException, IOException
- Throws:
com.fasterxml.jackson.core.JsonProcessingExceptionIOException- Since:
- 5.8
-
fetchInvalidations
protected void fetchInvalidations()
Fetch session invalidations.- Since:
- 5.9.3
-
assertNodeEqualsDoc
protected void assertNodeEqualsDoc(com.fasterxml.jackson.databind.JsonNode node, DocumentModel note) throws Exception
- Throws:
Exception
-
getLogEntries
protected List<com.fasterxml.jackson.databind.JsonNode> getLogEntries(com.fasterxml.jackson.databind.JsonNode node)
-
getErrorMessage
protected String getErrorMessage(com.fasterxml.jackson.databind.JsonNode node)
- Since:
- 7.1
-
assertEntityEqualsDoc
protected void assertEntityEqualsDoc(InputStream in, DocumentModel doc) throws Exception
- Throws:
Exception
-
hasErrorMessage
protected boolean hasErrorMessage(com.fasterxml.jackson.databind.JsonNode node)
- Since:
- 11.1
-
multiOf
protected javax.ws.rs.core.MultivaluedMap<String,String> multiOf(String k1, String v1)
Builds and returns aMultivaluedMapfilled with the given simple values.- Since:
- 11.1
-
multiOf
protected javax.ws.rs.core.MultivaluedMap<String,String> multiOf(String k1, String v1, String k2, String v2)
Builds and returns aMultivaluedMapfilled with the given simple values.- Since:
- 11.1
-
-