1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.dbutils;
18
19 import java.lang.reflect.InvocationHandler;
20 import java.lang.reflect.Method;
21 import java.sql.CallableStatement;
22 import java.sql.Connection;
23 import java.sql.Driver;
24 import java.sql.PreparedStatement;
25 import java.sql.ResultSet;
26 import java.sql.ResultSetMetaData;
27 import java.sql.Statement;
28
29 /**
30 * ProxyFactoryTest performs simple type checking on proxy objects returned
31 * from a ProxyFactory.
32 */
33 public class ProxyFactoryTest extends BaseTestCase {
34
35 private static final InvocationHandler stub = new InvocationHandler() {
36
37 public Object invoke(Object proxy, Method method, Object[] args)
38 throws Throwable {
39
40 return null;
41 }
42 };
43
44 /**
45 * Constructor for ProxyFactoryTest.
46 */
47 public ProxyFactoryTest(String name) {
48 super(name);
49 }
50
51 public void testCreateConnection() {
52 assertTrue(
53 ProxyFactory.instance().createConnection(stub)
54 instanceof Connection);
55 }
56
57 public void testCreateDriver() {
58 assertTrue(
59 ProxyFactory.instance().createDriver(stub) instanceof Driver);
60 }
61
62 public void testCreatePreparedStatement() {
63 assertTrue(
64 ProxyFactory.instance().createPreparedStatement(stub)
65 instanceof PreparedStatement);
66 }
67
68 public void testCreateResultSet() {
69 assertTrue(
70 ProxyFactory.instance().createResultSet(stub) instanceof ResultSet);
71 }
72
73 public void testCreateResultSetMetaData() {
74 assertTrue(
75 ProxyFactory.instance().createResultSetMetaData(stub)
76 instanceof ResultSetMetaData);
77 }
78
79 public void testCreateStatement() {
80 assertTrue(
81 ProxyFactory.instance().createStatement(stub) instanceof Statement);
82 }
83
84 public void testCreateCallableStatement() {
85 assertTrue(
86 ProxyFactory.instance().createCallableStatement(stub)
87 instanceof CallableStatement);
88 }
89
90 }