1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.ftp.reliability;
12
13 import org.mule.exception.DefaultSystemExceptionStrategy;
14 import org.mule.routing.filters.WildcardFilter;
15 import org.mule.tck.probe.PollingProber;
16 import org.mule.tck.probe.Probe;
17 import org.mule.tck.probe.Prober;
18 import org.mule.transport.ftp.AbstractFtpServerTestCase;
19
20 import java.util.Arrays;
21 import java.util.Collection;
22
23 import org.junit.Test;
24 import org.junit.runners.Parameterized.Parameters;
25
26
27
28
29
30
31
32
33
34 public class InboundMessageLossTestCase extends AbstractFtpServerTestCase
35 {
36
37 protected Prober prober = new PollingProber(10000, 100);
38
39 public InboundMessageLossTestCase(ConfigVariant variant, String configResources)
40 {
41 super(variant, configResources);
42 }
43
44 @Parameters
45 public static Collection<Object[]> parameters()
46 {
47 return Arrays.asList(new Object[][]{
48 {ConfigVariant.SERVICE, "reliability/inbound-message-loss.xml"}
49 });
50 }
51
52 @Override
53 protected void doSetUp() throws Exception
54 {
55 super.doSetUp();
56
57
58 ((DefaultSystemExceptionStrategy) muleContext.getExceptionListener()).setRollbackTxFilter(new WildcardFilter("*"));
59
60
61 createFtpServerDir("noException");
62 createFtpServerDir("transformerException");
63 createFtpServerDir("routerException");
64 createFtpServerDir("componentException");
65 }
66
67 @Test
68 public void testNoException() throws Exception
69 {
70 createFileOnFtpServer("noException/test1");
71 prober.check(new Probe()
72 {
73 @Override
74 public boolean isSatisfied()
75 {
76
77 return !fileExists("noException/test1");
78 }
79
80 @Override
81 public String describeFailure()
82 {
83 return "File should be gone";
84 }
85 });
86 }
87
88 @Test
89 public void testTransformerException() throws Exception
90 {
91 createFileOnFtpServer("transformerException/test1");
92 prober.check(new Probe()
93 {
94 @Override
95 public boolean isSatisfied()
96 {
97
98 return fileExists("transformerException/test1");
99 }
100
101 @Override
102 public String describeFailure()
103 {
104 return "File should have been restored";
105 }
106 });
107 }
108
109 @Test
110 public void testRouterException() throws Exception
111 {
112 createFileOnFtpServer("routerException/test1");
113 prober.check(new Probe()
114 {
115 @Override
116 public boolean isSatisfied()
117 {
118
119 return fileExists("routerException/test1");
120 }
121
122 @Override
123 public String describeFailure()
124 {
125 return "File should have been restored";
126 }
127 });
128 }
129
130 @Test
131 public void testComponentException() throws Exception
132 {
133 createFileOnFtpServer("componentException/test1");
134 prober.check(new Probe()
135 {
136 @Override
137 public boolean isSatisfied()
138 {
139
140
141 return !fileExists("componentException/test1");
142 }
143
144 @Override
145 public String describeFailure()
146 {
147 return "File should be gone";
148 }
149 });
150 }
151 }