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@851 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -247,10 +247,10 @@ public class MockConnection implements Connection {
|
||||
}
|
||||
|
||||
MockStatement stmt = new MockStatement(this);
|
||||
|
||||
|
||||
stmt.setResultSetType(resultSetType);
|
||||
stmt.setResultSetConcurrency(resultSetConcurrency);
|
||||
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
@@ -261,7 +261,12 @@ public class MockConnection implements Connection {
|
||||
throw new MockConnectionClosedException();
|
||||
}
|
||||
|
||||
return new MockPreparedStatement(this, sql);
|
||||
MockPreparedStatement stmt = new MockPreparedStatement(this, sql);
|
||||
|
||||
stmt.setResultSetType(resultSetType);
|
||||
stmt.setResultSetConcurrency(resultSetConcurrency);
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -270,7 +275,12 @@ public class MockConnection implements Connection {
|
||||
throw new MockConnectionClosedException();
|
||||
}
|
||||
|
||||
return new MockCallableStatement(this, sql);
|
||||
MockCallableStatement stmt = new MockCallableStatement(this, sql);
|
||||
|
||||
stmt.setResultSetType(resultSetType);
|
||||
stmt.setResultSetConcurrency(resultSetConcurrency);
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -330,7 +340,13 @@ public class MockConnection implements Connection {
|
||||
throw new MockConnectionClosedException();
|
||||
}
|
||||
|
||||
return new MockStatement(this);
|
||||
MockStatement stmt = new MockStatement(this);
|
||||
|
||||
stmt.setResultSetType(resultSetType);
|
||||
stmt.setResultSetConcurrency(resultSetConcurrency);
|
||||
stmt.setResultSetHoldability(resultSetHoldability);
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -340,7 +356,13 @@ public class MockConnection implements Connection {
|
||||
throw new MockConnectionClosedException();
|
||||
}
|
||||
|
||||
return new MockPreparedStatement(this, sql);
|
||||
MockPreparedStatement stmt = new MockPreparedStatement(this, sql);
|
||||
|
||||
stmt.setResultSetType(resultSetType);
|
||||
stmt.setResultSetConcurrency(resultSetConcurrency);
|
||||
stmt.setResultSetHoldability(resultSetHoldability);
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -350,7 +372,13 @@ public class MockConnection implements Connection {
|
||||
throw new MockConnectionClosedException();
|
||||
}
|
||||
|
||||
return new MockCallableStatement(this, sql);
|
||||
MockCallableStatement stmt = new MockCallableStatement(this, sql);
|
||||
|
||||
stmt.setResultSetType(resultSetType);
|
||||
stmt.setResultSetConcurrency(resultSetConcurrency);
|
||||
stmt.setResultSetHoldability(resultSetHoldability);
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,6 +41,7 @@ public class MockStatement implements Statement {
|
||||
|
||||
private int resultSetType;
|
||||
private int resultSetConcurrency;
|
||||
private int resultSetHoldability;
|
||||
|
||||
public MockStatement(Connection connection){
|
||||
super();
|
||||
@@ -55,7 +56,7 @@ public class MockStatement implements Statement {
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
|
||||
|
||||
return resultSetType;
|
||||
}
|
||||
|
||||
@@ -66,7 +67,6 @@ public class MockStatement implements Statement {
|
||||
public void setResultSetConcurrency(int resultSetConcurrency) {
|
||||
this.resultSetConcurrency = resultSetConcurrency;
|
||||
}
|
||||
|
||||
|
||||
public MockConnection getMockConnection() {
|
||||
return mockConnection;
|
||||
@@ -323,7 +323,6 @@ public class MockStatement implements Statement {
|
||||
return resultSetConcurrency;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addBatch(String sql) throws SQLException {
|
||||
if (closed) {
|
||||
@@ -423,7 +422,11 @@ public class MockStatement implements Statement {
|
||||
if (closed) {
|
||||
throw new SQLException("stmt closed.");
|
||||
}
|
||||
return 0;
|
||||
return resultSetHoldability;
|
||||
}
|
||||
|
||||
public void setResultSetHoldability(int resultSetHoldability) {
|
||||
this.resultSetHoldability = resultSetHoldability;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user