public void testCantWriteToFinalDestAfterTempDirectory() throws Exception
{
// Must create the temp directory before we change the access rights
createRemoteDirectory(OUTBOUND_ENDPOINT_NAME, "uploading");
SftpClient client = getSftpClient(OUTBOUND_ENDPOINT_NAME);
try
{
// change the chmod to "dr-x------" on the outbound-directory
remoteChmod(client, OUTBOUND_ENDPOINT_NAME, 00500);
// Send an file to the SFTP server, which the inbound-outboundEndpoint
// then can pick up
// Expect an error, permission denied
Exception exception = dispatchAndWaitForException(new DispatchParameters(INBOUND_ENDPOINT_NAME,
OUTBOUND_ENDPOINT_NAME), "sftp", "service");
assertNotNull(exception);
assertTrue("did not receive DispatchException, got : " + exception.getClass().toString(),
exception instanceof DispatchException);
assertTrue("did not receive IOException, got : " + exception.getCause().getClass().toString(),
exception.getCause() instanceof IOException);
assertEquals("Permission denied", exception.getCause().getMessage());
verifyInAndOutFiles(INBOUND_ENDPOINT_NAME, OUTBOUND_ENDPOINT_NAME, true, false);
ImmutableEndpoint endpoint = muleContext.getRegistry().lookupObject(OUTBOUND_ENDPOINT_NAME);
assertFalse("The inbound file should not be left in the TEMP-dir", super.verifyFileExists(
client, endpoint.getEndpointURI().getPath() + "/" + TEMP_DIR, FILENAME));
}
finally
{
client.disconnect();
}
}