1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.pool.impl;
19
20 import junit.framework.Test;
21 import junit.framework.TestSuite;
22
23 import org.apache.commons.pool.ObjectPool;
24 import org.apache.commons.pool.PoolableObjectFactory;
25 import org.apache.commons.pool.TestBaseObjectPool;
26
27
28
29
30
31
32 public class TestSoftReferenceObjectPool extends TestBaseObjectPool {
33 public TestSoftReferenceObjectPool(String testName) {
34 super(testName);
35 }
36
37 public static Test suite() {
38 return new TestSuite(TestSoftReferenceObjectPool.class);
39 }
40
41 protected ObjectPool makeEmptyPool(int cap) {
42 return new SoftReferenceObjectPool(
43 new PoolableObjectFactory() {
44 int counter = 0;
45 public Object makeObject() { return String.valueOf(counter++); }
46 public void destroyObject(Object obj) { }
47 public boolean validateObject(Object obj) { return true; }
48 public void activateObject(Object obj) { }
49 public void passivateObject(Object obj) { }
50 }
51 );
52 }
53
54 protected ObjectPool makeEmptyPool(final PoolableObjectFactory factory) {
55 return new SoftReferenceObjectPool(factory);
56 }
57
58 protected Object getNthObject(int n) {
59 return String.valueOf(n);
60 }
61
62 protected boolean isLifo() {
63 return false;
64 }
65
66 protected boolean isFifo() {
67 return false;
68 }
69
70 }