use of com.ctrip.platform.dal.dao.client.DalTransactionManager in project dal by ctripcorp.
the class DalTransactionManagerTest method testGetConnection.
@Test
public void testGetConnection() {
final DalHints hints = new DalHints();
try {
final DalTransactionManager test = new DalTransactionManager(getDalConnectionManager());
assertFalse(DalTransactionManager.isInTransaction());
ConnectionAction<?> action = new ConnectionAction<Object>() {
public Object execute() throws Exception {
Assert.assertNotNull(test.getConnection(hints, DalEventEnum.BATCH_CALL));
return null;
}
};
action.operation = DalEventEnum.EXECUTE;
test.doInTransaction(action, hints);
} catch (Exception e) {
fail();
e.printStackTrace();
}
}
use of com.ctrip.platform.dal.dao.client.DalTransactionManager in project dal by ctripcorp.
the class DalTransactionManagerTest method testGetCurrentDbMeta.
@Test
public void testGetCurrentDbMeta() {
final DalHints hints = new DalHints();
try {
final DalTransactionManager test = new DalTransactionManager(getDalConnectionManager());
assertFalse(DalTransactionManager.isInTransaction());
ConnectionAction<?> action = new ConnectionAction<Object>() {
public Object execute() throws Exception {
assertNotNull(DalTransactionManager.getCurrentDbMeta());
return null;
}
};
action.operation = DalEventEnum.EXECUTE;
test.doInTransaction(action, hints);
} catch (Exception e) {
fail();
e.printStackTrace();
}
assertFalse(DalTransactionManager.isInTransaction());
assertNull(DalTransactionManager.getCurrentDbMeta());
}
use of com.ctrip.platform.dal.dao.client.DalTransactionManager in project dal by ctripcorp.
the class DalTransactionManagerTest method testDoInTransactionFail.
@Test
public void testDoInTransactionFail() {
final DalHints hints = new DalHints();
try {
final DalTransactionManager test = new DalTransactionManager(getDalConnectionManager());
assertFalse(DalTransactionManager.isInTransaction());
ConnectionAction<?> action = new ConnectionAction<Object>() {
public Object execute() throws Exception {
throw new NullPointerException("test");
}
};
action.operation = DalEventEnum.EXECUTE;
test.doInTransaction(action, hints);
fail();
} catch (Exception e) {
assertFalse(DalTransactionManager.isInTransaction());
e.printStackTrace();
}
}
use of com.ctrip.platform.dal.dao.client.DalTransactionManager in project dal by ctripcorp.
the class DalTransactionManagerTest method testDoInTransaction.
@Test
public void testDoInTransaction() {
final DalHints hints = new DalHints();
try {
final DalTransactionManager test = new DalTransactionManager(getDalConnectionManager());
assertFalse(DalTransactionManager.isInTransaction());
ConnectionAction<?> action = new ConnectionAction<Object>() {
public Object execute() throws Exception {
assertNotNull(DalTransactionManager.getCurrentDbMeta());
return null;
}
};
action.operation = DalEventEnum.EXECUTE;
test.doInTransaction(action, hints);
} catch (Exception e) {
e.printStackTrace();
fail();
}
assertFalse(DalTransactionManager.isInTransaction());
assertNull(DalTransactionManager.getCurrentDbMeta());
}
use of com.ctrip.platform.dal.dao.client.DalTransactionManager in project dal by ctripcorp.
the class ConnectionActionTest method testPopulateDbMetaInTransaction.
@Test
public void testPopulateDbMetaInTransaction() {
TestConnectionAction test = new TestConnectionAction();
try {
DalTransactionManager tranManager = new DalTransactionManager(getDalConnectionManager());
tranManager.doInTransaction(test, new DalHints());
// assertNotNull(test.entry.getDatabaseName());
assertNotNull((test.entry).getDatabaseName());
//assertNotNull(test.entry.getTag().get(LogEntry.TAG_USER_NAME)); be removed
//assertNotNull(test.entry.getTag().get(LogEntry.TAG_SERVER_ADDRESS)); be removed
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
Aggregations