1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.pool;
19
20 import junit.framework.TestCase;
21
22 /***
23 * Unit tests for all {@link ObjectPoolFactory}.
24 *
25 * @author Sandy McArthur
26 * @version $Revision: 480413 $ $Date: 2006-11-28 22:16:05 -0700 (Tue, 28 Nov 2006) $
27 */
28 public abstract class TestObjectPoolFactory extends TestCase {
29 protected TestObjectPoolFactory(final String name) {
30 super(name);
31 }
32
33 /***
34 * @throws UnsupportedOperationException when this is unsupported by this PoolableObjectFactory type.
35 */
36 protected ObjectPoolFactory makeFactory() throws UnsupportedOperationException {
37 return makeFactory(new MethodCallPoolableObjectFactory());
38 }
39
40 /***
41 * @throws UnsupportedOperationException when this is unsupported by this PoolableObjectFactory type.
42 */
43 protected abstract ObjectPoolFactory makeFactory(PoolableObjectFactory objectFactory) throws UnsupportedOperationException;
44
45 public void testCreatePool() throws Exception {
46 final ObjectPoolFactory factory;
47 try {
48 factory = makeFactory();
49 } catch (UnsupportedOperationException uoe) {
50 return;
51 }
52 final ObjectPool pool = factory.createPool();
53 pool.close();
54 }
55
56 public void testToString() {
57 final ObjectPoolFactory factory;
58 try {
59 factory = makeFactory();
60 } catch (UnsupportedOperationException uoe) {
61 return;
62 }
63 factory.toString();
64 }
65 }