Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * $Id: SftpTempDirFunctionalTestCase.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;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 
 import org.junit.Test;
 
 {
 
     private static final String OUTBOUND_ENDPOINT_NAME = "outboundEndpoint";
     private static final String INBOUND_ENDPOINT_NAME = "inboundEndpoint";
     private static final String INBOUND_ENDPOINT_NAME2 = "inboundEndpoint2";
     private static final String OUTBOUND_ENDPOINT_NAME2 = "outboundEndpoint2";
     private static final String TEMP_DIR = "uploading";
 
     public SftpTempDirFunctionalTestCase(ConfigVariant variantString configResources)
     {
         super(variantconfigResources);
     }
 
     @Parameters
     public static Collection<Object[]> parameters()
     {
         return Arrays.asList(new Object[][]{{."mule-sftp-temp-dir-config-service.xml"},
             {."mule-sftp-temp-dir-config-flow.xml"}});
     }
 
     @Override
     protected void doSetUp() throws Exception
     {
         super.doSetUp();
 
     }
 
     @Test
     public void testTempDirInbound() throws Exception
     {
         MuleClient muleClient = new MuleClient();
 
         p.setSftpConnector("sftpCustomConnectorTempDirInbound");
         dispatchAndWaitForDelivery(p);
 
         // Verify inbound
         SftpClient sftpClientInbound = getSftpClient(muleClient);
         ImmutableEndpoint endpointInbound = (ImmutableEndpointmuleClient.getProperty();
         try
         {
             assertTrue("The temp directory should have been created",
                 tempDirectoryExists(sftpClientInboundmuleClient));
             assertFalse(
                 "No file should exist in the temp directory",
                 super.verifyFileExists(sftpClientInbound, endpointInbound.getEndpointURI().getPath()
                                                           + "/uploading"));
             assertFalse("The file should not exist in the source directory",
                 super.verifyFileExists(sftpClientInboundendpointInbound.getEndpointURI(), ));
         }
         finally
         {
             sftpClientInbound.disconnect();
         }
 
         // Verify outbound
         SftpClient sftpClientOutbound = getSftpClient(muleClient);
         ImmutableEndpoint endpointOutbound = (ImmutableEndpointmuleClient.getProperty();
         try
         {
             assertFalse("The temp directory should not have been created",
                 tempDirectoryExists(sftpClientOutboundmuleClient));
             assertTrue("The file should exist in the final destination : " + ,
                 super.verifyFileExists(sftpClientOutboundendpointOutbound.getEndpointURI(), ));
         }
         finally
         {
             sftpClientOutbound.disconnect();
         }
    }
    @Test
    public void testTempDirOutbound() throws Exception
    {
        MuleClient muleClient = new MuleClient();
        p.setSftpConnector("sftpCustomConnector");
        dispatchAndWaitForDelivery(p);
        // Verify inbound
        SftpClient sftpClientInbound = getSftpClient(muleClient);
        ImmutableEndpoint endpointInbound = (ImmutableEndpointmuleClient.getProperty();
        try
        {
            assertFalse("The temp directory should not have been created",
                tempDirectoryExists(sftpClientInboundmuleClient));
            assertFalse("The file should not exist in the source directory",
                super.verifyFileExists(sftpClientInboundendpointInbound.getEndpointURI(), ));
        }
        finally
        {
            sftpClientInbound.disconnect();
        }
        // Verify outbound
        SftpClient sftpClientOutbound = getSftpClient(muleClient);
        ImmutableEndpoint endpointOutbound = (ImmutableEndpointmuleClient.getProperty();
        try
        {
            assertTrue("The temp directory should have been created",
                tempDirectoryExists(sftpClientOutboundmuleClient));
            assertTrue("The file should exist in the final destination",
                super.verifyFileExists(sftpClientOutboundendpointOutbound.getEndpointURI(), ));
        }
        finally
        {
            sftpClientOutbound.disconnect();
        }
    }
    private boolean tempDirectoryExists(SftpClient sftpClientMuleClient muleClientString endpointName)
        throws IOException
    {
        try
        {
            EndpointURI endpointURI = getUriByEndpointName(muleClientendpointName);
            sftpClient.changeWorkingDirectory(endpointURI.getPath() + "/" + );
            return true;
        }
        catch (IOException f)
        {
            return false;
        }
    }
New to GrepCode? Check out our FAQ X