/** * Returns the process id (PID). * * @return the process id (PID) */ public int getPid() { return this.launcher.getPid(); }
/** * Returns the process id (PID). * * @return the process id (PID) */ public int getPid() { return this.launcher.getPid(); }
@Override public void run() { try { final LocalProcessLauncher launcher = new LocalProcessLauncher(new File(absolutePath), true); assertNotSame(pid, launcher.getPid()); assertFalse(pid == launcher.getPid()); final FileReader fr = new FileReader(absolutePath); final BufferedReader br = new BufferedReader(fr); final int pidFromFile = Integer.parseInt(br.readLine()); br.close(); assertNotSame(pid, pidFromFile); assertFalse(pid == pidFromFile); assertEquals(launcher.getPid(), pidFromFile); } catch(IllegalStateException e) { throw new AssertionError(e); } catch(IOException e) { throw new AssertionError(e); } catch(FileAlreadyExistsException e) { throw new AssertionError(e); } catch(PidUnavailableException e) { throw new AssertionError(e); } } });
public void testPidFileContainsPid() throws Exception { final File pidFile = new File(getClass().getSimpleName() + File.separator + "testPidFileContainsPid.pid"); final LocalProcessLauncher launcher = new LocalProcessLauncher(pidFile, false); assertNotNull(launcher); assertTrue(pidFile.exists()); final FileReader fr = new FileReader(pidFile); final BufferedReader br = new BufferedReader(fr); final int pid = Integer.parseInt(br.readLine()); br.close(); assertTrue(pid > 0); assertEquals(launcher.getPid(), pid); assertEquals(ProcessUtils.identifyPid(), pid); }
final int pid = launcher.getPid();
public void testPidFileReadByOtherProcess() throws Exception { final File pidFile = new File(getClass().getSimpleName() + File.separator + "testPidFileReadByOtherProcess.pid"); final String absolutePath = pidFile.getAbsolutePath(); assertFalse(pidFile.exists()); final LocalProcessLauncher launcher = new LocalProcessLauncher(pidFile, false); assertTrue(pidFile.exists()); assertNotNull(launcher); final int pid = launcher.getPid(); Host.getHost(0).getVM(0).invoke(new SerializableRunnable("LocalProcessLauncherDUnitTest#testPidFileReadByOtherProcess") { @Override public void run() { try { final FileReader fr = new FileReader(absolutePath); final BufferedReader br = new BufferedReader(fr); final int pidFromFile = Integer.parseInt(br.readLine()); br.close(); assertEquals(pid, pidFromFile); } catch (FileNotFoundException e) { throw new Error(e); } catch (IOException e) { throw new Error(e); } } }); } }
assertTrue(pidFile.exists()); assertNotNull(launcher); final int pid = launcher.getPid();