Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * $Id: SftpInvalidInboundEndpointTestCase.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.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
    private static final int NO_OF_INVALID_ATTEMPTS = 50;
    public SftpInvalidInboundEndpointTestCase(ConfigVariant variantString configResources)
    {
        super(variantconfigResources);
    }
    @Parameters
    public static Collection<Object[]> parameters()
    {
        return Arrays.asList(new Object[][]{{.,
            "dataintegrity/sftp-invalid-inbound-endpoint-config.xml"}});
    }
    @Test
    public void testInvalidInboundEndpoint() throws Exception
    {
        String expectedStartOfErrorMessage = "Error 'No such file' occurred when trying to CDW";
        MuleRegistry registry = .getRegistry();
        SftpConnector c = (SftpConnectorregistry.lookupConnector("sftp");
        assertNotNull(c);
        EndpointBuilder epb = registry.lookupEndpointBuilder("InvalidEndpoint");
        InboundEndpoint ep = epb.buildInboundEndpoint();
        // Verify that failed creations of sftp-clients don't leak resources (e.g.
        // ssh-servers)
        // In v2.2.1-RC2 this tests fails after 132 attempts on a Mac OSX 10.6
        // machine
        for (int i = 0; i < i++)
        {
            if (.isDebugEnabled())
                .debug("CreateSftpClient invalid atempt #" + i + " of " + );
            try
            {
                c.createSftpClient(ep);
                fail("Should have received an exception here!!!");
            }
            catch (IOException ioe)
            {
                String actualStartOfErrorMessage = ioe.getMessage().substring(0,
                    expectedStartOfErrorMessage.length());
                assertEquals(expectedStartOfErrorMessageactualStartOfErrorMessage);
            }
        }
    }
New to GrepCode? Check out our FAQ X