1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.transport.jdbc;
12
13
14 import org.mule.api.endpoint.EndpointBuilder;
15 import org.mule.api.endpoint.InboundEndpoint;
16 import org.mule.api.service.Service;
17 import org.mule.api.transport.Connector;
18 import org.mule.endpoint.EndpointURIEndpointBuilder;
19 import org.mule.tck.testmodels.fruit.Orange;
20 import org.mule.transport.SimpleRetryConnectionStrategy;
21 import org.mule.transport.jdbc.JdbcConnector;
22
23 import javax.sql.DataSource;
24
25
26
27
28 public class JdbcConnectionTestCase extends AbstractJdbcFunctionalTestCase
29 {
30
31 protected JdbcConnector connector;
32
33 protected void emptyTable() throws Exception
34 {
35
36
37 }
38
39 public Connector createConnector() throws Exception
40 {
41 connector = (JdbcConnector)super.createConnector();
42 SimpleRetryConnectionStrategy strategy = new SimpleRetryConnectionStrategy();
43 strategy.setRetryCount(10);
44 strategy.setRetryFrequency(1000);
45 strategy.setDoThreading(true);
46 connector.setConnectionStrategy(strategy);
47 return connector;
48 }
49
50 public void testReconnection() throws Exception
51 {
52
53 Service service = getTestService("anOrange", Orange.class);
54 service.setModel(model);
55 muleContext.getRegistry().registerService(service);
56 EndpointBuilder endpointBuilder = new EndpointURIEndpointBuilder("jdbc://test?sql=SELECT * FROM TABLE", muleContext);
57 endpointBuilder.setName("test");
58 endpointBuilder.setConnector(connector);
59 InboundEndpoint endpoint = muleContext.getRegistry().lookupEndpointFactory().getInboundEndpoint(
60 endpointBuilder);
61 muleContext.start();
62 connector.registerListener(service, endpoint);
63
64
65
66
67
68
69
70
71
72 Thread.sleep(1000);
73 }
74
75 protected DataSource createDataSource() throws Exception
76 {
77 return createClientDataSource();
78 }
79
80 }