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.tcsimulator;
05:
06: import java.io.File;
07:
08: public final class Sandbox {
09: public static final int TEST_SERVER = 0;
10: public static final int CONTROL_SERVER = 1;
11: private static final String TEST_SERVER_SANDBOX_NAME = "server";
12: private static final String CONTROL_SERVER_SANDBOX_NAME = "control";
13: private static final String TEST_CONFIG_FILENAME = "tc-config.xml";
14: private static final String CONTROL_CONFIG_FILENAME = "control-config.xml";
15: private static final String TC_DISTRIBUTION = "terracotta";
16:
17: final File testHome;
18: final File serverHome;
19: final File configFile;
20: final int serverType;
21:
22: public Sandbox(File testHome, int serverType) {
23: this .testHome = testHome;
24: this .testHome.mkdir();
25: this .serverType = serverType;
26: if (this .serverType == TEST_SERVER) {
27: this .serverHome = new File(this .testHome,
28: TEST_SERVER_SANDBOX_NAME);
29: this .configFile = new File(this .testHome,
30: TEST_CONFIG_FILENAME);
31: } else if (serverType == CONTROL_SERVER) {
32: this .serverHome = new File(this .testHome,
33: CONTROL_SERVER_SANDBOX_NAME);
34: this .configFile = new File(this .testHome,
35: CONTROL_CONFIG_FILENAME);
36: } else {
37: throw new AssertionError(
38: "Can't resolve server type. Must be either test- or control-server.");
39: }
40: this .serverHome.mkdir();
41: }
42:
43: public File getConfigFile() {
44: return this .configFile;
45: }
46:
47: public File getServerHome() {
48: return this .serverHome;
49: }
50:
51: public File getTestHome() {
52: return this .testHome;
53: }
54:
55: public String getDistributionName() {
56: return TC_DISTRIBUTION;
57: }
58: }
|