use of siena.SienaException in project siena by mandubian.
the class GaeTest method testTransactionDeleteFailure.
public void testTransactionDeleteFailure() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
pm.insert(accFrom);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
pm.delete(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);
}
use of siena.SienaException in project siena by mandubian.
the class GaeTest method testTransactionUpdateBatch.
public void testTransactionUpdateBatch() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
pm.insert(accFrom);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
accFrom.amount -= 100L;
pm.update(accFrom);
pm.commitTransaction();
} catch (SienaException e) {
pm.rollbackTransaction();
fail();
} finally {
pm.closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertTrue(900L == accFromAfter.amount);
}
use of siena.SienaException in project siena by mandubian.
the class GaeTest method testTransactionInsert.
public void testTransactionInsert() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
accFrom.amount = 1000L;
pm.insert(accFrom);
pm.commitTransaction();
} catch (SienaException e) {
pm.rollbackTransaction();
fail();
} finally {
pm.closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertTrue(1000L == accFromAfter.amount);
}
use of siena.SienaException in project siena by mandubian.
the class GaeTest method testTransactionDeleteBatchFailure.
public void testTransactionDeleteBatchFailure() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
pm.insert(accFrom);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
pm.delete(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);
}
use of siena.SienaException in project siena by mandubian.
the class SienaRemoteTest method testFailSecurity.
public void testFailSecurity() {
MockPersistenceManager mock = new MockPersistenceManager();
PersistenceManagerFactory.install(mock, Person.class);
RemotePersistenceManager remote = new RemotePersistenceManager();
Properties properties = new Properties();
properties.setProperty("connector", MockConnector.class.getName());
properties.setProperty("serializer", MockConnector.class.getName());
properties.setProperty("key", "siena");
remote.init(properties);
MockConnector.key = "1234";
try {
remote.createQuery(Person.class).fetch();
} catch (SienaException e) {
return;
}
fail("It should have failed due to invalid hash");
}
Aggregations