补充HADataSource的测试

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@892 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-09-20 12:39:45 +00:00
parent 63706803d8
commit c7e9863c13
@@ -22,9 +22,11 @@ public class HADataSourceTest extends TestCase {
protected void setUp() throws Exception {
dataSourceA = new DruidDataSource();
dataSourceA.setUrl("jdbc:mock:x1");
dataSourceA.setFilters("trace");
dataSourceB = new DruidDataSource();
dataSourceB.setUrl("jdbc:mock:x1");
dataSourceB.setFilters("stat");
dataSourceHA = new HADataSource();
dataSourceHA.addDataSource(dataSourceA);
@@ -71,7 +73,7 @@ public class HADataSourceTest extends TestCase {
Assert.assertEquals("cName", mockStmt.getCursorName());
Assert.assertEquals(ResultSet.FETCH_REVERSE, mockStmt.getFetchDirection());
Assert.assertEquals(202, mockStmt.getFetchSize());
{
MultiDataSourceStatement dsStmt = stmt.unwrap(MultiDataSourceStatement.class);
Assert.assertTrue(dsStmt.getId() > 0);
@@ -149,4 +151,50 @@ public class HADataSourceTest extends TestCase {
conn.close();
}
public void test_createStatement_4() throws Exception {
Connection conn = dataSourceHA.getConnection();
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE,
ResultSet.CLOSE_CURSORS_AT_COMMIT);
stmt.executeUpdate("SET @user = 'xxx'");
MockStatement mockStmt = stmt.unwrap(MockStatement.class);
Assert.assertEquals(ResultSet.TYPE_SCROLL_INSENSITIVE, mockStmt.getResultSetType());
Assert.assertEquals(ResultSet.CONCUR_UPDATABLE, mockStmt.getResultSetConcurrency());
Assert.assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, mockStmt.getResultSetHoldability());
Assert.assertEquals(ResultSet.TYPE_SCROLL_INSENSITIVE, stmt.getResultSetType());
Assert.assertEquals(ResultSet.CONCUR_UPDATABLE, stmt.getResultSetConcurrency());
Assert.assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, stmt.getResultSetHoldability());
stmt.close();
conn.close();
}
public void test_close() throws Exception {
Connection conn = dataSourceHA.getConnection();
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE,
ResultSet.CLOSE_CURSORS_AT_COMMIT);
stmt.getMaxFieldSize();
stmt.getMaxRows();
stmt.cancel();
stmt.getWarnings();
stmt.clearWarnings();
stmt.getResultSet();
stmt.getUpdateCount();
stmt.getMoreResults();
stmt.getMoreResults(1);
stmt.getResultSetConcurrency();
stmt.getResultSetHoldability();
stmt.getResultSetType();
stmt.getConnection();
stmt.getGeneratedKeys();
stmt.isClosed();
stmt.close();
conn.close();
}
}