How to use matches method of com.paypal.selion.utils.process.AbstractProcessHandler class

Best SeLion code snippet using com.paypal.selion.utils.process.AbstractProcessHandler.matches

Source:AbstractProcessHandler.java Github

copy

Full Screen

...64 // (I.e Windows) The machineName, process name, PID.65 tProcess = new ProcessInfo(eachProcessData[1], eachProcessData[2]);66 break;67 }68 if (matches(tProcess.getProcessName())) {69 processToBeKilled.add(tProcess);70 }71 }72 }73 return processToBeKilled;74 }75 protected void killProcess(String[] killCommand, List<ProcessInfo> process) throws ProcessHandlerException {76 try {77 for (ProcessInfo eachProcess : process) {78 LOGGER.info("Killing process: " + eachProcess);79 String[] cmd = Arrays.copyOf(killCommand, killCommand.length + 1);80 cmd[cmd.length - 1] = eachProcess.getProcessId();81 Process output = Runtime.getRuntime().exec(cmd);82 int returnCode = output.waitFor();83 if (returnCode != 0) {84 LOGGER.info("Printing possible errors " + convertStreamToString(output.getErrorStream()));85 }86 output.destroy();87 }88 LOGGER.info("Successfully killed all stalled processes");89 } catch (IOException | InterruptedException e) {90 throw new ProcessHandlerException(e);91 }92 }93 private String convertStreamToString(InputStream isr) throws IOException {94 BufferedReader br = new BufferedReader(new InputStreamReader(isr));95 String eachLine = null;96 StringBuffer sb = new StringBuffer();97 while ((eachLine = br.readLine()) != null) {98 sb.append(eachLine);99 }100 br.close();101 return sb.toString();102 }103 /**104 * @param image - A image name that should be checked against the image names represented by105 * {@link ProcessNames} enum.106 * @return <code>true</code> if the image name matches for the given operating system.107 */108 protected abstract boolean matches(String image);109 /**110 * Gets the PID for the SeLion-Grid (main) process111 * 112 * @return the PID as an int113 * @throws ProcessHandlerException114 */115 protected int getCurrentProcessID() throws ProcessHandlerException {116 int pid;117 // Not ideal but using JNA failed on RHEL5.118 RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();119 Field jvm = null;120 try {121 jvm = runtime.getClass().getDeclaredField("jvm");122 jvm.setAccessible(true);...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeLion automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful