mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
完善mock和测试
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@797 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -36,6 +36,8 @@ public class MockStatement implements Statement {
|
||||
private SQLWarning warnings;
|
||||
private String cursorName;
|
||||
private int updateCount;
|
||||
private int fetchDirection;
|
||||
private int fetchSize;
|
||||
|
||||
public MockStatement(Connection connection){
|
||||
super();
|
||||
@@ -236,111 +238,161 @@ public class MockStatement implements Statement {
|
||||
|
||||
@Override
|
||||
public boolean getMoreResults() throws SQLException {
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFetchDirection(int direction) throws SQLException {
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
|
||||
this.fetchDirection = direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFetchDirection() throws SQLException {
|
||||
return 0;
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return fetchDirection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFetchSize(int rows) throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
this.fetchSize = rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFetchSize() throws SQLException {
|
||||
return 0;
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return fetchSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getResultSetConcurrency() throws SQLException {
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getResultSetType() throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBatch(String sql) throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBatch() throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] executeBatch() throws SQLException {
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMoreResults(int current) throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet getGeneratedKeys() throws SQLException {
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return new MockResultSet(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int executeUpdate(String sql, String[] columnNames) throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String sql, int[] columnIndexes) throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String sql, String[] columnNames) throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getResultSetHoldability() throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -351,12 +403,16 @@ public class MockStatement implements Statement {
|
||||
|
||||
@Override
|
||||
public void setPoolable(boolean poolable) throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPoolable() throws SQLException {
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user