Search in sources :

Example 31 with SienaException

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

Example 32 with SienaException

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

Example 33 with SienaException

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

Example 34 with SienaException

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

Example 35 with SienaException

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

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