View Javadoc

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