Package siena.base.test.model

Examples of siena.base.test.model.TransactionAccountFrom


    }
  }
 
  public void testTransactionUpdateBatch() {
    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;
        accTo.amount+=100L;
        pm.update(accFrom, 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);
    }
  }
View Full Code Here


    }
  }
 
  public void testTransactionUpdateBatchFailure() {
    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;
        accTo.amount+=100L;
        pm.update(accFrom, 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);
    }
  }
View Full Code Here

    }
  }
 
  public void testTransactionSaveBatch() {
    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;
        accTo.amount+=100L;
        pm.save(accFrom, 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);
    }
  }
View Full Code Here

    }
  }
 
  public void testTransactionSaveBatchFailure() {
    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;
        accTo.amount+=100L;
        pm.save(accFrom, 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);
    }
  }
View Full Code Here

      fail();
    }finally{
      accFrom.getPersistenceManager().closeConnection();
    }
   
    TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
    assertTrue(900L == accFromAfter.amount);

  }
View Full Code Here

      accFrom.getPersistenceManager().rollbackTransaction();
    }finally{
      accFrom.getPersistenceManager().closeConnection();
    }
   
    TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
    assertTrue(1000L == accFromAfter.amount);
  }
View Full Code Here

    fail();
  }
 
  @Override
  public void testTransactionUpdate() {
    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);
  }
View Full Code Here

    assertTrue(900L == accFromAfter.amount);
  }
 
  @Override
  public void testTransactionUpdateFailure() {
    TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
    pm.insert(accFrom);
 
    try {
      pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
      accFrom.amount-=100L;
      pm.update(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);
  }
View Full Code Here

    TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
    assertTrue(1000L == accFromAfter.amount);
  }
 
  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);
  }
View Full Code Here

    TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
    assertTrue(1000L == accFromAfter.amount);
  }
 
  public void testTransactionInsertFailure() {
    TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
 
    try {
      pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
      accFrom.amount=1000L;
      pm.insert(accFrom);
      throw new SienaException("test");
    }catch(SienaException e){
      pm.rollbackTransaction();
    }finally{
      pm.closeConnection();
    }
   
    TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
    assertNull(accFromAfter);

  }
View Full Code Here

TOP

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

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.