/**
 * Verify that an object that gets flagged as abandoned and is subsequently
 * invalidated is only destroyed (and pool counter decremented) once.
 */
Verify that an object that gets flagged as abandoned and is subsequently
invalidated is only destroyed (and pool counter decremented) once.
/ ** * Verify that an object that gets flagged as abandoned and is subsequently * invalidated is only destroyed ( and pool counter decremented ) once . * /
func (suit *PoolAbandonedTestSuite) TestAbandonedInvalidate() {
	suit.pool.AbandonedConfig.RemoveAbandonedOnBorrow = false
	suit.pool.AbandonedConfig.RemoveAbandonedOnMaintenance = true
	suit.pool.AbandonedConfig.RemoveAbandonedTimeout = 1
	suit.factory.destroyLatency = 200
	n := 10
	suit.pool.Config.MaxTotal = n
	suit.pool.Config.BlockWhenExhausted = false
	suit.pool.Config.TimeBetweenEvictionRunsMillis = 500
	suit.pool.StartEvictor()
	var obj *AbandonedTestObject
	for i := 0; i < 5; i++ {
		obj = suit.NoErrorWithResult(suit.pool.BorrowObject()).(*AbandonedTestObject)
	}
	sleep(1000)                     
	suit.pool.InvalidateObject(obj) 
	sleep(2000)                     
	suit.Equal(0, suit.pool.GetNumActive())
	suit.Equal(5, suit.pool.GetDestroyedCount())
}
func ( suit * PoolAbandonedTestSuite ) TestAbandonedInvalidate ( ) { suit . pool . AbandonedConfig . RemoveAbandonedOnBorrow = false suit . pool . AbandonedConfig . RemoveAbandonedOnMaintenance = true suit . pool . AbandonedConfig . RemoveAbandonedTimeout = 1 suit . factory . destroyLatency = 200 n := 10 suit . pool . Config . MaxTotal = n suit . pool . Config . BlockWhenExhausted = false suit . pool . Config . TimeBetweenEvictionRunsMillis = 500 suit . pool . StartEvictor ( ) var obj * AbandonedTestObject for i := 0 ; i < 5 ; i ++ { obj = suit . NoErrorWithResult ( suit . pool . BorrowObject ( ) ) . ( * AbandonedTestObject ) } sleep ( 1000 ) suit . pool . InvalidateObject ( obj ) sleep ( 2000 ) suit . Equal ( 0 , suit . pool . GetNumActive ( ) ) suit . Equal ( 5 , suit . pool . GetDestroyedCount ( ) ) }
Verify that an object that gets flagged as abandoned and is subsequently
invalidated is only destroyed (and pool counter decremented) once.
Verify that an object that gets flagged as abandoned and is subsequently invalidated is only destroyed ( and pool counter decremented ) once .
// destroys take 200 ms // abandon checked out instances and let evictor start // Should not trigger another destroy / decrement // give evictor time to finish destroys