KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hsqldb > test > TestBugBase


1 /* Copyright (c) 2001-2005, The HSQL Development Group
2
3  * All rights reserved.
4
5  *
6
7  * Redistribution and use in source and binary forms, with or without
8
9  * modification, are permitted provided that the following conditions are met:
10
11  *
12
13  * Redistributions of source code must retain the above copyright notice, this
14
15  * list of conditions and the following disclaimer.
16
17  *
18
19  * Redistributions in binary form must reproduce the above copyright notice,
20
21  * this list of conditions and the following disclaimer in the documentation
22
23  * and/or other materials provided with the distribution.
24
25  *
26
27  * Neither the name of the HSQL Development Group nor the names of its
28
29  * contributors may be used to endorse or promote products derived from this
30
31  * software without specific prior written permission.
32
33  *
34
35  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
36
37  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38
39  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40
41  * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
42
43  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44
45  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
46
47  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48
49  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50
51  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52
53  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
54
55  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56
57  */

58
59
60
61
62
63 package org.hsqldb.test;
64
65 import java.sql.Connection JavaDoc;
66 import java.sql.DriverManager JavaDoc;
67
68 import org.hsqldb.Server;
69
70 import junit.framework.TestCase;
71
72 /**
73  * HSQLDB TestBugBase Junit test case. <p>
74  *
75  * @author boucherb@users
76  * @version 1.7.2
77  * @since 1.7.2
78  */

79 public abstract class TestBugBase extends TestCase {
80
81     // change the url to reflect your preferred db location and name
82
// String url = "jdbc:hsqldb:hsql://localhost/yourtest";
83
String JavaDoc serverProps = "database.0=mem:test";
84     String JavaDoc url = "jdbc:hsqldb:hsql://localhost";
85     String JavaDoc user = "sa";
86     String JavaDoc password = "";
87     Server server;
88
89     public TestBugBase(String JavaDoc name) {
90         super(name);
91     }
92
93     protected void setUp() {
94
95         server = new Server();
96
97         server.putPropertiesFromString(serverProps);
98         server.setLogWriter(null);
99         server.setErrWriter(null);
100         server.start();
101
102         try {
103             Class.forName("org.hsqldb.jdbcDriver");
104         } catch (Exception JavaDoc e) {
105             e.printStackTrace();
106             System.out.println(this + ".setUp() error: " + e.getMessage());
107         }
108     }
109
110     protected void tearDown() {
111
112         server.stop();
113
114         server = null;
115     }
116
117     Connection JavaDoc newConnection() throws Exception JavaDoc {
118         return DriverManager.getConnection(url, user, password);
119     }
120
121     public abstract void test() throws Exception JavaDoc;
122 }
123
Popular Tags