MuleClient muleClient = new MuleClient(muleContext);
// Must create the temp directory before we change the access rights
createRemoteDirectory(muleClient, OUTBOUND_ENDPOINT_NAME, "uploading");
SftpClient sftpClient = getSftpClient(muleClient, OUTBOUND_ENDPOINT_NAME);
try
{
// change the chmod to "dr-x------" on the outbound-directory
remoteChmod(muleClient, sftpClient, 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(muleClient, INBOUND_ENDPOINT_NAME, OUTBOUND_ENDPOINT_NAME, true, false);
ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(OUTBOUND_ENDPOINT_NAME);
assertFalse("The inbound file should not be left in the TEMP-dir", super.verifyFileExists(
sftpClient, endpoint.getEndpointURI().getPath() + "/" + TEMP_DIR, FILE_NAME));
}
finally
{
sftpClient.disconnect();
}
}