1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.jdbc.reliability;
12
13 import static org.junit.Assert.assertEquals;
14
15 import org.mule.tck.probe.Probe;
16
17 import java.util.Arrays;
18 import java.util.Collection;
19
20 import org.apache.commons.dbutils.handlers.ArrayHandler;
21 import org.junit.Test;
22 import org.junit.runners.Parameterized.Parameters;
23
24
25
26
27
28
29
30
31
32
33 public class InboundMessageLossTransactionsTestCase extends InboundMessageLossTestCase
34 {
35 public InboundMessageLossTransactionsTestCase(ConfigVariant variant, String configResources)
36 {
37 super(variant, configResources);
38 }
39
40 @Parameters
41 public static Collection<Object[]> parameters()
42 {
43 return Arrays.asList(new Object[][]{
44 {ConfigVariant.SERVICE, "reliability/jdbc-connector.xml, reliability/inbound-message-loss-transactions.xml"},
45 });
46 }
47
48 @Override
49 @Test
50 public void testComponentException() throws Exception
51 {
52 assertEquals(1, qr.update(jdbcConnector.getConnection(),
53 "INSERT INTO TEST(TYPE, DATA, ACK, RESULT) VALUES (4, '" + TEST_MESSAGE + "', NULL, NULL)"));
54
55 prober.check(new Probe()
56 {
57 @Override
58 public boolean isSatisfied()
59 {
60 try
61 {
62 Object[] queryResult = (Object[]) qr.query(jdbcConnector.getConnection(),
63 "SELECT DATA FROM TEST WHERE TYPE = 4 AND ACK IS NULL", new ArrayHandler());
64
65
66 return (queryResult != null && queryResult.length == 1);
67 }
68 catch (Exception e)
69 {
70 throw new RuntimeException(e);
71 }
72 }
73
74 @Override
75 public String describeFailure()
76 {
77 return "Row should not be acknowledged (marked read)";
78 }
79 });
80 }
81 }