Source:
public static Process startServerUsingCarbonHome(String carbonHome, int portOffset, AutomationContext automationContext, String[] parameters) throws Exception { Process tempProcess; String scriptName = "wso2server"; File commandDir = new File(carbonHome); String[] cmdArray; log.info("Starting server............. "); if (System.getProperty("os.name").toLowerCase().contains("windows")) { commandDir = new File(carbonHome + File.separator + "bin"); cmdArray = new String[]{"cmd.exe", "/c", scriptName + ".bat", "-DportOffset=" + portOffset}; cmdArray = mergePropertiesToCommandArray(parameters, cmdArray); tempProcess = Runtime.getRuntime().exec(cmdArray, null, commandDir); } else { cmdArray = new String[]{"sh", "bin/" + scriptName + ".sh", "-DportOffset=" + portOffset}; cmdArray = mergePropertiesToCommandArray(parameters, cmdArray); tempProcess = Runtime.getRuntime().exec(cmdArray, null, commandDir); } int defaultHttpPort = Integer.parseInt(automationContext.getInstance().getPorts().get("http")); InputStreamHandler errorStreamHandler = new InputStreamHandler("errorStream", tempProcess.getErrorStream()); inputStreamHandler = new ServerLogReader("inputStream", tempProcess.getInputStream()); inputStreamHandler.start(); errorStreamHandler.start(); ClientConnectionUtil.waitForPort(defaultHttpPort, DEFAULT_START_STOP_WAIT_MS, false, automationContext.getInstance().getHosts().get("default")); long time = System.currentTimeMillis() + TIMEOUT; while (!inputStreamHandler.getOutput().contains(SERVER_STARTUP_MESSAGE) && System.currentTimeMillis() < time) { } ClientConnectionUtil.waitForLogin(automationContext); log.info("Server started successfully."); return tempProcess; }

Target:
public static Process startServerUsingCarbonHome( String carbonHome, int portOffset, AutomationContext automationContext, String[] parameters) throws CarbonToolsIntegrationTestException { Process tempProcess; String scriptName = "wso2server"; try { File commandDir = new File(carbonHome); String[] cmdArray; log.info("Starting server............. "); if (System.getProperty("os.name").toLowerCase().contains("windows")) { commandDir = new File(carbonHome + File.separator + "bin"); cmdArray = new String[]{"cmd.exe", "/c", scriptName + ".bat", "-DportOffset=" + portOffset}; cmdArray = mergePropertiesToCommandArray(parameters, cmdArray); tempProcess = Runtime.getRuntime().exec(cmdArray, null, commandDir); } else { cmdArray = new String[]{"sh", "bin/" + scriptName + ".sh", "-DportOffset=" + portOffset}; cmdArray = mergePropertiesToCommandArray(parameters, cmdArray); tempProcess = Runtime.getRuntime().exec(cmdArray, null, commandDir); } int defaultHttpPort = Integer.parseInt(automationContext.getInstance().getPorts().get("http")); InputStreamHandler errorStreamHandler = new InputStreamHandler("errorStream", tempProcess.getErrorStream()); inputStreamHandler = new ServerLogReader("inputStream", tempProcess.getInputStream()); inputStreamHandler.start(); errorStreamHandler.start(); ClientConnectionUtil.waitForPort(defaultHttpPort, DEFAULT_START_STOP_WAIT_MS, false, automationContext.getInstance().getHosts().get("default")); long time = System.currentTimeMillis() + TIMEOUT; while (!inputStreamHandler.getOutput().contains(SERVER_STARTUP_MESSAGE) && System.currentTimeMillis() < time) { } ClientConnectionUtil.waitForLogin(automationContext); log.info("Server started successfully."); return tempProcess; } catch (Exception ex) { log.error("Error while starting the server using carbon home", ex); throw new CarbonToolsIntegrationTestException("Error while starting the server using carbon home", ex); } }