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