Search in sources :

Example 26 with SienaException

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);
}
Also used : TransactionAccountFrom(siena.base.test.model.TransactionAccountFrom) SienaException(siena.SienaException)

Example 27 with SienaException

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);
}
Also used : TransactionAccountFrom(siena.base.test.model.TransactionAccountFrom) SienaException(siena.SienaException)

Example 28 with SienaException

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);
}
Also used : TransactionAccountFrom(siena.base.test.model.TransactionAccountFrom) SienaException(siena.SienaException)

Example 29 with SienaException

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);
}
Also used : TransactionAccountFrom(siena.base.test.model.TransactionAccountFrom) SienaException(siena.SienaException)

Example 30 with SienaException

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");
}
Also used : RemotePersistenceManager(siena.remote.RemotePersistenceManager) SienaException(siena.SienaException) Properties(java.util.Properties)

Aggregations

SienaException (siena.SienaException)214 Field (java.lang.reflect.Field)65 TransactionAccountFrom (siena.base.test.model.TransactionAccountFrom)52 ArrayList (java.util.ArrayList)46 IOException (java.io.IOException)40 SQLException (java.sql.SQLException)38 TransactionAccountTo (siena.base.test.model.TransactionAccountTo)34 SienaRestrictedApiException (siena.SienaRestrictedApiException)33 PreparedStatement (java.sql.PreparedStatement)25 ClassInfo (siena.ClassInfo)21 HashMap (java.util.HashMap)19 List (java.util.List)18 Discovery (siena.base.test.model.Discovery)18 Entity (com.google.appengine.api.datastore.Entity)15 Key (com.google.appengine.api.datastore.Key)14 ResultSet (java.sql.ResultSet)14 Id (siena.Id)14 AmazonClientException (com.amazonaws.AmazonClientException)12 Collection (java.util.Collection)10 DiscoveryStringId (siena.base.test.model.DiscoveryStringId)9