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 public class SftpNoOutboundDirectoryTestCase extends AbstractSftpDataIntegrityTestCase
25 {
26
27 private static final String ENDPOINT_NAME = "inboundEndpoint";
28
29 @Override
30 protected String getConfigResources()
31 {
32 return "dataintegrity/sftp-no-outbound-directory-config.xml";
33 }
34
35 @Override
36 protected void doSetUp() throws Exception
37 {
38 super.doSetUp();
39
40
41 initEndpointDirectory(ENDPOINT_NAME);
42 }
43
44
45
46
47 @Test
48 public void testNoOutboundDirectory() throws Exception
49 {
50 MuleClient muleClient = new MuleClient(muleContext);
51
52
53
54 Exception exception = dispatchAndWaitForException(new DispatchParameters(ENDPOINT_NAME, null),
55 "sftp", "service");
56 assertNotNull(exception);
57
58 assertTrue("expected DispatchException, but got " + exception.getClass().toString(),
59 exception instanceof DispatchException);
60 assertTrue("expected IOException, but got " + exception.getCause().getClass().toString(),
61 exception.getCause() instanceof IOException);
62 assertTrue("wrong starting message : " + exception.getCause().getMessage(), exception.getCause()
63 .getMessage()
64 .startsWith("Error 'No such file' occurred when trying to CDW to '"));
65 assertTrue("wrong ending message : " + exception.getCause().getMessage(), exception.getCause()
66 .getMessage()
67 .endsWith("/DIRECTORY-MISSING'."));
68
69 SftpClient sftpClient = getSftpClient(muleClient, ENDPOINT_NAME);
70 try
71 {
72 ImmutableEndpoint endpoint = (ImmutableEndpoint) muleClient.getProperty(ENDPOINT_NAME);
73 assertTrue("The inbound file should still exist", super.verifyFileExists(sftpClient,
74 endpoint.getEndpointURI(), FILE_NAME));
75 }
76 finally
77 {
78 sftpClient.disconnect();
79 }
80 }
81
82 }