1 64 65 package com.jcorporate.expresso.services.test; 66 67 import com.jcorporate.expresso.core.misc.ConfigManager; 68 import com.jcorporate.expresso.kernel.LogManager; 69 70 71 91 public class TestSystemInitializer { 92 static String testContext = "test"; 93 94 static String logDirectory; 95 96 public TestSystemInitializer() { 97 } 98 99 103 public static void setUp() 104 throws Exception { 105 106 if (ConfigManager.isInitialized()) { 110 return; 111 } 112 113 String prop = System.getProperty("junit.argv.webAppDir"); 114 if (prop == null) { 115 throw new IllegalArgumentException ("junit.argv.webAppDir doesn't exist"); 116 } 117 ConfigManager.setWebAppDir(prop); 118 119 120 prop = System.getProperty("junit.argv.configDir"); 121 122 if (prop == null) { 123 throw new IllegalArgumentException ("junit.argv.configDir doesn't exist"); 124 } 125 126 String logConfig = prop + "/expressoLogging.xml"; 127 128 129 try { 130 java.io.File f = new java.io.File (logConfig); 131 if (f != null) { 132 if (!f.exists()) { 133 logConfig = null; 134 System.out.println("cannot find logging config file: " + f.getCanonicalPath()); 135 } 136 } else { 137 logConfig = null; 138 } 139 } catch (Exception ex) { 140 ex.printStackTrace(); 141 logConfig = null; 142 } 143 144 logDirectory = System.getProperty("junit.argv.logDir", null); 145 146 LogManager lm = new LogManager(logConfig, logDirectory); 147 ConfigManager.load(prop); 148 149 150 151 ConfigManager.dbInitialize(); 153 154 prop = System.getProperty("junit.argv.testContext"); 155 if (prop != null && prop.length() > 0) { 156 testContext = prop; 157 } 158 159 160 } 161 162 169 public static String getTestContext() { 170 return testContext; 171 } 172 173 public static String getLogDirectory() { 174 return logDirectory; 175 } 176 } | Popular Tags |