@Test(groups = "Integration") public void testCopyToFailBadSubdirAllow() throws IOException { String fn = Urls.mergePaths(tempDir.getPath(), "non-existent-subdir/file"); SshPutTaskWrapper t = submit(SshTasks.newSshPutTaskFactory(host, fn).contents("hello world").allowFailure()); // this doesn't fail t.block(); Assert.assertTrue(t.isDone()); // and this doesn't fail either Assert.assertEquals(t.get(), null); // but it's not successful Assert.assertNotNull(t.getException()); Assert.assertFalse(t.isSuccessful()); // exit code probably null, but won't be zero Assert.assertNotEquals(t.getExitCode(), (Integer) 0); }
@Test(groups = "Integration") public void testCopyToFailBadSubdir() throws IOException { String fn = Urls.mergePaths(tempDir.getPath(), "non-existent-subdir/file"); SshPutTaskWrapper t = submit(SshTasks.newSshPutTaskFactory(host, fn).contents("hello world")); // this doesn't fail t.block(); Assert.assertTrue(t.isDone()); setExpectingFailure(); try { // but this does t.get(); } catch (Exception e) { log.info("The error if file cannot be written is: " + e); clearExpectedFailure(); } checkExpectedFailure(); // and the results indicate failure Assert.assertFalse(t.isSuccessful()); Assert.assertNotNull(t.getException()); Assert.assertNotEquals(t.getExitCode(), (Integer) 0); }