Class BaseTest


  • public class BaseTest
    extends Object
    Since:
    5.7.2
    • Field Detail

      • 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
    • Constructor Detail

      • BaseTest

        public BaseTest()
    • Method Detail

      • doBefore

        public void doBefore()
      • doAfter

        public void doAfter()
      • getBaseURL

        protected String getBaseURL()
      • getRestApiUrl

        protected String getRestApiUrl()
      • getServiceFor

        protected com.sun.jersey.api.client.WebResource getServiceFor​(String username,
                                                                      String password)
        Returns a WebResource to 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 a WebResource to 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
      • getClientBuilder

        protected JerseyClientHelper.ApacheHttpClientBuilder getClientBuilder()
        Can be overridden in subclasses to configure the Apache HTTP client, typically by setting a custom connection timeout with:
         @Override
         protected ApacheHttpClientBuilder getClientBuilder() {
             return super.getClientBuilder().setConnectionRequestTimeout(100000)
                                            .setConnectTimeout(100000)
                                            .setSocketTimeout(100000);
         }
         
         
        Since:
        2023.7
      • 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:
        IOException
        com.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.JsonProcessingException
        IOException
        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)
      • getEntries

        protected List<com.fasterxml.jackson.databind.JsonNode> getEntries​(com.fasterxml.jackson.databind.JsonNode node)
      • getErrorMessage

        protected String getErrorMessage​(com.fasterxml.jackson.databind.JsonNode node)
        Since:
        7.1
      • 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 a MultivaluedMap filled 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 a MultivaluedMap filled with the given simple values.
        Since:
        11.1
      • multiOf

        protected javax.ws.rs.core.MultivaluedMap<String,​String> multiOf​(Map<String,​String> map)
        Builds and returns a MultivaluedMap filled with the given simple values.
        Since:
        11.1