01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.test.server;
05:
06: import org.hsqldb.HsqlProperties;
07: import org.hsqldb.Server;
08: import org.hsqldb.ServerConfiguration;
09:
10: import com.tc.test.server.appserver.deployment.AbstractDBServer;
11:
12: public class HSqlDBServer extends AbstractDBServer {
13: private static final String DEFAULT_DB_NAME = "testdb";
14: private static final int DEFAULT_PORT = ServerConfiguration
15: .getDefaultPort(1, false);
16:
17: Server server = null;
18:
19: public HSqlDBServer(String name, int port) {
20: super ();
21:
22: this .setDbName(name == null ? DEFAULT_DB_NAME : name);
23: this .setServerPort(port == 0 ? DEFAULT_PORT : port);
24: }
25:
26: public void doStart() throws Exception {
27: HsqlProperties hsqlproperties1 = new HsqlProperties();
28: HsqlProperties hsqlproperties2 = HsqlProperties
29: .argArrayToProps(new String[] { "-database.0",
30: "mem:test", "-dbname.0", this .getDbName(),
31: "server.port", "" + this .getServerPort() },
32: "server");
33: hsqlproperties1.addProperties(hsqlproperties2);
34: ServerConfiguration
35: .translateDefaultDatabaseProperty(hsqlproperties1);
36: server = new Server();
37: server.setProperties(hsqlproperties1);
38: server.start();
39: }
40:
41: public void doStop() throws Exception {
42: server.setNoSystemExit(true);
43: server.stop();
44: }
45:
46: public String toString() {
47: return super .toString() + " dbName:" + this .getDbName()
48: + "; serverPort:" + this.getServerPort();
49: }
50: }
|