diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/ActionsBaseTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/ActionsBaseTestCase.java index 0b9e5b6bae..c426236355 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/ActionsBaseTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/ActionsBaseTestCase.java @@ -32,7 +32,7 @@ */ public class ActionsBaseTestCase extends OAuth2ServiceAbstractIntegrationTest { - protected ActionsRestClient restClient; + protected ActionsRestClient actionsRestClient; /** * Initialize the test case. @@ -44,7 +44,7 @@ protected void init(TestUserMode userMode) throws Exception { super.init(userMode); - restClient = new ActionsRestClient(serverURL, tenantInfo); + actionsRestClient = new ActionsRestClient(serverURL, tenantInfo); setSystemproperties(); } @@ -59,7 +59,7 @@ protected void init(TestUserMode userMode) throws Exception { */ public String createAction(String actionType, ActionModel actionModel) throws IOException { - return restClient.createActionType(actionModel, actionType); + return actionsRestClient.createActionType(actionModel, actionType); } /** @@ -72,6 +72,6 @@ public String createAction(String actionType, ActionModel actionModel) throws IO */ public int deleteAction(String actionType, String actionId) throws IOException { - return restClient.deleteActionType(actionType, actionId); + return actionsRestClient.deleteActionType(actionType, actionId); } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenClientCredentialsGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenClientCredentialsGrantTestCase.java index 65ba06140e..f57f568bf0 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenClientCredentialsGrantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenClientCredentialsGrantTestCase.java @@ -58,7 +58,6 @@ import org.wso2.identity.integration.test.rest.api.user.common.model.PatchOperationRequestObject; import org.wso2.identity.integration.test.rest.api.user.common.model.RoleItemAddGroupobj; import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject; -import org.wso2.identity.integration.test.restclients.ActionsRestClient; import org.wso2.identity.integration.test.restclients.SCIM2RestClient; import org.wso2.identity.integration.test.utils.CarbonUtils; import org.wso2.identity.integration.test.utils.OAuth2Constant; @@ -171,8 +170,6 @@ protected boolean isRedirectable(String method) { }).build(); scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo); - restClient = new ActionsRestClient(serverURL, tenantInfo); - // TODO: Review if ActionsRestClient should be instantiated, or if the superclass initialization is sufficient customScopes = Arrays.asList(CUSTOM_SCOPE_1, CUSTOM_SCOPE_2, CUSTOM_SCOPE_3); @@ -198,13 +195,15 @@ protected boolean isRedirectable(String method) { public void atEnd() throws Exception { deleteAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionId); - restClient = null; deleteRole(roleId); deleteApp(applicationId); deleteDomainAPI(domainAPIId); scim2RestClient.deleteUser(userId); - scim2RestClient = null; MockServer.shutDownMockServer(); + restClient.closeHttpClient(); + scim2RestClient.closeHttpClient(); + actionsRestClient.closeHttpClient(); + client.close(); accessToken = null; jwtClaims = null; } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenPasswordGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenPasswordGrantTestCase.java index c1cd53f099..d9b43c98b8 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenPasswordGrantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenPasswordGrantTestCase.java @@ -42,7 +42,6 @@ import org.wso2.identity.integration.test.rest.api.user.common.model.PatchOperationRequestObject; import org.wso2.identity.integration.test.rest.api.user.common.model.RoleItemAddGroupobj; import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject; -import org.wso2.identity.integration.test.restclients.ActionsRestClient; import org.wso2.identity.integration.test.restclients.SCIM2RestClient; import org.wso2.identity.integration.test.utils.CarbonUtils; import org.wso2.identity.integration.test.utils.OAuth2Constant; @@ -127,8 +126,6 @@ public void testInit() throws Exception { super.init(TestUserMode.TENANT_USER); scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo); - restClient = new ActionsRestClient(serverURL, tenantInfo); - // TODO: Review if ActionsRestClient should be instantiated, or if the superclass initialization is sufficient List customScopes = Arrays.asList(CUSTOM_SCOPE_1, CUSTOM_SCOPE_2, CUSTOM_SCOPE_3); @@ -154,13 +151,14 @@ public void testInit() throws Exception { public void atEnd() throws Exception { deleteAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionId); - restClient = null; deleteRole(roleId); deleteApp(applicationId); deleteDomainAPI(domainAPIId); scim2RestClient.deleteUser(userId); - scim2RestClient = null; MockServer.shutDownMockServer(); + restClient.closeHttpClient(); + scim2RestClient.closeHttpClient(); + actionsRestClient.closeHttpClient(); accessToken = null; jwtClaims = null; } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/ActionsRestClient.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/ActionsRestClient.java index bb8a0fca19..bfe0bb13f4 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/ActionsRestClient.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/ActionsRestClient.java @@ -143,4 +143,14 @@ private Header[] getHeaders() { return headerList; } + + /** + * Close the HTTP client. + * + * @throws IOException If an error occurred while closing the Http Client. + */ + public void closeHttpClient() throws IOException { + + client.close(); + } }