* @ejb.interface-method
*/
public void simulateFactoryError(String failure, int count)
{
log.info(failure + " start");
TestConnectionFactory cf = null;
try
{
long available = getAvailableConnections();
InitialContext ctx = new InitialContext();
cf = (TestConnectionFactory) ctx.lookup("java:/JBossTestCF");
cf.setFailure(failure);
for (int i = 0; i < count; ++i)
{
try
{
TestConnection c = (TestConnection) cf.getConnection(failure);
c.close();
}
catch (ResourceException expected)
{
}
}
if (available != getAvailableConnections())
throw new EJBException("Expected " + available + " got " + getAvailableConnections() + " connections");
}
catch (Exception e)
{
log.warn("Unexpected: ", e);
throw new EJBException(e.getMessage());
}
finally
{
sessionContext.setRollbackOnly();
if (cf != null)
cf.setFailure(null);
}
}