Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * $Id: SftpWrongPassPhraseOnOutboundDirectoryTestCase.java 23812 2012-02-03 13:17:37Z asequeira $
   * --------------------------------------------------------------------------------------
   * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
   *
   * 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.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 
 
 
 import org.junit.Test;
Verify that the original file is not lost if the password for the outbound endpoint is wrong
 
 {
     private static String INBOUND_ENDPOINT_NAME = "inboundEndpoint";
 
     public SftpWrongPassPhraseOnOutboundDirectoryTestCase(ConfigVariant variantString configResources)
     {
         super(variantconfigResources);
     }
 
     @Parameters
     public static Collection<Object[]> parameters()
     {
         return Arrays.asList(new Object[][]{
             {."dataintegrity/sftp-wrong-passphrase-config-service.xml"},
             {."dataintegrity/sftp-wrong-passphrase-config-flow.xml"}});
     }
 
     // @Override
     // protected void doSetUp() throws Exception
     // {
     // super.doSetUp();
     //
     // // Delete the in & outbound directories
     // initEndpointDirectory(INBOUND_ENDPOINT_NAME);
     // }
 
    
The outbound directory doesn't exist. The source file should still exist

 
     @Test
     public void testWrongPassPhraseOnOutboundDirectory() throws Exception
     {
         MuleClient muleClient = new MuleClient();
         assertTrue(.isStarted());
         // Send an file to the SFTP server, which the inbound-outboundEndpoint then
         // can pick up
             null), "sftp""service");
         assertNotNull(exception);
         assertTrue("expected DispatchException, but got " + exception.getClass().toString(),
             exception instanceof DispatchException);
         assertTrue("expected IOException, but got " + exception.getCause().getClass().toString(),
             exception.getCause() instanceof IOException);
         assertTrue("wrong message : " + exception.getCause().getMessage(), exception.getCause()
             .getMessage()
             .startsWith("Error during login to"));
 
         SftpClient sftpClient = getSftpClient(muleClient);
         try
         {
             ImmutableEndpoint endpoint = (ImmutableEndpointmuleClient.getProperty();
             assertTrue("The inbound file should still exist",
                 super.verifyFileExists(sftpClientendpoint.getEndpointURI(), ));
         }
         finally
         {
             sftpClient.disconnect();
         }
     }

    
Ensures that the directory exists and is writable by deleting the directory and then recreate it. Overrides inherited behavior to use working credentials.
    protected void initEndpointDirectory(String endpointName)
        throws MuleExceptionIOExceptionSftpException
    {
        // MuleClient muleClient = new MuleClient(muleContext);
        // SftpClient sftpClient = getSftpClient(muleClient, endpointName);
        // try
        // {
        // ChannelSftp channelSftp = sftpClient.getChannelSftp();
        // try
        // {
        // recursiveDelete(muleClient, sftpClient, endpointName, "");
        // }
        // catch (IOException e)
        // {
        // if (logger.isErrorEnabled())
        // logger.error("Failed to recursivly delete endpoint " + endpointName, e);
        // }
        //
        // String path = getPathByEndpoint(muleClient, sftpClient, endpointName);
        // channelSftp.mkdir(path);
        // }
        // finally
        // {
        // sftpClient.disconnect();
        // if (logger.isDebugEnabled()) logger.debug("Done init endpoint directory: "
        // + endpointName);
        // }
    }
New to GrepCode? Check out our FAQ X