完善mock和测试

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@796 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-09-16 05:00:15 +00:00
parent fad33c53a8
commit a90633b176
4 changed files with 201 additions and 3 deletions
@@ -375,7 +375,9 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
statement.getAttributes().put(ATTR_UPDATE_COUNT, updateCount);
final JdbcSqlStat sqlStat = getSqlStat(statement);
sqlStat.addUpdateCount(updateCount);
if (sqlStat != null) {
sqlStat.addUpdateCount(updateCount);
}
}
return updateCount;
@@ -33,6 +33,9 @@ public class MockStatement implements Statement {
private int maxRows;
private int queryTimeout;
private boolean escapeProcessing;
private SQLWarning warnings;
private String cursorName;
private int updateCount;
public MockStatement(Connection connection){
super();
@@ -163,17 +166,37 @@ public class MockStatement implements Statement {
@Override
public SQLWarning getWarnings() throws SQLException {
return null;
if (closed) {
throw new SQLException("stmt closed.");
}
return warnings;
}
@Override
public void clearWarnings() throws SQLException {
if (closed) {
throw new SQLException("stmt closed.");
}
warnings = null;
}
public void setWarning(SQLWarning warning) {
this.warnings = warning;
}
@Override
public void setCursorName(String name) throws SQLException {
if (closed) {
throw new SQLException("stmt closed.");
}
cursorName = name;
}
public String getCursorName() {
return cursorName;
}
@Override
@@ -191,13 +214,24 @@ public class MockStatement implements Statement {
@Override
public ResultSet getResultSet() throws SQLException {
if (closed) {
throw new SQLException("stmt closed.");
}
return new MockResultSet(this);
}
@Override
public int getUpdateCount() throws SQLException {
if (closed) {
throw new SQLException("stmt closed.");
}
return 0;
return updateCount;
}
public void setUpdateCount(int updateCount) {
this.updateCount = updateCount;
}
@Override