use of siena.SienaException in project siena by mandubian.
the class GaeAsyncTest method testSearchSingleFieldEndException.
public void testSearchSingleFieldEndException() {
Discovery4Search[] discs = new Discovery4Search[5];
discs[0] = new Discovery4Search("alpha", LongAutoID_CURIE);
discs[1] = new Discovery4Search("beta", LongAutoID_CURIE);
discs[2] = new Discovery4Search("alphagamma", LongAutoID_CURIE);
discs[3] = new Discovery4Search("delta", LongAutoID_CURIE);
discs[4] = new Discovery4Search("eta", LongAutoID_CURIE);
pm.insert((Object[]) discs).get();
try {
QueryAsync<Discovery4Search> query = pm.createQuery(Discovery4Search.class).search("*gamma", "name");
query.fetch();
} catch (SienaException ex) {
return;
}
fail();
}
use of siena.SienaException in project siena by mandubian.
the class BaseTest method testTransactionDelete.
public void testTransactionDelete() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
TransactionAccountTo accTo = new TransactionAccountTo(1000L);
pm.insert(accFrom, accTo);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
pm.delete(accFrom);
pm.delete(accTo);
pm.commitTransaction();
} catch (SienaException e) {
pm.rollbackTransaction();
fail();
} finally {
pm.closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertNull(accFromAfter);
TransactionAccountTo accToAfter = pm.getByKey(TransactionAccountTo.class, accTo.id);
assertNull(accToAfter);
}
use of siena.SienaException in project siena by mandubian.
the class BaseTestNoAutoInc_10_TRANSACTION method testTransactionSaveFailure.
public void testTransactionSaveFailure() {
if (supportsTransaction()) {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
TransactionAccountTo accTo = new TransactionAccountTo(1000L);
pm.insert(accFrom, accTo);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
accFrom.amount -= 100L;
pm.save(accFrom);
accTo.amount += 100L;
pm.save(accTo);
throw new SienaException("test");
} catch (SienaException e) {
pm.rollbackTransaction();
} finally {
pm.closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertTrue(1000L == accFromAfter.amount);
TransactionAccountTo accToAfter = pm.getByKey(TransactionAccountTo.class, accTo.id);
assertTrue(1000L == accToAfter.amount);
}
}
use of siena.SienaException in project siena by mandubian.
the class BaseTestNoAutoInc_10_TRANSACTION method testTransactionUpdate.
public void testTransactionUpdate() {
if (supportsTransaction()) {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
TransactionAccountTo accTo = new TransactionAccountTo(1000L);
pm.insert(accFrom, accTo);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
accFrom.amount -= 100L;
pm.update(accFrom);
accTo.amount += 100L;
pm.update(accTo);
pm.commitTransaction();
} catch (SienaException e) {
pm.rollbackTransaction();
fail();
} finally {
pm.closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertTrue(900L == accFromAfter.amount);
TransactionAccountTo accToAfter = pm.getByKey(TransactionAccountTo.class, accTo.id);
assertTrue(1100L == accToAfter.amount);
}
}
use of siena.SienaException in project siena by mandubian.
the class BaseTestNoAutoInc_10_TRANSACTION method testTransactionDelete.
public void testTransactionDelete() {
if (supportsTransaction()) {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
TransactionAccountTo accTo = new TransactionAccountTo(1000L);
pm.insert(accFrom, accTo);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
pm.delete(accFrom);
pm.delete(accTo);
pm.commitTransaction();
} catch (SienaException e) {
pm.rollbackTransaction();
fail();
} finally {
pm.closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertNull(accFromAfter);
TransactionAccountTo accToAfter = pm.getByKey(TransactionAccountTo.class, accTo.id);
assertNull(accToAfter);
}
}
Aggregations