1
2
3
4
5
6
7 package org.mule.transport.sftp.dataintegrity;
8
9 import org.mule.api.endpoint.ImmutableEndpoint;
10 import org.mule.api.transport.DispatchException;
11 import org.mule.module.client.MuleClient;
12 import org.mule.transport.sftp.SftpClient;
13
14 import java.io.IOException;
15
16 import org.junit.Test;
17
18 import static org.junit.Assert.assertNotNull;
19 import static org.junit.Assert.assertTrue;
20
21
22
23
24
25 public class SftpWrongPassPhraseOnOutboundDirectoryTestCase extends AbstractSftpDataIntegrityTestCase
26 {
27
28 private static String INBOUND_ENDPOINT_NAME = "inboundEndpoint";
29
30 @Override
31 protected String getConfigResources()
32 {
33 return "dataintegrity/sftp-wrong-passphrase-config.xml";
34 }
35
36 @Override
37 protected void doSetUp() throws Exception
38 {
39 super.doSetUp();
40
41
42 initEndpointDirectory(INBOUND_ENDPOINT_NAME);
43 }
44
45
46
47
48
49
50 @Test
51 public void testWrongPassPhraseOnOutboundDirectory() throws Exception
52 {
53 MuleClient muleClient = new MuleClient(muleContext);
54 assertTrue(muleContext.isStarted());
55
56
57 final Exception exception = dispatchAndWaitForException(new DispatchParameters(INBOUND_ENDPOINT_NAME,
58 null), "sftp", "service");
59 assertNotNull(exception);
60 assertTrue("expected DispatchException, but got " + exception.getClass().toString(),
61 exception instanceof DispatchException);
62 assertTrue("expected IOException, but got " + exception.getCause().getClass().toString(),
63 exception.getCause() instanceof IOException);
64 assertTrue("wrong message : " + exception.getCause().getMessage(), exception.getCause()
65 .getMessage()
66 .startsWith("Error during login to"));
67
68 SftpClient sftpClient = getSftpClient(muleClient, INBOUND_ENDPOINT_NAME);
69 try
70 {
71 ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(INBOUND_ENDPOINT_NAME);
72 assertTrue("The inbound file should still exist", super.verifyFileExists(sftpClient,
73 endpoint.getEndpointURI(), FILE_NAME));
74 }
75 finally
76 {
77 sftpClient.disconnect();
78 }
79 }
80
81 }