use of com.ctrip.platform.dal.dao.client.DalConnection in project dal by ctripcorp.
the class AutoMarkdownTest method mockDalConnection.
public DalConnection mockDalConnection() {
DalConnection conn = EasyMock.createMock(DalConnection.class);
DbMeta meta = EasyMock.createMock(DbMeta.class);
EasyMock.expect(meta.getDataBaseKeyName()).andReturn(dbName).times(1);
EasyMock.expect(meta.getDatabaseCategory()).andReturn(DatabaseCategory.MySql).times(1);
EasyMock.expect(conn.getMeta()).andReturn(meta).times(3);
EasyMock.replay(meta, conn);
return conn;
}
use of com.ctrip.platform.dal.dao.client.DalConnection in project dal by ctripcorp.
the class DalConnectionTest method testSetAutoCommit.
@Test
public void testSetAutoCommit() throws SQLException {
Connection conn = null;
try {
DalConnection test = getConnection();
test.setAutoCommit(false);
conn = test.getConn();
assertFalse(conn.getAutoCommit());
test.setAutoCommit(true);
assertTrue(conn.getAutoCommit());
} catch (Throwable e) {
fail();
e.printStackTrace();
} finally {
if (conn != null)
conn.close();
}
}
use of com.ctrip.platform.dal.dao.client.DalConnection in project dal by ctripcorp.
the class DalConnectionManagerTest method testGetNewConnection.
@Test
public void testGetNewConnection() {
boolean useMaster = true;
DalHints hints = new DalHints();
try {
DalConnectionManager test = getDalConnectionManager(noShardDb);
DalConnection conn = test.getNewConnection(hints, useMaster, DalEventEnum.BATCH_CALL);
assertNotNull(conn);
assertNotNull(conn.getConn());
conn.getConn().close();
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of com.ctrip.platform.dal.dao.client.DalConnection in project dal by ctripcorp.
the class DalTransactionTest method getDalConnection.
private DalConnection getDalConnection(int shard) throws Exception {
Connection conn = null;
conn = DalClientFactory.getDalConfigure().getLocator().getConnection("SqlSvrShard_" + shard);
return new DalConnection(conn, true, String.valueOf(shard), DbMeta.createIfAbsent(logicDbName, DalClientFactory.getDalConfigure().getDatabaseSet(logicDbName).getDatabaseCategory(), conn));
}
Aggregations