### Question:
LocalTransaction { public void commit() { LocalTransactionContext context = localTxContextHolder.get(); if (!isActiveInternal(context)) { throw new TransactionNotYetBegunException(Message.DOMA2046); } if (context.hasConnection()) { LocalTransactionConnection connection = context.getConnection(); try { connection.commit(); jdbcLogger.logTransactionCommitted(className, "commit", context.getId()); } catch (SQLException e) { rollbackInternal("commit"); throw new JdbcException(Message.DOMA2043, e, e); } finally { end("commit"); } } else { end("commit"); } } protected  LocalTransaction(
      DataSource dataSource,
      ThreadLocal<LocalTransactionContext> localTxContextHolder,
      JdbcLogger jdbcLogger); protected  LocalTransaction(
      DataSource dataSource,
      ThreadLocal<LocalTransactionContext> localTxContextHolder,
      JdbcLogger jdbcLogger,
      TransactionIsolationLevel defaultTransactionIsolationLevel); void begin(); void begin(TransactionIsolationLevel transactionIsolationLevel); void commit(); LocalTransactionContext suspend(); void resume(LocalTransactionContext context); void rollback(); void setSavepoint(String savepointName); boolean hasSavepoint(String savepointName); void releaseSavepoint(String savepointName); void rollback(String savepointName); @Override String toString(); boolean isActive(); void setRollbackOnly(); boolean isRollbackOnly();  }### Answer:
@Test public void testCommit() { transaction.begin(); dataSource.getConnection(); transaction.commit(); assertFalse(transaction.isActive()); assertTrue(connection.autoCommit); assertTrue(connection.committed); }
@Test public void testCommit_notYetBegun() { try { transaction.commit(); fail(); } catch (TransactionNotYetBegunException expected) { System.out.println(expected.getMessage()); } }