001: /* Copyright (c) 2001-2005, The HSQL Development Group
002:
003: * All rights reserved.
004:
005: *
006:
007: * Redistribution and use in source and binary forms, with or without
008:
009: * modification, are permitted provided that the following conditions are met:
010:
011: *
012:
013: * Redistributions of source code must retain the above copyright notice, this
014:
015: * list of conditions and the following disclaimer.
016:
017: *
018:
019: * Redistributions in binary form must reproduce the above copyright notice,
020:
021: * this list of conditions and the following disclaimer in the documentation
022:
023: * and/or other materials provided with the distribution.
024:
025: *
026:
027: * Neither the name of the HSQL Development Group nor the names of its
028:
029: * contributors may be used to endorse or promote products derived from this
030:
031: * software without specific prior written permission.
032:
033: *
034:
035: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
036:
037: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
038:
039: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
040:
041: * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
042:
043: * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
044:
045: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
046:
047: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
048:
049: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
050:
051: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
052:
053: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
054:
055: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
056:
057: */
058:
059: package org.hsqldb.test;
060:
061: import java.sql.Connection;
062: import java.sql.DriverManager;
063:
064: import org.hsqldb.Server;
065:
066: import junit.framework.TestCase;
067:
068: /**
069: * HSQLDB TestBugBase Junit test case. <p>
070: *
071: * @author boucherb@users
072: * @version 1.7.2
073: * @since 1.7.2
074: */
075: public abstract class TestBugBase extends TestCase {
076:
077: // change the url to reflect your preferred db location and name
078: // String url = "jdbc:hsqldb:hsql://localhost/yourtest";
079: String serverProps = "database.0=mem:test";
080: String url = "jdbc:hsqldb:hsql://localhost";
081: String user = "sa";
082: String password = "";
083: Server server;
084:
085: public TestBugBase(String name) {
086: super (name);
087: }
088:
089: protected void setUp() {
090:
091: server = new Server();
092:
093: server.putPropertiesFromString(serverProps);
094: server.setLogWriter(null);
095: server.setErrWriter(null);
096: server.start();
097:
098: try {
099: Class.forName("org.hsqldb.jdbcDriver");
100: } catch (Exception e) {
101: e.printStackTrace();
102: System.out.println(this + ".setUp() error: "
103: + e.getMessage());
104: }
105: }
106:
107: protected void tearDown() {
108:
109: server.stop();
110:
111: server = null;
112: }
113:
114: Connection newConnection() throws Exception {
115: return DriverManager.getConnection(url, user, password);
116: }
117:
118: public abstract void test() throws Exception;
119: }
|