01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
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(ProxyFactory.instance().createConnection(stub) instanceof Connection);
53: }
54:
55: public void testCreateDriver() {
56: assertTrue(ProxyFactory.instance().createDriver(stub) instanceof Driver);
57: }
58:
59: public void testCreatePreparedStatement() {
60: assertTrue(ProxyFactory.instance()
61: .createPreparedStatement(stub) instanceof PreparedStatement);
62: }
63:
64: public void testCreateResultSet() {
65: assertTrue(ProxyFactory.instance().createResultSet(stub) instanceof ResultSet);
66: }
67:
68: public void testCreateResultSetMetaData() {
69: assertTrue(ProxyFactory.instance()
70: .createResultSetMetaData(stub) instanceof ResultSetMetaData);
71: }
72:
73: public void testCreateStatement() {
74: assertTrue(ProxyFactory.instance().createStatement(stub) instanceof Statement);
75: }
76:
77: public void testCreateCallableStatement() {
78: assertTrue(ProxyFactory.instance()
79: .createCallableStatement(stub) instanceof CallableStatement);
80: }
81:
82: }
|