Search in sources :

Example 51 with TransactionAccountFrom

use of siena.base.test.model.TransactionAccountFrom in project siena by mandubian.

the class GaeTest method testTransactionSaveFailure.

public void testTransactionSaveFailure() {
    TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
    pm.insert(accFrom);
    try {
        pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
        accFrom.amount -= 100L;
        pm.save(accFrom);
        throw new SienaException("test");
    } catch (SienaException e) {
        pm.rollbackTransaction();
    } finally {
        pm.closeConnection();
    }
    TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
    assertTrue(1000L == accFromAfter.amount);
}
Also used : TransactionAccountFrom(siena.base.test.model.TransactionAccountFrom) SienaException(siena.SienaException)

Example 52 with TransactionAccountFrom

use of siena.base.test.model.TransactionAccountFrom in project siena by mandubian.

the class GaeTest method testTransactionInsertBatchFailure.

public void testTransactionInsertBatchFailure() {
    TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
    try {
        pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
        accFrom.amount = 1000L;
        pm.insert(accFrom);
        throw new SienaException("test");
    } catch (SienaException e) {
        pm.rollbackTransaction();
    } finally {
        pm.closeConnection();
    }
    TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
    assertNull(accFromAfter);
}
Also used : TransactionAccountFrom(siena.base.test.model.TransactionAccountFrom) SienaException(siena.SienaException)

Aggregations

SienaException (siena.SienaException)52 TransactionAccountFrom (siena.base.test.model.TransactionAccountFrom)52 TransactionAccountTo (siena.base.test.model.TransactionAccountTo)34 TransactionAccountFromModel (siena.base.test.model.TransactionAccountFromModel)4 TransactionAccountToModel (siena.base.test.model.TransactionAccountToModel)2