Mildly more realistic stubs.

pull/6/head
Brett Wooldridge 11 years ago
parent 60601d4b61
commit 39f74267ac

@ -10,12 +10,12 @@ public abstract class StubBaseConnection implements Connection
/** {@inheritDoc} */
public Statement createStatement() throws SQLException
{
return new StubStatement();
return new StubStatement(this);
}
/** {@inheritDoc} */
public PreparedStatement prepareStatement(String sql) throws SQLException
{
return new StubPreparedStatement();
return new StubPreparedStatement(this);
}
}

@ -167,7 +167,7 @@ public class StubConnection extends StubBaseConnection implements Connection
/** {@inheritDoc} */
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
{
return new StubPreparedStatement();
return new StubPreparedStatement(this);
}
/** {@inheritDoc} */
@ -229,7 +229,7 @@ public class StubConnection extends StubBaseConnection implements Connection
/** {@inheritDoc} */
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
{
return new StubPreparedStatement();
return new StubPreparedStatement(this);
}
/** {@inheritDoc} */
@ -241,19 +241,19 @@ public class StubConnection extends StubBaseConnection implements Connection
/** {@inheritDoc} */
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
{
return new StubPreparedStatement();
return new StubPreparedStatement(this);
}
/** {@inheritDoc} */
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
{
return new StubPreparedStatement();
return new StubPreparedStatement(this);
}
/** {@inheritDoc} */
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
{
return new StubPreparedStatement();
return new StubPreparedStatement(this);
}
/** {@inheritDoc} */

@ -45,6 +45,10 @@ import java.util.Calendar;
*/
public class StubPreparedStatement extends StubStatement implements PreparedStatement
{
public StubPreparedStatement(Connection connection)
{
super(connection);
}
/** {@inheritDoc} */
public ResultSet executeQuery(String sql) throws SQLException
@ -191,12 +195,6 @@ public class StubPreparedStatement extends StubStatement implements PreparedStat
return null;
}
/** {@inheritDoc} */
public Connection getConnection() throws SQLException
{
return null;
}
/** {@inheritDoc} */
public boolean getMoreResults(int current) throws SQLException
{

@ -29,6 +29,12 @@ import java.sql.Statement;
public class StubStatement implements Statement
{
private boolean closed;
private Connection connection;
public StubStatement(Connection connection)
{
this.connection = connection;
}
/** {@inheritDoc} */
public <T> T unwrap(Class<T> iface) throws SQLException
@ -197,7 +203,7 @@ public class StubStatement implements Statement
/** {@inheritDoc} */
public Connection getConnection() throws SQLException
{
return null;
return connection;
}
/** {@inheritDoc} */

Loading…
Cancel
Save