Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * $Id: 23812 2012-02-03 13:17:37Z asequeira $
   * --------------------------------------------------------------------------------------
   * Copyright (c) MuleSoft, Inc.  All rights reserved.
   * The software in this package is published under the terms of the CPAL v1.0
   * license, a copy of which has been included with this distribution in the
   * LICENSE.txt file.
 package org.mule.transport.sftp.dataintegrity;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import org.junit.Test;
Tests that files are not deleted if the final destination is not writable when using a temp directory.
     private static String INBOUND_ENDPOINT_NAME = "inboundEndpoint";
     private static String OUTBOUND_ENDPOINT_NAME = "outboundEndpoint";
     public SftpCantWriteToFinalDestAfterTempDirectoryTestCase(ConfigVariant variantString configResources)
     public static Collection<Object[]> parameters()
         return Arrays.asList(new Object[][]{
     protected void doSetUp() throws Exception
         // Delete the in & outbound directories

No write access on the outbound directory but write access to the TEMP directory. The source file should still exist and no file should exist in the TEMP directory.
     public void testCantWriteToFinalDestAfterTempDirectory() throws Exception
         MuleClient muleClient = new MuleClient();
         // Must create the temp directory before we change the access rights
         SftpClient sftpClient = getSftpClient(muleClient);
             // change the chmod to "dr-x------" on the outbound-directory
             remoteChmod(muleClientsftpClient, 00500);
             // Send an file to the SFTP server, which the inbound-outboundEndpoint
             // then can pick up
             // Expect an error, permission denied
                 ), "sftp""service");
             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());
             ImmutableEndpoint endpoint = (ImmutableEndpointmuleClient.getProperty();
             assertFalse("The inbound file should not be left in the TEMP-dir"super.verifyFileExists(
                 sftpClient, endpoint.getEndpointURI().getPath() + "/" + ));
New to GrepCode? Check out our FAQ X