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