1 4 package com.tcsimulator; 5 6 import java.io.File ; 7 8 public final class Sandbox { 9 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 installationRoot; 19 final File serverHome; 20 final File configFile; 21 final int serverType; 22 23 public Sandbox(File testHome, int serverType) { 24 this.testHome = testHome; 25 this.testHome.mkdir(); 26 this.installationRoot = new File (testHome, "terracotta"); 27 this.serverType = serverType; 28 if (this.serverType == TEST_SERVER) { 29 this.serverHome = new File (this.testHome, TEST_SERVER_SANDBOX_NAME); 30 this.configFile = new File (this.testHome, TEST_CONFIG_FILENAME); 31 } else if (serverType == CONTROL_SERVER) { 32 this.serverHome = new File (this.testHome, CONTROL_SERVER_SANDBOX_NAME); 33 this.configFile = new File (this.testHome, CONTROL_CONFIG_FILENAME); 34 } else { 35 throw new AssertionError ("Can't resolve server type. Must be either test- or control-server."); 36 } 37 this.serverHome.mkdir(); 38 } 39 40 public File getConfigFile() { 41 return this.configFile; 42 } 43 44 public File getServerHome() { 45 return this.serverHome; 46 } 47 48 public File getInstallationRoot() { 49 return this.installationRoot; 50 } 51 52 public File getTestHome() { 53 return this.testHome; 54 } 55 56 public String getDistributionName() { 57 return TC_DISTRIBUTION; 58 } 59 } | Popular Tags |