diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/common/UserApprovalTestBase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/common/UserApprovalTestBase.java index f536223a53..ecbd8a419b 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/common/UserApprovalTestBase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/common/UserApprovalTestBase.java @@ -211,19 +211,19 @@ protected void waitForWorkflowToDeploy() throws Exception { if (!isBpelDeployed) { log.info("Verifying BPEL deployment."); url = identityContextUrls.getSecureServiceUrl() + "/" + addUserWorkflowName + "Service?wsdl"; - if (isWorkflowDeployed(url)) { + if (isServiceDeployed(url)) { isBpelDeployed = true; - log.info("BPEL Workflow deployed successfully in " + count + " attempt(s)."); + log.info("Verified BPEL Workflow deployment successfully in " + count + " attempt(s)."); } } - if(isBpelDeployed) { + if (isBpelDeployed) { log.info("Verifying Human Task deployment."); url = identityContextUrls.getSecureServiceUrl() + "/" + addUserWorkflowName + "TaskService?wsdl"; - if (isWorkflowDeployed(url)) { + if (isServiceDeployed(url)) { isHumanTaskDeployed = true; - log.info("Human Task Workflow deployed successfully in " + count + " attempt(s)."); - log.info("Workflow is deployed successfully."); + log.info("Verified Human Task Workflow deployment successfully in " + count + " attempt(s)."); + log.info("Workflow deployment successfully Verified."); break; } } @@ -233,23 +233,25 @@ protected void waitForWorkflowToDeploy() throws Exception { // Give up after 100 seconds. if (!isBpelDeployed || !isHumanTaskDeployed) { - log.info("No luck. Going to give up. Test will most probably fail."); + log.warn("No luck. Going to give up. Test will most probably fail."); } - log.info("Waiting for 5 seconds before proceeding."); - Thread.sleep(5000); } - private boolean isWorkflowDeployed(String url) throws IOException { + private boolean isServiceDeployed(String url) throws IOException { // We have to check whether the service is up and running by calling the generated endpoint. HttpClient client = new HttpClientFactory().getHttpClient(); HttpGet request = new HttpGet(url); HttpResponse httpResponse = client.execute(request); + log.info("Response code: " + httpResponse.getStatusLine().getStatusCode()); + if (httpResponse.getStatusLine().getStatusCode() == 200) { + return true; + } + // If the server response is 500, or it contains "service not available" text or "Operation not found" text, // then we have to assume that the service is still not available. // Log response to get more context. - log.info("Response code: " + httpResponse.getStatusLine().getStatusCode()); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent())); String line; @@ -260,8 +262,7 @@ private boolean isWorkflowDeployed(String url) throws IOException { break; } } - - return (httpResponse.getStatusLine().getStatusCode() == 200); + return false; } protected void setUpWorkFlowAssociation() throws Exception { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/v1/UserMeApprovalTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/v1/UserMeApprovalTest.java index e1f15a8e80..9c30e22e2f 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/v1/UserMeApprovalTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/approval/v1/UserMeApprovalTest.java @@ -345,7 +345,7 @@ private void verifyTaskCreation(int taskCount) throws InterruptedException { .path("findAll{ it.presentationName == '" + TEST_WORKFLOW_ADD_USER_FOR_REST_TASK + "' }.size()"); if (numOfTasks == taskCount) { - log.info("Tasks creation verified successfully in " + i + "attempt(s). Number of tasks created : " + log.info("Tasks creation verified successfully in " + i + " attempt(s). Number of tasks created : " + numOfTasks + " of " + userToAdd.length); break; } else {