Source:
protected boolean isCarbonAppListed(String appName) throws LazyLoadingTestException { int deploymentDelay = 90 * 1000; log.info("waiting " + deploymentDelay + " millis for Carbon Application to list" + appName); ApplicationAdminClient appAdminClient; try { appAdminClient = new ApplicationAdminClient(backendURL, sessionCookie); } catch (AxisFault axisFault) { String customErrorMessage = "AxisFault Exception when creating WebAppAdminClient object. backend URL:" + backendURL + " Session Cookie: " + sessionCookie + "\n" + axisFault.getMessage(); log.error(customErrorMessage); throw new LazyLoadingTestException(customErrorMessage, axisFault); } String[] appList; boolean doLoop = true; boolean isAppListed = false; long startTime = System.currentTimeMillis(); long time; while (((time = (System.currentTimeMillis() - startTime)) < deploymentDelay) && doLoop) { try { appList = appAdminClient.listAllApplications(); } catch (ApplicationAdminExceptionException applicationAdminExceptionException) { String customErrorMessage = "ApplicationAdminExceptionException Exception when when calling " + "listAllApplications() methods in WebAppAdminClient" + applicationAdminExceptionException.getMessage(); log.error(customErrorMessage); throw new LazyLoadingTestException(customErrorMessage, applicationAdminExceptionException); } catch (RemoteException remoteException) { String customErrorMessage = "RemoteException Exception when calling listAllApplications() methods in " + "WebAppAdminClient\n" + remoteException.getMessage(); log.error(customErrorMessage); throw new LazyLoadingTestException(customErrorMessage, remoteException); } if (Arrays.asList(appList).contains(appName)) { isAppListed = true; log.info(appName + " Carbon Application is listed in" + time + " millis"); doLoop = false; } try { Thread.sleep(500); } catch (InterruptedException interruptedException) { String customErrorMessage = "InterruptedException occurs when sleeping 500 milliseconds and while" + " waiting for Carbon Application to listed in ApplicationAdminClient." + interruptedException.getMessage(); log.error(customErrorMessage); throw new LazyLoadingTestException(customErrorMessage, interruptedException); } } return isAppListed; }

Target:
protected boolean isCarbonAppListed(String appName) throws LazyLoadingTestException { String[] appList; boolean isAppListed = false; long time; long startTime; log.info("waiting for " + appName + " Carbon application to list. Max wait time :" + DEPLOYMENT_DELAY_IN_MILLISECONDS + " milliseconds"); startTime = System.currentTimeMillis(); while (((time = (System.currentTimeMillis() - startTime)) < DEPLOYMENT_DELAY_IN_MILLISECONDS)) { try { appList = appAdminClient.listAllApplications(); } catch (ApplicationAdminExceptionException applicationAdminExceptionException) { String customErrorMessage = "ApplicationAdminExceptionException Exception when when calling " + "listAllApplications() methods in WebAppAdminClient"; log.error(customErrorMessage, applicationAdminExceptionException); throw new LazyLoadingTestException(customErrorMessage, applicationAdminExceptionException); } catch (RemoteException remoteException) { String customErrorMessage = "RemoteException Exception when calling listAllApplications() methods in WebAppAdminClient"; log.error(customErrorMessage, remoteException); throw new LazyLoadingTestException(customErrorMessage, remoteException); } if (Arrays.asList(appList).contains(appName)) { isAppListed = true; log.info(appName + " Carbon Application is listed in" + time + " millis"); break; } else { try { Thread.sleep(500); } catch (InterruptedException interruptedException) { String customErrorMessage = "InterruptedException occurs when sleeping 500 milliseconds and while" + " waiting for Carbon Application to listed in ApplicationAdminClient."; log.warn(customErrorMessage, interruptedException); } } } return isAppListed; }