@Test(groups="Integration") public void testNonRunningPidRequired() { ProcessTaskWrapper<?> t = submit(SshEffectorTasks.requirePidRunning(99999)); setExpectingFailure(); try { t.getTask().getUnchecked(); } catch (Exception e) { log.info("The error if required PID is not found is: "+e); clearExpectedFailure(); Assert.assertTrue(e.toString().contains("Process with PID"), "Expected nice clue in error but got: "+e); } checkExpectedFailure(); }
@Test(groups="Integration") public void testRequirePidFromFileOnFailure() throws IOException { File f = File.createTempFile("testBrooklynPid", ".pid"); Files.write( "99999".getBytes(), f ); ProcessTaskWrapper<?> t = submit(SshEffectorTasks.requirePidFromFileRunning(f.getPath())); setExpectingFailure(); try { t.getTask().getUnchecked(); } catch (Exception e) { log.info("The error if required PID is not found is: "+e); clearExpectedFailure(); Assert.assertTrue(e.toString().contains("Process with PID"), "Expected nice clue in error but got: "+e); Assert.assertEquals(t.getExitCode(), (Integer)1); } checkExpectedFailure(); }
@Test(groups="Integration") public void testRequirePidFromFileOnFailureNoSuchFile() throws IOException { ProcessTaskWrapper<?> t = submit(SshEffectorTasks.requirePidFromFileRunning("/path/does/not/exist/SADVQW")); setExpectingFailure(); try { t.getTask().getUnchecked(); } catch (Exception e) { log.info("The error if required PID is not found is: "+e); clearExpectedFailure(); Assert.assertTrue(e.toString().contains("Process with PID"), "Expected nice clue in error but got: "+e); Assert.assertEquals(t.getExitCode(), (Integer)1); } checkExpectedFailure(); }
@Test(groups="Integration") public void testRequirePidFromFileOnFailureTooManyFiles() throws IOException { ProcessTaskWrapper<?> t = submit(SshEffectorTasks.requirePidFromFileRunning("/*")); setExpectingFailure(); try { t.getTask().getUnchecked(); } catch (Exception e) { log.info("The error if required PID is not found is: "+e); clearExpectedFailure(); Assert.assertTrue(e.toString().contains("Process with PID"), "Expected nice clue in error but got: "+e); Assert.assertEquals(t.getExitCode(), (Integer)2); } checkExpectedFailure(); }