01: package test.org.mandarax.jdbc;
02:
03: /*
04: * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20:
21: import junit.framework.TestCase;
22:
23: /**
24: * Test cases testing the mandarax jdbc urls (connections).
25: * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
26: * @version 3.3.2 <29 December 2004>
27: * @since 3.0
28: */
29:
30: public class CreateConnectionTestCase extends TestCase {
31: private String url = null;
32: private boolean urlOK = true;
33:
34: /*
35: * Constructor.
36: * @param url the kb url
37: * @param urlOK whether this url is to be valid
38: */
39: public CreateConnectionTestCase(String url, boolean urlOK) {
40: super ("test");
41: this .url = url;
42: this .urlOK = urlOK;
43: }
44:
45: /*
46: * Constructor.
47: * @param url the kb url
48: */
49: public CreateConnectionTestCase(String url) {
50: this (url, true);
51: }
52:
53: /**
54: * Perform the test.
55: */
56: public void test() throws Exception {
57: if (urlOK)
58: java.sql.DriverManager.getConnection(url);
59: else {
60: try {
61: java.sql.DriverManager.getConnection(url);
62: assertTrue(false);
63: } catch (Exception x) {
64: assertTrue(true);
65: }
66: }
67: }
68:
69: /**
70: * Convert the object to a string.
71: * @return the string representation of this object
72: */
73: public String toString() {
74: String ok = urlOK ? " (should work)" : " (should fail)";
75: return "Test connection for url " + url + " " + ok;
76: }
77:
78: /**
79: * Prepare the test case.
80: */
81: public void setUp() throws Exception {
82: super .setUp();
83: Class.forName("org.mandarax.jdbc.DriverImpl");
84: TestKB.setup();
85: }
86:
87: }
|