public void testReEnteringRecovery() throws Exception { if (log.isDebugEnabled()) { log.debug("*** Starting testReEnteringRecovery"); } pds.startRecovery(); try { pds.startRecovery(); fail("expected RecoveryException"); } catch (RecoveryException ex) { assertEquals("recovery already in progress on a PoolingDataSource containing an XAPool of resource pds with 1 connection(s) (0 still available)", ex.getMessage()); } // make sure startRecovery() can be called again once endRecovery() has been called pds.endRecovery(); pds.startRecovery(); pds.endRecovery(); }
public void testReEnteringRecovery() throws Exception { if (log.isDebugEnabled()) { log.debug("*** Starting testReEnteringRecovery"); } pds.startRecovery(); try { pds.startRecovery(); fail("expected RecoveryException"); } catch (RecoveryException ex) { assertEquals("recovery already in progress on a PoolingDataSource containing an XAPool of resource pds with 1 connection(s) (0 still available)", ex.getMessage()); } // make sure startRecovery() can be called again once endRecovery() has been called pds.endRecovery(); pds.startRecovery(); pds.endRecovery(); }
public void testReEnteringRecovery() throws Exception { pcf.startRecovery(); try { pcf.startRecovery(); fail("excpected RecoveryException"); } catch (RecoveryException ex) { assertEquals("recovery already in progress on a PoolingConnectionFactory with an XAPool of resource pcf with 1 connection(s) (0 still available)", ex.getMessage()); } // make sure startRecovery() can be called again once endRecovery() has been called pcf.endRecovery(); pcf.startRecovery(); pcf.endRecovery(); }
public void testReEnteringRecovery() throws Exception { pcf.startRecovery(); try { pcf.startRecovery(); fail("excpected RecoveryException"); } catch (RecoveryException ex) { assertEquals("recovery already in progress on a PoolingConnectionFactory with an XAPool of resource pcf with 1 connection(s) (0 still available)", ex.getMessage()); } // make sure startRecovery() can be called again once endRecovery() has been called pcf.endRecovery(); pcf.startRecovery(); pcf.endRecovery(); }
public void testSuccessfulRecoveryMarksAsNotFailed() throws Exception { MockitoXADataSource.setStaticGetXAConnectionException(new SQLException("creating a new connection does not work")); PoolingDataSource poolingDataSource = new PoolingDataSource(); poolingDataSource.setClassName(MockitoXADataSource.class.getName()); poolingDataSource.setUniqueName("ds1"); poolingDataSource.setMaxPoolSize(1); poolingDataSource.init(); try { IncrementalRecoverer.recover(poolingDataSource); fail("expected RecoveryException"); } catch (RecoveryException ex) { assertEquals("cannot start recovery on a PoolingDataSource containing an XAPool of resource ds1 with 0 connection(s) (0 still available)", ex.getMessage()); } assertEquals("a PoolingDataSource containing an XAPool of resource ds1 with 0 connection(s) (0 still available) -failed-", poolingDataSource.toString()); MockitoXADataSource.setStaticGetXAConnectionException(null); Recoverer recoverer = new Recoverer(); recoverer.run(); assertEquals("a PoolingDataSource containing an XAPool of resource ds1 with 1 connection(s) (1 still available)", poolingDataSource.toString()); // recoverer must not unregister the resource assertSame(poolingDataSource, ResourceRegistrar.get("ds1")); poolingDataSource.close(); } }
public void testSuccessfulRecoveryMarksAsNotFailed() throws Exception { MockitoXADataSource.setStaticGetXAConnectionException(new SQLException("creating a new connection does not work")); PoolingDataSource poolingDataSource = new PoolingDataSource(); poolingDataSource.setClassName(MockitoXADataSource.class.getName()); poolingDataSource.setUniqueName("ds1"); poolingDataSource.setMaxPoolSize(1); poolingDataSource.init(); try { IncrementalRecoverer.recover(poolingDataSource); fail("expected RecoveryException"); } catch (RecoveryException ex) { assertEquals("cannot start recovery on a PoolingDataSource containing an XAPool of resource ds1 with 0 connection(s) (0 still available)", ex.getMessage()); } assertEquals("a PoolingDataSource containing an XAPool of resource ds1 with 0 connection(s) (0 still available) -failed-", poolingDataSource.toString()); MockitoXADataSource.setStaticGetXAConnectionException(null); Recoverer recoverer = new Recoverer(); recoverer.run(); assertEquals("a PoolingDataSource containing an XAPool of resource ds1 with 1 connection(s) (1 still available)", poolingDataSource.toString()); // recoverer must not unregister the resource assertSame(poolingDataSource, ResourceRegistrar.get("ds1")); poolingDataSource.close(); } }