Package siena.base.test.model

Examples of siena.base.test.model.TransactionAccountFromModel


    assertTrue(bob1.city == null);
    assertTrue(bob1.n == 0);
  }

  public void testTransactionSave() {
    TransactionAccountFromModel accFrom = new TransactionAccountFromModel(1000L);
    TransactionAccountToModel accTo = new TransactionAccountToModel(1000L);
   
    accFrom.insert();
    accTo.insert();
 
    try {
      accFrom.getPersistenceManager().beginTransaction();
      accFrom.amount-=100L;
      accFrom.save();
      accTo.amount+=100L;
      accTo.save();
      accFrom.getPersistenceManager().commitTransaction();
    }catch(SienaException e){
      accFrom.getPersistenceManager().rollbackTransaction();
      fail();
    }finally{
      accFrom.getPersistenceManager().closeConnection();
    }
   
    TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
    assertTrue(900L == accFromAfter.amount);
    TransactionAccountTo accToAfter = pm.getByKey(TransactionAccountTo.class, accTo.id);
View Full Code Here


    TransactionAccountTo accToAfter = pm.getByKey(TransactionAccountTo.class, accTo.id);
    assertTrue(1100L == accToAfter.amount);
  }
 
  public void testTransactionSaveFailure() {
    TransactionAccountFromModel accFrom = new TransactionAccountFromModel(1000L);
    TransactionAccountToModel accTo = new TransactionAccountToModel(1000L);
    accFrom.insert();
    accTo.insert();
 
    try {
      accFrom.getPersistenceManager().beginTransaction();
      accFrom.amount-=100L;
      accFrom.save();
      accTo.amount+=100L;
      accTo.save();
      throw new SienaException("test");
    }catch(SienaException e){
      accFrom.getPersistenceManager().rollbackTransaction();
    }finally{
      accFrom.getPersistenceManager().closeConnection();
    }
   
    TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
    assertTrue(1000L == accFromAfter.amount);
    TransactionAccountTo accToAfter = pm.getByKey(TransactionAccountTo.class, accTo.id);
View Full Code Here

  }


  // SPECIFIC TESTS FOR GAE (transaction on one entity in a given group)
  public void testTransactionSave() {
    TransactionAccountFromModel accFrom = new TransactionAccountFromModel(1000L);
   
    accFrom.insert();
 
    try {
      accFrom.getPersistenceManager().beginTransaction();
      accFrom.amount-=100L;
      accFrom.save();
      accFrom.getPersistenceManager().commitTransaction();
    }catch(SienaException e){
      accFrom.getPersistenceManager().rollbackTransaction();
      fail();
    }finally{
      accFrom.getPersistenceManager().closeConnection();
    }
   
    TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
    assertTrue(900L == accFromAfter.amount);
View Full Code Here

    assertTrue(900L == accFromAfter.amount);

  }
 
  public void testTransactionSaveFailure() {
    TransactionAccountFromModel accFrom = new TransactionAccountFromModel(1000L);
    accFrom.insert();
 
    try {
      accFrom.getPersistenceManager().beginTransaction();
      accFrom.amount-=100L;
      accFrom.save();
      throw new SienaException("test");
    }catch(SienaException e){
      accFrom.getPersistenceManager().rollbackTransaction();
    }finally{
      accFrom.getPersistenceManager().closeConnection();
    }
   
    TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
    assertTrue(1000L == accFromAfter.amount);
  }
View Full Code Here

TOP

Related Classes of siena.base.test.model.TransactionAccountFromModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.