Ejemplo n.º 1
0
 public void commit(boolean required) throws SQLException {
   if (closed) throw new ExecutorException("Cannot commit, transaction is already closed");
   clearLocalCache();
   flushStatements();
   if (required) {
     transaction.commit();
   }
 }
 @Test
 public void shouldEnsureThatCallsToManagedTransactionAPIDoNotForwardToManagedConnections()
     throws Exception {
   TransactionFactory tf = new ManagedTransactionFactory();
   tf.setProperties(new Properties());
   Transaction tx = tf.newTransaction(conn);
   assertEquals(conn, tx.getConnection());
   tx.commit();
   tx.rollback();
   tx.close();
   verify(conn).close();
 }
 @Test
 public void
     shouldEnsureThatCallsToManagedTransactionAPIDoNotForwardToManagedConnectionsAndDoesNotCloseConnection()
         throws Exception {
   TransactionFactory tf = new ManagedTransactionFactory();
   Properties props = new Properties();
   props.setProperty("closeConnection", "false");
   tf.setProperties(props);
   Transaction tx = tf.newTransaction(conn);
   assertEquals(conn, tx.getConnection());
   tx.commit();
   tx.rollback();
   tx.close();
   verifyNoMoreInteractions(conn);
 }