mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
补充HADataSource的测试
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@892 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user