| 1 |
// |
| 2 |
// ======================================================================== |
| 3 |
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others. |
| 4 |
// ------------------------------------------------------------------------ |
| 5 |
// All rights reserved. This program and the accompanying materials |
| 6 |
// are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
// and Apache License v2.0 which accompanies this distribution. |
| 8 |
// |
| 9 |
// The Eclipse Public License is available at |
| 10 |
// http://www.eclipse.org/legal/epl-v10.html |
| 11 |
// |
| 12 |
// The Apache License v2.0 is available at |
| 13 |
// http://www.opensource.org/licenses/apache2.0.php |
| 14 |
// |
| 15 |
// You may elect to redistribute this code under either of these licenses. |
| 16 |
// ======================================================================== |
| 17 |
// |
| 18 |
|
| 19 |
package com.acme; |
| 20 |
|
| 21 |
import java.io.PrintWriter; |
| 22 |
import java.sql.Connection; |
| 23 |
import java.sql.SQLException; |
| 24 |
import java.util.logging.Logger; |
| 25 |
import javax.sql.DataSource; |
| 26 |
|
| 27 |
/** |
| 28 |
* MockDataSource |
| 29 |
*/ |
| 30 |
public class MockDataSource implements DataSource |
| 31 |
{ |
| 32 |
|
| 33 |
/** |
| 34 |
* NOTE: JDK7+ new feature |
| 35 |
*/ |
| 36 |
@Override |
| 37 |
public Logger getParentLogger() |
| 38 |
{ |
| 39 |
return null; |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* @see javax.sql.DataSource#getConnection() |
| 44 |
*/ |
| 45 |
@Override |
| 46 |
public Connection getConnection() throws SQLException |
| 47 |
{ |
| 48 |
return null; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) |
| 53 |
*/ |
| 54 |
@Override |
| 55 |
public Connection getConnection(String username, String password) |
| 56 |
throws SQLException |
| 57 |
{ |
| 58 |
return null; |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* @see javax.sql.DataSource#getLogWriter() |
| 63 |
*/ |
| 64 |
@Override |
| 65 |
public PrintWriter getLogWriter() throws SQLException |
| 66 |
{ |
| 67 |
return null; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* @see javax.sql.DataSource#getLoginTimeout() |
| 72 |
*/ |
| 73 |
@Override |
| 74 |
public int getLoginTimeout() throws SQLException |
| 75 |
{ |
| 76 |
return 0; |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter) |
| 81 |
*/ |
| 82 |
@Override |
| 83 |
public void setLogWriter(PrintWriter out) throws SQLException |
| 84 |
{ |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* @see javax.sql.DataSource#setLoginTimeout(int) |
| 89 |
*/ |
| 90 |
@Override |
| 91 |
public void setLoginTimeout(int seconds) throws SQLException |
| 92 |
{ |
| 93 |
} |
| 94 |
|
| 95 |
@Override |
| 96 |
public boolean isWrapperFor(Class<?> iface) throws SQLException |
| 97 |
{ |
| 98 |
return false; |
| 99 |
} |
| 100 |
|
| 101 |
@Override |
| 102 |
public <T> T unwrap(Class<T> iface) throws SQLException |
| 103 |
{ |
| 104 |
return null; |
| 105 |
} |
| 106 |
} |