/** * Tests that the enList method. * * @throws InitializationException * @throws DataException * @throws SQLException * @throws CouldNotBeginException * @throws CouldNotEnlistException */ @Test public void testEnList() throws InitializationException, DataException, SQLException, CouldNotBeginException, CouldNotEnlistException { Provider provider = Bo2.getDefaultDeployment().getProvider(); JdbcConnectionProvider jdbc = provider.getResource("LOCALDB", JdbcConnectionProvider.class); // $NON-NLS-1$ Connection connection = jdbc.getConnection(); JdbcConnectionsTransactionManager manager = new JdbcConnectionsTransactionManager(); manager.begin(); manager.enList(jdbc); assertFalse(jdbc.getConnection().getAutoCommit()); assertTrue(manager.connections.contains(connection)); jdbc.close(); }
/** allows for multiple uses of this object to have an open connection */ private void allowReuse() throws JdbcException { closePreviousResources(); if (connection == null) { connection = connectionProvider.getConnection(dbInfo); } }