01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.test;
06:
07: import org.hsqldb.HsqlProperties;
08: import org.hsqldb.Server;
09: import org.hsqldb.ServerConfiguration;
10:
11: // Mainly copy from HsqlDBServer class of dso-spring-tests modules.
12: public class HSqlDBServer {
13: private static final String DEFAULT_DB_NAME = "testdb";
14: private static final int DEFAULT_PORT = 9001;
15:
16: private Server server;
17:
18: public HSqlDBServer() {
19: super ();
20: }
21:
22: public void start() throws Exception {
23: HsqlProperties hsqlproperties1 = new HsqlProperties();
24: HsqlProperties hsqlproperties2 = HsqlProperties
25: .argArrayToProps(new String[] { "-database.0",
26: "mem:testdb", "-dbname.0", DEFAULT_DB_NAME,
27: "server.port", "" + DEFAULT_PORT }, "server");
28: hsqlproperties1.addProperties(hsqlproperties2);
29: ServerConfiguration
30: .translateDefaultDatabaseProperty(hsqlproperties1);
31: server = new Server();
32: server.setProperties(hsqlproperties1);
33: server.start();
34: }
35:
36: public void stop() throws Exception {
37: server.setNoSystemExit(true);
38: server.stop();
39: }
40:
41: public static void main(String[] args) {
42: try {
43: HSqlDBServer dbServer = new HSqlDBServer();
44: dbServer.start();
45: } catch (Exception e) {
46: throw new AssertionError(e);
47: }
48: }
49: }
|