Ejemplo n.º 1
0
 protected Connection getConnection(Log statementLog) throws SQLException {
   Connection connection = transaction.getConnection();
   if (statementLog.isDebugEnabled() || connectionLog.isDebugEnabled()) {
     return ConnectionLogger.newInstance(connection, statementLog);
   } else {
     return connection;
   }
 }
 @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);
 }