1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.sftp;
12
13 import static org.junit.Assert.assertFalse;
14 import static org.junit.Assert.assertTrue;
15
16 import java.util.Arrays;
17 import java.util.Collection;
18
19 import org.junit.Test;
20 import org.junit.runners.Parameterized.Parameters;
21 import org.mule.transport.sftp.notification.SftpTransportNotificationTestListener;
22
23
24
25
26 public class SftpNotificationFunctionalTestCase extends AbstractSftpTestCase
27 {
28
29 private static final long TIMEOUT = 15000;
30
31
32 private final static int SEND_SIZE = 1024 * 1024 * 2;
33
34 public SftpNotificationFunctionalTestCase(ConfigVariant variant, String configResources)
35 {
36 super(variant, configResources);
37 }
38
39 @Parameters
40 public static Collection<Object[]> parameters()
41 {
42 return Arrays.asList(new Object[][]{
43 {ConfigVariant.SERVICE, "mule-sftp-notification-test-config-service.xml"},
44 {ConfigVariant.FLOW, "mule-sftp-notification-test-config-flow.xml"}
45 });
46 }
47
48 @Override
49 protected void doSetUp() throws Exception
50 {
51 super.doSetUp();
52
53 initEndpointDirectory("inboundEndpoint");
54
55 SftpTransportNotificationTestListener.reset();
56 }
57
58
59
60
61 @Test
62 public void testNotification() throws Exception
63 {
64 executeBaseTest("inboundEndpoint", "vm://test.upload", FILE_NAME, SEND_SIZE, "receiving", TIMEOUT);
65 }
66
67
68
69
70 @Override
71 protected void executeBaseAssertionsBeforeCall()
72 {
73
74 super.executeBaseAssertionsBeforeCall();
75
76
77 assertFalse(SftpTransportNotificationTestListener.gotSftpPutNotification());
78 assertFalse(SftpTransportNotificationTestListener.gotSftpRenameNotification());
79 assertFalse(SftpTransportNotificationTestListener.gotSftpGetNotification());
80 assertFalse(SftpTransportNotificationTestListener.gotSftpDeleteNotification());
81 }
82
83
84
85
86 @Override
87 protected void executeBaseAssertionsAfterCall(int sendSize, int receivedSize)
88 {
89
90 super.executeBaseAssertionsAfterCall(sendSize, receivedSize);
91
92
93 assertTrue(SftpTransportNotificationTestListener.gotSftpPutNotification());
94 assertTrue(SftpTransportNotificationTestListener.gotSftpRenameNotification());
95 assertTrue(SftpTransportNotificationTestListener.gotSftpGetNotification());
96 assertTrue(SftpTransportNotificationTestListener.gotSftpDeleteNotification());
97 }
98 }