* @ejb:interface-method
* @ejb:transaction type="NotSupported"
*/
public void testConnectionObtainable()
{
TestConnection tc = null;
try
{
DataSource ds = (DataSource) new InitialContext().lookup("java:StatementTestsConnectionDS");
Connection c = ds.getConnection();
WrappedConnection wc = (WrappedConnection) c;
Connection uc = wc.getUnderlyingConnection();
tc = (TestConnection) Proxy.getInvocationHandler(uc);
c.close();
tc.setFail(true);
int closeCount1 = tc.getClosedCount();
c = ds.getConnection();
if (closeCount1 == tc.getClosedCount())
{
throw new EJBException("no connections closed!, closedCount: " + closeCount1);
}
c.close();
for (int i = 0; i < 10; i++)
{
int closeCount = tc.getClosedCount();
c = ds.getConnection();
if (closeCount == tc.getClosedCount())
{
throw new EJBException("no connections closed! at iteration: " + i + ", closedCount: " + closeCount);
}
c.close();
}
}
catch (SQLException e)
{
throw new EJBException(e);
}
catch (NamingException e)
{
throw new EJBException(e);
}
finally
{
if (tc != null)
tc.setFail(false);
}
}