Class APIMTestCaseUtils


  • public class APIMTestCaseUtils
    extends Object
    • Constructor Detail

      • APIMTestCaseUtils

        public APIMTestCaseUtils()
    • Method Detail

      • updateSynapseConfiguration

        public static void updateSynapseConfiguration​(org.apache.axiom.om.OMElement synapseConfig,
                                                      String backendURL,
                                                      String sessionCookie)
                                               throws Exception
        Parameters:
        synapseConfig - - Synapse configuration to be updated
        backendURL - - backend URL of the gateway server
        sessionCookie - - session cookie of user login
        Throws:
        Exception - - Throws if update fails
      • addEndpoint

        public static void addEndpoint​(String backEndUrl,
                                       String sessionCookie,
                                       org.apache.axiom.om.OMElement endpointConfig)
                                throws Exception
        Throws:
        Exception
      • addLocalEntry

        public static void addLocalEntry​(String backEndUrl,
                                         String sessionCookie,
                                         org.apache.axiom.om.OMElement localEntryConfig)
                                  throws Exception
        Throws:
        Exception
      • addSequence

        public static void addSequence​(String backEndUrl,
                                       String sessionCookie,
                                       org.apache.axiom.om.OMElement sequenceConfig)
                                throws Exception
        Throws:
        Exception
      • addAPI

        public static void addAPI​(String backEndUrl,
                                  String sessionCookie,
                                  org.apache.axiom.om.OMElement api)
                           throws RemoteException,
                                  org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
        Throws:
        RemoteException
        org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
      • addScheduleTask

        public static void addScheduleTask​(String backEndUrl,
                                           String sessionCookie,
                                           org.apache.axiom.om.OMElement taskDescription)
                                    throws org.wso2.carbon.task.stub.TaskManagementException,
                                           RemoteException
        Throws:
        org.wso2.carbon.task.stub.TaskManagementException
        RemoteException
      • isEndpointDeployed

        public static boolean isEndpointDeployed​(String backEndUrl,
                                                 String sessionCookie,
                                                 String endpointName)
                                          throws org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException,
                                                 RemoteException
        Throws:
        org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
        RemoteException
      • isSequenceDeployed

        public static boolean isSequenceDeployed​(String backEndUrl,
                                                 String sessionCookie,
                                                 String sequenceName)
                                          throws org.wso2.carbon.sequences.stub.types.SequenceEditorException,
                                                 RemoteException
        Throws:
        org.wso2.carbon.sequences.stub.types.SequenceEditorException
        RemoteException
      • isApiDeployed

        public static boolean isApiDeployed​(String backEndUrl,
                                            String sessionCookie,
                                            String apiName)
                                     throws RemoteException,
                                            org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
        Throws:
        RemoteException
        org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
      • isScheduleTaskDeployed

        public static boolean isScheduleTaskDeployed​(String backEndUrl,
                                                     String sessionCookie,
                                                     String taskName)
                                              throws RemoteException,
                                                     org.wso2.carbon.task.stub.TaskManagementException
        Throws:
        RemoteException
        org.wso2.carbon.task.stub.TaskManagementException
      • isLocalEntryExist

        public static boolean isLocalEntryExist​(String backEndUrl,
                                                String sessionCookie,
                                                String localEntryName)
                                         throws org.wso2.carbon.localentry.stub.types.LocalEntryAdminException,
                                                RemoteException
        Throws:
        org.wso2.carbon.localentry.stub.types.LocalEntryAdminException
        RemoteException
      • isSequenceExist

        public static boolean isSequenceExist​(String backEndUrl,
                                              String sessionCookie,
                                              String sequenceName)
                                       throws org.wso2.carbon.sequences.stub.types.SequenceEditorException,
                                              RemoteException
        Throws:
        org.wso2.carbon.sequences.stub.types.SequenceEditorException
        RemoteException
      • isEndpointExist

        public static boolean isEndpointExist​(String backEndUrl,
                                              String sessionCookie,
                                              String endpointName)
                                       throws org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException,
                                              RemoteException
        Throws:
        org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
        RemoteException
      • isApiExist

        public static boolean isApiExist​(String backEndUrl,
                                         String sessionCookie,
                                         String apiName)
                                  throws RemoteException,
                                         org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
        Throws:
        RemoteException
        org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
      • isScheduleTaskExist

        public static boolean isScheduleTaskExist​(String backEndUrl,
                                                  String sessionCookie,
                                                  String taskName)
                                           throws RemoteException,
                                                  org.wso2.carbon.task.stub.TaskManagementException
        Throws:
        RemoteException
        org.wso2.carbon.task.stub.TaskManagementException
      • deleteLocalEntry

        public static void deleteLocalEntry​(String backEndUrl,
                                            String sessionCookie,
                                            String localEntryName)
                                     throws org.wso2.carbon.localentry.stub.types.LocalEntryAdminException,
                                            RemoteException
        Throws:
        org.wso2.carbon.localentry.stub.types.LocalEntryAdminException
        RemoteException
      • deleteEndpoint

        public static void deleteEndpoint​(String backEndUrl,
                                          String sessionCookie,
                                          String endpointName)
                                   throws org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException,
                                          RemoteException
        Throws:
        org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
        RemoteException
      • deleteSequence

        public static void deleteSequence​(String backEndUrl,
                                          String sessionCookie,
                                          String sequenceName)
                                   throws org.wso2.carbon.sequences.stub.types.SequenceEditorException,
                                          RemoteException
        Throws:
        org.wso2.carbon.sequences.stub.types.SequenceEditorException
        RemoteException
      • deleteEndpointTemplate

        public static void deleteEndpointTemplate​(String backEndUrl,
                                                  String sessionCookie,
                                                  String endpointTemplate)
                                           throws RemoteException,
                                                  org.wso2.carbon.sequences.stub.types.SequenceEditorException,
                                                  org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
        Throws:
        RemoteException
        org.wso2.carbon.sequences.stub.types.SequenceEditorException
        org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
      • deleteSequenceTemplate

        public static void deleteSequenceTemplate​(String backEndUrl,
                                                  String sessionCookie,
                                                  String sequenceTemplateName)
                                           throws RemoteException,
                                                  org.wso2.carbon.sequences.stub.types.SequenceEditorException,
                                                  org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
        Throws:
        RemoteException
        org.wso2.carbon.sequences.stub.types.SequenceEditorException
        org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
      • deleteApi

        public static void deleteApi​(String backEndUrl,
                                     String sessionCookie,
                                     String apiName)
                              throws RemoteException,
                                     org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
        Throws:
        RemoteException
        org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
      • deleteScheduleTask

        public static void deleteScheduleTask​(String backEndUrl,
                                              String sessionCookie,
                                              String taskName,
                                              String group)
                                       throws org.wso2.carbon.task.stub.TaskManagementException,
                                              RemoteException
        Throws:
        org.wso2.carbon.task.stub.TaskManagementException
        RemoteException
      • isMessageProcessorUnDeployed

        public static boolean isMessageProcessorUnDeployed​(String backEndUrl,
                                                           String sessionCookie,
                                                           String messageProcessorName)
                                                    throws org.wso2.carbon.sequences.stub.types.SequenceEditorException,
                                                           RemoteException
        Throws:
        org.wso2.carbon.sequences.stub.types.SequenceEditorException
        RemoteException
      • isLocalEntryDeployed

        public static boolean isLocalEntryDeployed​(String backEndUrl,
                                                   String sessionCookie,
                                                   String localEntryName)
                                            throws org.wso2.carbon.localentry.stub.types.LocalEntryAdminException,
                                                   RemoteException
        Throws:
        org.wso2.carbon.localentry.stub.types.LocalEntryAdminException
        RemoteException
      • isLocalEntryUnDeployed

        public static boolean isLocalEntryUnDeployed​(String backEndUrl,
                                                     String sessionCookie,
                                                     String localEntryName)
                                              throws org.wso2.carbon.localentry.stub.types.LocalEntryAdminException,
                                                     RemoteException
        Throws:
        org.wso2.carbon.localentry.stub.types.LocalEntryAdminException
        RemoteException
      • isSequenceUnDeployed

        public static boolean isSequenceUnDeployed​(String backEndUrl,
                                                   String sessionCookie,
                                                   String sequenceName)
                                            throws org.wso2.carbon.sequences.stub.types.SequenceEditorException,
                                                   RemoteException
        Throws:
        org.wso2.carbon.sequences.stub.types.SequenceEditorException
        RemoteException
      • isEndpointUnDeployed

        public static boolean isEndpointUnDeployed​(String backEndUrl,
                                                   String sessionCookie,
                                                   String endpointName)
                                            throws org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException,
                                                   RemoteException
        Throws:
        org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
        RemoteException
      • isEndpointTemplateUnDeployed

        public static boolean isEndpointTemplateUnDeployed​(String backEndUrl,
                                                           String sessionCookie,
                                                           String endpointTemplateName)
                                                    throws org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException,
                                                           RemoteException
        Throws:
        org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
        RemoteException
      • isSequenceTemplateUnDeployed

        public static boolean isSequenceTemplateUnDeployed​(String backEndUrl,
                                                           String sessionCookie,
                                                           String sequenceTemplateName)
                                                    throws org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException,
                                                           RemoteException
        Throws:
        org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
        RemoteException
      • isApiUnDeployed

        public static boolean isApiUnDeployed​(String backEndUrl,
                                              String sessionCookie,
                                              String apiName)
                                       throws RemoteException,
                                              org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
        Throws:
        RemoteException
        org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
      • isScheduleTaskUnDeployed

        public static boolean isScheduleTaskUnDeployed​(String backEndUrl,
                                                       String sessionCookie,
                                                       String taskName)
                                                throws RemoteException,
                                                       org.wso2.carbon.task.stub.TaskManagementException
        Throws:
        RemoteException
        org.wso2.carbon.task.stub.TaskManagementException
      • verifySynapseDeployment

        public static void verifySynapseDeployment​(org.apache.axiom.om.OMElement synapseConfig,
                                                   String backendURL,
                                                   String sessionCookie)
                                            throws org.wso2.carbon.localentry.stub.types.LocalEntryAdminException,
                                                   RemoteException,
                                                   org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException,
                                                   org.wso2.carbon.sequences.stub.types.SequenceEditorException,
                                                   org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
        Throws:
        org.wso2.carbon.localentry.stub.types.LocalEntryAdminException
        RemoteException
        org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException
        org.wso2.carbon.sequences.stub.types.SequenceEditorException
        org.wso2.carbon.rest.api.stub.RestApiAdminAPIException
      • decode

        public static byte[] decode​(String stringToBeDecodedArg)
                             throws UnsupportedEncodingException
        This method is used to base64Url-decode a base64Url-encoded string
        Parameters:
        stringToBeDecodedArg - - The base64Url encoded string to be decoded
        Returns:
        - The base64Url decoded string
        Throws:
        UnsupportedEncodingException
      • getAPIIdentifierListFromHttpResponse

        public static List<org.wso2.carbon.apimgt.api.model.APIIdentifier> getAPIIdentifierListFromHttpResponse​(org.wso2.carbon.automation.test.utils.http.client.HttpResponse httpResponse)
                                                                                                         throws APIManagerIntegrationTestException
        Get the API information from the response object as Lost of APIIdentifier
        Parameters:
        httpResponse - Response that contains the API information
        Returns:
        List of APIIdentifier
        Throws:
        org.json.JSONException
        APIManagerIntegrationTestException
      • getAPIIdentifierListFromHttpResponse

        public static List<org.wso2.carbon.apimgt.api.model.APIIdentifier> getAPIIdentifierListFromHttpResponse​(APIListDTO apiListDTO)
        Parameters:
        apiListDTO -
        Returns:
        Throws:
        APIManagerIntegrationTestException
      • getAPIIdentifierListFromHttpResponse

        public static List<org.wso2.carbon.apimgt.api.model.APIIdentifier> getAPIIdentifierListFromHttpResponse​(APIListDTO apiListDTO)
        Parameters:
        apiListDTO -
        Returns:
        Throws:
        APIManagerIntegrationTestException
      • isAPIAvailable

        public static boolean isAPIAvailable​(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifierToCheck,
                                             List<org.wso2.carbon.apimgt.api.model.APIIdentifier> apiIdentifierList)
        Check the given API is available in the APIIdentifier List. it will match for API Name,API Version and API Provider
        Parameters:
        apiIdentifierToCheck - - API identifier to verify
        apiIdentifierList - - API identifier list
        Returns:
        - Status of API availability
      • getPayloadForPasswordGrant

        public static String getPayloadForPasswordGrant​(String username,
                                                        String password)
        Get the json payload required for getting an access token using the password grant-type
        Parameters:
        username - - The username of the user (required)
        password - - The password of the user (required)
        Returns:
        - The json payload. Sample: "grant_type=password&username=user&password=pass"
      • isAPIAvailable

        public static boolean isAPIAvailable​(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifier,
                                             APIListDTO apiListDTO)
        Check the given API is available in the APIIdentifier List. it will match for API Name,API Version and API Provider
        Parameters:
        apiIdentifier - - API DTO to verify
        apiListDTO - - API Info DTO list
        Returns:
        - Status of API availability
      • isAPIAvailableInStore

        public static boolean isAPIAvailableInStore​(org.wso2.carbon.apimgt.api.model.APIIdentifier apiIdentifier,
                                                    APIListDTO apiListDTO)
        Check the given API is available in the APIIdentifier List. it will match for API Name,API Version and API Provider
        Parameters:
        apiIdentifier - - API DTO to verify
        apiListDTO - - API Info DTO list
        Returns:
        - Status of API availability
      • encodeCredentials

        public static String encodeCredentials​(String user,
                                               char[] pass)
        get the base64 encoded username and password
        Parameters:
        user - username
        pass - password
        Returns:
        encoded basic auth, as string