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 org.apache.commons.pool.ObjectPool;
21 import org.apache.commons.pool.PoolableObjectFactory;
22 import org.apache.commons.pool.TestBaseObjectPool;
23
24
25
26
27
28
29 public class TestSoftReferenceObjectPool extends TestBaseObjectPool {
30 public TestSoftReferenceObjectPool(String testName) {
31 super(testName);
32 }
33
34 protected ObjectPool makeEmptyPool(int cap) {
35 return new SoftReferenceObjectPool(
36 new PoolableObjectFactory() {
37 int counter = 0;
38 public Object makeObject() { return String.valueOf(counter++); }
39 public void destroyObject(Object obj) { }
40 public boolean validateObject(Object obj) { return true; }
41 public void activateObject(Object obj) { }
42 public void passivateObject(Object obj) { }
43 }
44 );
45 }
46
47 protected ObjectPool makeEmptyPool(final PoolableObjectFactory factory) {
48 return new SoftReferenceObjectPool(factory);
49 }
50
51 protected Object getNthObject(int n) {
52 return String.valueOf(n);
53 }
54
55 protected boolean isLifo() {
56 return false;
57 }
58
59 protected boolean isFifo() {
60 return false;
61 }
62
63 }