### Question:
LocalTransactionDataSource implements DataSource { @Override public Connection getConnection() { return getConnectionInternal(); } LocalTransactionDataSource(DataSource dataSource);  LocalTransactionDataSource(String url, String user, String password); @Override Connection getConnection(); @Override Connection getConnection(String username, String password); @Override int getLoginTimeout(); @Override PrintWriter getLogWriter(); @Override boolean isWrapperFor(Class<?> iface); @Override void setLoginTimeout(int seconds); @Override void setLogWriter(PrintWriter out); @SuppressWarnings("unchecked") @Override T unwrap(Class<T> iface); LocalTransaction getLocalTransaction(JdbcLogger jdbcLogger); LocalTransaction getLocalTransaction(
      JdbcLogger jdbcLogger, TransactionIsolationLevel transactionIsolationLevel); KeepAliveLocalTransaction getKeepAliveLocalTransaction(JdbcLogger jdbcLogger); KeepAliveLocalTransaction getKeepAliveLocalTransaction(
      JdbcLogger jdbcLogger, TransactionIsolationLevel transactionIsolationLevel); @Override Logger getParentLogger();  }### Answer:
@Test public void testGetConnection() { UtilLoggingJdbcLogger jdbcLogger = new UtilLoggingJdbcLogger(); LocalTransactionDataSource dataSource = new LocalTransactionDataSource(new MockDataSource()); dataSource.getLocalTransaction(jdbcLogger).begin(); dataSource.getConnection(); dataSource.getLocalTransaction(jdbcLogger).commit(); }
@Test public void testGetConnection_notYetBegun() { LocalTransactionDataSource dataSource = new LocalTransactionDataSource(new MockDataSource()); try { dataSource.getConnection(); fail(); } catch (TransactionNotYetBegunException expected) { System.out.println(expected.getMessage()); } }