Search in sources :

Example 1 with OneLayerExceptionDalCommand

use of com.ctrip.platform.dal.dao.client.DalCommand.nesting.normal.OneLayerExceptionDalCommand in project dal by ctripcorp.

the class DalCommandTest method testThreeLayerExceptionTransaction.

// Three layer transaction throws exception
@Test
public void testThreeLayerExceptionTransaction() throws Exception {
    DalClient client = DalClientFactory.getClient(dbName);
    try {
        client.execute(new OneLayerExceptionDalCommand(), new DalHints());
        Assert.fail();
    } catch (Throwable e) {
        System.out.println(e.getMessage());
        Assert.assertTrue(e instanceof BatchUpdateException);
        Assert.assertTrue(e.getMessage().equals("Data truncation: Data too long for column 'Name' at row 1"));
        Assert.assertTrue(isCurrentTransactionNull());
    }
}
Also used : DalClient(com.ctrip.platform.dal.dao.DalClient) DalHints(com.ctrip.platform.dal.dao.DalHints) OneLayerExceptionDalCommand(com.ctrip.platform.dal.dao.client.DalCommand.nesting.normal.OneLayerExceptionDalCommand) BatchUpdateException(java.sql.BatchUpdateException) Test(org.junit.Test)

Aggregations

DalClient (com.ctrip.platform.dal.dao.DalClient)1 DalHints (com.ctrip.platform.dal.dao.DalHints)1 OneLayerExceptionDalCommand (com.ctrip.platform.dal.dao.client.DalCommand.nesting.normal.OneLayerExceptionDalCommand)1 BatchUpdateException (java.sql.BatchUpdateException)1 Test (org.junit.Test)1