View Javadoc

1   /*
2    * $Id: TestDataSource.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.test;
12  
13  import com.mockobjects.dynamic.Mock;
14  
15  import java.io.PrintWriter;
16  import java.sql.Connection;
17  import java.sql.SQLException;
18  
19  import javax.sql.DataSource;
20  
21  public class TestDataSource implements DataSource
22  {
23  
24      public Connection getConnection() throws SQLException
25      {
26          Mock mockConnection = new Mock(Connection.class);
27          mockConnection.expectAndReturn("getAutoCommit", false);
28          mockConnection.expect("commit");
29          mockConnection.expect("close");
30  
31          return (Connection) mockConnection.proxy();
32      }
33  
34      public Connection getConnection(String username, String password) throws SQLException
35      {
36          return getConnection();
37      }
38  
39      public int getLoginTimeout() throws SQLException
40      {
41          return 0;
42      }
43  
44      public PrintWriter getLogWriter() throws SQLException
45      {
46          return null;
47      }
48  
49      public void setLoginTimeout(int seconds) throws SQLException
50      {
51          // nop
52      }
53  
54      public void setLogWriter(PrintWriter out) throws SQLException
55      {
56          // nop
57      }
58  
59      public boolean isWrapperFor(Class<?> iface) throws SQLException
60      {
61          return false;
62      }
63  
64      public <T> T unwrap(Class<T> iface) throws SQLException
65      {
66          return null;
67      }
68  }
69  
70