Class AbstractWebServicesTest

  • All Implemented Interfaces:
    JaloSessionHolder

    @Deprecated(since="6.0",
                forRemoval=true)
    public abstract class AbstractWebServicesTest
    extends ServicelayerTest
    Deprecated, for removal: This API element is subject to removal in a future version.
    Deprecated since 6.0, use NeedsEmbeddedServer annotation to run embedded server on test class and WsSecuredRequestBuilder or WsRequestBuilder to construct Invocation.Builder that you need to access your web services
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String EMBEDDEDSERVER_HTTP_PORT_CONFIG_KEY
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      static java.lang.String EMBEDDEDSERVER_HTTPS_PORT_CONFIG_KEY
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected static java.lang.String HEADER_AUTH_KEY
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected static java.lang.String HEADER_AUTH_VALUE_PREFIX
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected javax.ws.rs.client.Client jerseyClient
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected javax.ws.rs.client.WebTarget webResource
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      static java.lang.String WS_REQUIRED_CHANNEL_PROPERTY
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      static java.lang.String WS_TEST_OAUTH2_CLIENT_ID_KEY
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      static java.lang.String WS_TEST_OAUTH2_CLIENT_SECRET_KEY
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      static java.lang.String WS_TEST_OAUTH2_CUSTOMER_PASSWORD_KEY
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      static java.lang.String WS_TEST_OAUTH2_CUSTOMER_USERNAME_KEY
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      static java.lang.String WS_TEST_OAUTH2_TOKEN_ENDPOINT_PATH_KEY
      Deprecated, for removal: This API element is subject to removal in a future version.
       
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractWebServicesTest()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected javax.ws.rs.client.Invocation.Builder addAuthorizationHeader​(javax.ws.rs.client.WebTarget webResource, java.lang.String token)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected void assertBadRequest​(javax.ws.rs.core.Response response, boolean expectEmptyBody)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Tests whether the response has status BAD_REQUEST.
      protected void assertCreated​(javax.ws.rs.core.Response response, boolean expectEmptyBody)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Tests whether resource was successfully created.
      protected void assertForbidden​(javax.ws.rs.core.Response response, boolean expectEmptyBody)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Tests whether the response has status FORBIDDEN.
      protected void assertOk​(javax.ws.rs.core.Response response, boolean expectEmptyBody)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Tests whether the response has status OK.
      protected void assertResponseStatus​(javax.ws.rs.core.Response.Status status, javax.ws.rs.core.Response response)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected void assertResponseStatus​(javax.ws.rs.core.Response.Status responseStatus, javax.ws.rs.core.Response response, boolean expectEmptyBody)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Tests whether the response status has expected value.
      protected void assertUnauthorized​(javax.ws.rs.core.Response response, boolean expectEmptyBody)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Tests whether the response has status UNAUTHORIZED.
      protected javax.ws.rs.client.Invocation.Builder authorizeClientUsingClientCredentials​(javax.ws.rs.client.WebTarget webResource)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected javax.ws.rs.client.Invocation.Builder authorizeClientUsingClientCredentials​(javax.ws.rs.client.WebTarget webResource, java.lang.String clientId, java.lang.String clientSecret)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected javax.ws.rs.client.Invocation.Builder authorizeClientUsingResourceOwnerPassword​(javax.ws.rs.client.WebTarget webResource)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected javax.ws.rs.client.Invocation.Builder authorizeClientUsingResourceOwnerPassword​(javax.ws.rs.client.WebTarget webResource, java.lang.String customerName, java.lang.String customerPassword)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected javax.ws.rs.client.Invocation.Builder authorizeClientUsingResourceOwnerPassword​(javax.ws.rs.client.WebTarget webResource, java.lang.String customerName, java.lang.String customerPassword, java.lang.String clientId, java.lang.String clientSecret)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected void beforeEmbeddedServerCreation()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected javax.ws.rs.client.Client createClient​(org.glassfish.jersey.client.ClientConfig config)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Method creates client which accepts all hostname and trust all certificates - because of that it is suitable only for tests
      protected EmbeddedServer createEmbeddedServer()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      void ensureEmbeddedServerIsRunning()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected void ensureWebappIsRunning()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected ExtensionInfo getAuthorizationExtensionInfo()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected java.lang.String getAuthorizationExtensionName()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected EmbeddedServerBuilder getEmbeddedServerBuilder()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      ExtensionInfo getExtensionInfo()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      abstract java.lang.String getExtensionName()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected java.lang.String getOAuth2TokenUsingClientCredentials​(javax.ws.rs.client.WebTarget webResource, java.lang.String clientID, java.lang.String clientSecret)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected java.lang.String getOAuth2TokenUsingResourceOwnerPassword​(javax.ws.rs.client.WebTarget webResource, java.lang.String clientID, java.lang.String clientSecret, java.lang.String customerName, java.lang.String customerPassword)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      static java.lang.String getTokenFromJsonStr​(java.lang.String jsonStr)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected java.lang.String getWebRoot​(ExtensionInfo extensionInfo)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected java.lang.String getWsVersionForExtensionInfo​(ExtensionInfo extensionInfo)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      boolean isUseSSL()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      static <T> T jsonToObj​(java.lang.String jsonStr, java.lang.Class<T> c)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      static java.lang.String objToJson​(java.lang.Object obj)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      void setUp()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      protected javax.ws.rs.client.WebTarget setupWebResource​(ExtensionInfo extensionInfo)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      void setUseSSL​(boolean useSSL)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      static void stopEmbeddedTomcat()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • WS_REQUIRED_CHANNEL_PROPERTY

        public static final java.lang.String WS_REQUIRED_CHANNEL_PROPERTY
        Deprecated, for removal: This API element is subject to removal in a future version.
        See Also:
        Constant Field Values
      • EMBEDDEDSERVER_HTTP_PORT_CONFIG_KEY

        public static final java.lang.String EMBEDDEDSERVER_HTTP_PORT_CONFIG_KEY
        Deprecated, for removal: This API element is subject to removal in a future version.
        See Also:
        Constant Field Values
      • EMBEDDEDSERVER_HTTPS_PORT_CONFIG_KEY

        public static final java.lang.String EMBEDDEDSERVER_HTTPS_PORT_CONFIG_KEY
        Deprecated, for removal: This API element is subject to removal in a future version.
        See Also:
        Constant Field Values
      • WS_TEST_OAUTH2_TOKEN_ENDPOINT_PATH_KEY

        public static final java.lang.String WS_TEST_OAUTH2_TOKEN_ENDPOINT_PATH_KEY
        Deprecated, for removal: This API element is subject to removal in a future version.
        See Also:
        Constant Field Values
      • WS_TEST_OAUTH2_CLIENT_ID_KEY

        public static final java.lang.String WS_TEST_OAUTH2_CLIENT_ID_KEY
        Deprecated, for removal: This API element is subject to removal in a future version.
        See Also:
        Constant Field Values
      • WS_TEST_OAUTH2_CLIENT_SECRET_KEY

        public static final java.lang.String WS_TEST_OAUTH2_CLIENT_SECRET_KEY
        Deprecated, for removal: This API element is subject to removal in a future version.
        See Also:
        Constant Field Values
      • WS_TEST_OAUTH2_CUSTOMER_USERNAME_KEY

        public static final java.lang.String WS_TEST_OAUTH2_CUSTOMER_USERNAME_KEY
        Deprecated, for removal: This API element is subject to removal in a future version.
        See Also:
        Constant Field Values
      • WS_TEST_OAUTH2_CUSTOMER_PASSWORD_KEY

        public static final java.lang.String WS_TEST_OAUTH2_CUSTOMER_PASSWORD_KEY
        Deprecated, for removal: This API element is subject to removal in a future version.
        See Also:
        Constant Field Values
      • HEADER_AUTH_KEY

        protected static final java.lang.String HEADER_AUTH_KEY
        Deprecated, for removal: This API element is subject to removal in a future version.
        See Also:
        Constant Field Values
      • HEADER_AUTH_VALUE_PREFIX

        protected static final java.lang.String HEADER_AUTH_VALUE_PREFIX
        Deprecated, for removal: This API element is subject to removal in a future version.
        See Also:
        Constant Field Values
      • webResource

        protected javax.ws.rs.client.WebTarget webResource
        Deprecated, for removal: This API element is subject to removal in a future version.
      • jerseyClient

        protected javax.ws.rs.client.Client jerseyClient
        Deprecated, for removal: This API element is subject to removal in a future version.
    • Constructor Detail

      • AbstractWebServicesTest

        protected AbstractWebServicesTest()
        Deprecated, for removal: This API element is subject to removal in a future version.
    • Method Detail

      • stopEmbeddedTomcat

        public static void stopEmbeddedTomcat()
        Deprecated, for removal: This API element is subject to removal in a future version.
      • getWsVersionForExtensionInfo

        protected java.lang.String getWsVersionForExtensionInfo​(ExtensionInfo extensionInfo)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • setUp

        public void setUp()
                   throws java.lang.Exception
        Deprecated, for removal: This API element is subject to removal in a future version.
        Throws:
        java.lang.Exception
      • createClient

        protected javax.ws.rs.client.Client createClient​(org.glassfish.jersey.client.ClientConfig config)
                                                  throws java.security.NoSuchAlgorithmException,
                                                         java.security.KeyManagementException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Method creates client which accepts all hostname and trust all certificates - because of that it is suitable only for tests
        Parameters:
        config - client config
        Returns:
        created client
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyManagementException
      • setupWebResource

        protected javax.ws.rs.client.WebTarget setupWebResource​(ExtensionInfo extensionInfo)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • ensureEmbeddedServerIsRunning

        public void ensureEmbeddedServerIsRunning()
        Deprecated, for removal: This API element is subject to removal in a future version.
      • createEmbeddedServer

        protected EmbeddedServer createEmbeddedServer()
        Deprecated, for removal: This API element is subject to removal in a future version.
      • beforeEmbeddedServerCreation

        protected void beforeEmbeddedServerCreation()
        Deprecated, for removal: This API element is subject to removal in a future version.
      • getEmbeddedServerBuilder

        protected EmbeddedServerBuilder getEmbeddedServerBuilder()
        Deprecated, for removal: This API element is subject to removal in a future version.
      • ensureWebappIsRunning

        protected void ensureWebappIsRunning()
        Deprecated, for removal: This API element is subject to removal in a future version.
      • getExtensionName

        public abstract java.lang.String getExtensionName()
        Deprecated, for removal: This API element is subject to removal in a future version.
      • getExtensionInfo

        public ExtensionInfo getExtensionInfo()
        Deprecated, for removal: This API element is subject to removal in a future version.
      • getAuthorizationExtensionName

        protected java.lang.String getAuthorizationExtensionName()
        Deprecated, for removal: This API element is subject to removal in a future version.
      • getAuthorizationExtensionInfo

        protected ExtensionInfo getAuthorizationExtensionInfo()
        Deprecated, for removal: This API element is subject to removal in a future version.
      • getWebRoot

        protected java.lang.String getWebRoot​(ExtensionInfo extensionInfo)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • authorizeClientUsingClientCredentials

        protected javax.ws.rs.client.Invocation.Builder authorizeClientUsingClientCredentials​(javax.ws.rs.client.WebTarget webResource,
                                                                                              java.lang.String clientId,
                                                                                              java.lang.String clientSecret)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • authorizeClientUsingClientCredentials

        protected javax.ws.rs.client.Invocation.Builder authorizeClientUsingClientCredentials​(javax.ws.rs.client.WebTarget webResource)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • authorizeClientUsingResourceOwnerPassword

        protected javax.ws.rs.client.Invocation.Builder authorizeClientUsingResourceOwnerPassword​(javax.ws.rs.client.WebTarget webResource,
                                                                                                  java.lang.String customerName,
                                                                                                  java.lang.String customerPassword,
                                                                                                  java.lang.String clientId,
                                                                                                  java.lang.String clientSecret)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • authorizeClientUsingResourceOwnerPassword

        protected javax.ws.rs.client.Invocation.Builder authorizeClientUsingResourceOwnerPassword​(javax.ws.rs.client.WebTarget webResource,
                                                                                                  java.lang.String customerName,
                                                                                                  java.lang.String customerPassword)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • authorizeClientUsingResourceOwnerPassword

        protected javax.ws.rs.client.Invocation.Builder authorizeClientUsingResourceOwnerPassword​(javax.ws.rs.client.WebTarget webResource)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • getOAuth2TokenUsingClientCredentials

        protected java.lang.String getOAuth2TokenUsingClientCredentials​(javax.ws.rs.client.WebTarget webResource,
                                                                        java.lang.String clientID,
                                                                        java.lang.String clientSecret)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • getOAuth2TokenUsingResourceOwnerPassword

        protected java.lang.String getOAuth2TokenUsingResourceOwnerPassword​(javax.ws.rs.client.WebTarget webResource,
                                                                            java.lang.String clientID,
                                                                            java.lang.String clientSecret,
                                                                            java.lang.String customerName,
                                                                            java.lang.String customerPassword)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • addAuthorizationHeader

        protected javax.ws.rs.client.Invocation.Builder addAuthorizationHeader​(javax.ws.rs.client.WebTarget webResource,
                                                                               java.lang.String token)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • getTokenFromJsonStr

        public static java.lang.String getTokenFromJsonStr​(java.lang.String jsonStr)
                                                    throws java.io.IOException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Throws:
        java.io.IOException
      • jsonToObj

        public static <T> T jsonToObj​(java.lang.String jsonStr,
                                      java.lang.Class<T> c)
                               throws java.io.IOException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Throws:
        java.io.IOException
      • objToJson

        public static java.lang.String objToJson​(java.lang.Object obj)
                                          throws java.io.IOException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Throws:
        java.io.IOException
      • assertOk

        protected void assertOk​(javax.ws.rs.core.Response response,
                                boolean expectEmptyBody)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Tests whether the response has status OK. Expects correct status (200), content type of 'application/xml'
        Parameters:
        response - ClientResponse
        expectEmptyBody - true - the body is checked for null value
      • assertCreated

        protected void assertCreated​(javax.ws.rs.core.Response response,
                                     boolean expectEmptyBody)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Tests whether resource was successfully created. Expects correct status (201), content type of 'application/xml'
        Parameters:
        response - ClientResponse
        expectEmptyBody - true - the body is checked for null value
      • assertForbidden

        protected void assertForbidden​(javax.ws.rs.core.Response response,
                                       boolean expectEmptyBody)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Tests whether the response has status FORBIDDEN. Expects correct status (403), content type of 'application/xml'
        Parameters:
        response - ClientResponse
        expectEmptyBody - true - the body is checked for null value
      • assertBadRequest

        protected void assertBadRequest​(javax.ws.rs.core.Response response,
                                        boolean expectEmptyBody)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Tests whether the response has status BAD_REQUEST. Expects correct status (400), content type of 'application/xml'
        Parameters:
        response - ClientResponse
        expectEmptyBody - true - the body is checked for null value
      • assertUnauthorized

        protected void assertUnauthorized​(javax.ws.rs.core.Response response,
                                          boolean expectEmptyBody)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Tests whether the response has status UNAUTHORIZED. Expects correct status (401), content type of 'application/xml'
        Parameters:
        response - ClientResponse
        expectEmptyBody - true - the body is checked for null value
      • assertResponseStatus

        protected void assertResponseStatus​(javax.ws.rs.core.Response.Status responseStatus,
                                            javax.ws.rs.core.Response response,
                                            boolean expectEmptyBody)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Tests whether the response status has expected value.
        Parameters:
        response - ClientResponse
        expectEmptyBody - true - the body is checked for null value
      • assertResponseStatus

        protected void assertResponseStatus​(javax.ws.rs.core.Response.Status status,
                                            javax.ws.rs.core.Response response)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • setUseSSL

        public void setUseSSL​(boolean useSSL)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • isUseSSL

        public boolean isUseSSL()
        Deprecated, for removal: This API element is subject to removal in a future version.