1 16 17 package org.apache.commons.pool.impl; 18 19 import junit.framework.Test; 20 import junit.framework.TestSuite; 21 22 import org.apache.commons.pool.ObjectPool; 23 import org.apache.commons.pool.PoolableObjectFactory; 24 import org.apache.commons.pool.TestObjectPool; 25 26 30 public class TestSoftReferenceObjectPool extends TestObjectPool { 31 public TestSoftReferenceObjectPool(String testName) { 32 super(testName); 33 } 34 35 public static Test suite() { 36 return new TestSuite(TestSoftReferenceObjectPool.class); 37 } 38 39 protected ObjectPool makeEmptyPool(int cap) { 40 return new SoftReferenceObjectPool( 41 new PoolableObjectFactory() { 42 int counter = 0; 43 public Object makeObject() { return String.valueOf(counter++); } 44 public void destroyObject(Object obj) { } 45 public boolean validateObject(Object obj) { return true; } 46 public void activateObject(Object obj) { } 47 public void passivateObject(Object obj) { } 48 } 49 ); 50 } 51 52 protected Object getNthObject(int n) { 53 return String.valueOf(n); 54 } 55 56 } 57 | Popular Tags |