Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * $Id: SftpFilterTestCase.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;
Simple test to verify that the filter configuration works. Note that the transport uses an "early" filter to improves the performance.
    private static String INBOUND_ENDPOINT_NAME = "inboundEndpoint";
    private static String OUTBOUND_ENDPOINT_NAME = "outboundEndpoint";
    public SftpFilterTestCase(ConfigVariant variantString configResources)
    {
        super(variantconfigResources);
    }
    
    @Parameters
    public static Collection<Object[]> parameters()
    {
        return Arrays.asList(new Object[][]{
            {."mule-sftp-filter-config-service.xml"},
            {."mule-sftp-filter-config-flow.xml"}
        });
    }
    @Override
    protected void doSetUp() throws Exception
    {
        super.doSetUp();
    }
    @Test
    public void testFilter() throws Exception
    {
        MuleClient muleClient = new MuleClient();
        // Send .txt file using muleclient.dipatch directly (since the file won't be
        // delivered to the endpoint (due to filter settings) we can't wait for a
        // delivery notification....
        HashMap<StringStringtxtProps = new HashMap<StringString>(1);
        txtProps.put(.);
        muleClient.dispatch(getAddressByEndpoint(muleClient), txtProps);
        // Send .xml file
        dp.setFilename("file.xml");
        dispatchAndWaitForDelivery(dp);
        SftpClient outboundSftpClient = getSftpClient(muleClient);
        ImmutableEndpoint outboundEndpoint = (ImmutableEndpointmuleClient.getProperty();
        SftpClient inboundSftpClient = getSftpClient(muleClient);
        ImmutableEndpoint inboundEndpoint = (ImmutableEndpointmuleClient.getProperty();
        assertFalse("The xml file should not be left in the inbound directory"verifyFileExists(
            inboundSftpClientinboundEndpoint.getEndpointURI().getPath(), "file.xml"));
        assertTrue("The xml file should be in the outbound directory"verifyFileExists(outboundSftpClient,
            outboundEndpoint.getEndpointURI().getPath(), "file.xml"));
        assertTrue("The txt file should be left in the inbound directory"verifyFileExists(
            inboundSftpClientinboundEndpoint.getEndpointURI().getPath(), ));
        assertFalse("The txt file should not be in the outbound directory"verifyFileExists(
            outboundSftpClientoutboundEndpoint.getEndpointURI().getPath(), ));
    }
New to GrepCode? Check out our FAQ X