1
2
3
4
5
6
7 package org.mule.transport.sftp.dataintegrity;
8
9 import org.mule.api.transport.DispatchException;
10 import org.mule.module.client.MuleClient;
11 import org.mule.transport.sftp.SftpClient;
12
13 import java.io.IOException;
14
15 import org.junit.Test;
16
17 import static org.junit.Assert.assertEquals;
18 import static org.junit.Assert.assertNotNull;
19 import static org.junit.Assert.assertTrue;
20
21
22
23
24 public class SftpCantCreateTempDirectoryTestCase extends AbstractSftpDataIntegrityTestCase
25 {
26
27 private static String INBOUND_ENDPOINT_NAME = "inboundEndpoint";
28 private static String OUTBOUND_ENDPOINT_NAME = "outboundEndpoint";
29
30 @Override
31 protected String getConfigResources()
32 {
33 return "dataintegrity/sftp-dataintegrity-common-with-tempdir-config.xml";
34 }
35
36 @Override
37 protected void doSetUp() throws Exception
38 {
39 super.doSetUp();
40
41
42 initEndpointDirectory(INBOUND_ENDPOINT_NAME);
43 initEndpointDirectory(OUTBOUND_ENDPOINT_NAME);
44 }
45
46
47
48
49
50
51
52 @Test
53 public void testCantCreateTempDirectory() throws Exception
54 {
55 MuleClient muleClient = new MuleClient(muleContext);
56
57 SftpClient sftpClient = getSftpClient(muleClient, OUTBOUND_ENDPOINT_NAME);
58
59 try
60 {
61
62
63 remoteChmod(muleClient, sftpClient, OUTBOUND_ENDPOINT_NAME, 00500);
64
65
66
67
68 Exception exception = dispatchAndWaitForException(new DispatchParameters(INBOUND_ENDPOINT_NAME,
69 OUTBOUND_ENDPOINT_NAME), "sftp", "service");
70 assertNotNull(exception);
71 assertTrue("expected DispatchException, but got : " + exception.getClass().toString(),
72 exception instanceof DispatchException);
73 assertTrue("expected IOException, but got : " + exception.getCause().getClass().toString(),
74 exception.getCause() instanceof IOException);
75 assertEquals("Could not create the directory 'uploading', caused by: Permission denied",
76 exception.getCause().getMessage());
77
78 verifyInAndOutFiles(muleClient, INBOUND_ENDPOINT_NAME, OUTBOUND_ENDPOINT_NAME, true, false);
79 }
80 finally
81 {
82 sftpClient.disconnect();
83 }
84 }
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 }