View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.jdbc;
8   
9   import org.mule.api.transport.Connector;
10  import org.mule.tck.util.MuleDerbyTestUtils;
11  import org.mule.transport.AbstractConnectorTestCase;
12  
13  import java.util.HashMap;
14  import java.util.Map;
15  
16  import org.apache.derby.jdbc.EmbeddedDataSource;
17  
18  public class JdbcConnectorTestCase extends AbstractConnectorTestCase
19  {
20  
21      private static final String DATABASE_NAME = "embeddedDb";
22  
23      @Override
24      protected void doSetUp() throws Exception
25      {
26          MuleDerbyTestUtils.createDataBase(DATABASE_NAME);
27          super.doSetUp();
28      }
29  
30      @Override
31      protected void doTearDown() throws Exception
32      {
33          MuleDerbyTestUtils.cleanupDerbyDb(DATABASE_NAME);
34          super.doTearDown();
35      }
36      
37      @Override
38      public Connector createConnector() throws Exception
39      {
40          JdbcConnector c = new JdbcConnector(muleContext);
41          EmbeddedDataSource embeddedDS = new EmbeddedDataSource();
42          embeddedDS.setDatabaseName(DATABASE_NAME);
43          c.setName("JdbcConnector");
44          c.setDataSource(embeddedDS);
45          c.setPollingFrequency(1000);
46          return c;
47      }
48  
49      public Object getValidMessage() throws Exception
50      {
51          Map map = new HashMap();
52          return map;
53      }
54  
55      public String getTestEndpointURI()
56      {
57          return "jdbc://test?sql=SELECT * FROM TABLE";
58      }
59  }