1 /*** 2 * 3 */ 4 package atg.test.configuration; 5 6 import java.io.File; 7 import java.io.IOException; 8 import java.util.HashMap; 9 import java.util.Map; 10 11 import org.apache.log4j.Logger; 12 13 import atg.nucleus.Nucleus; 14 import atg.nucleus.logging.PrintStreamLogger; 15 import atg.service.lockmanager.ClientLockManager; 16 import atg.test.util.FileUtil; 17 import atg.xml.tools.apache.ApacheXMLToolsFactory; 18 19 /*** 20 * <i>This class is a merger of atg.test.util.DBUtils and 21 * atg.adapter.gsa.GSATestUtils. The result will hopefully be a class that just 22 * has the bare minimums needed for testing against an existing and/or in-memory 23 * database.</i> 24 * <p> 25 * This class will created all properties files needed for non repository based 26 * tests. 27 * </p> 28 * 29 * @author robert 30 * 31 */ 32 public final class BasicConfiguration { 33 34 protected String isDebug = Boolean.FALSE.toString(); 35 36 protected final Map<String, String> settings = new HashMap<String, String>(); 37 38 private static Logger log = Logger.getLogger(BasicConfiguration.class); 39 40 public void setDebug(final boolean isDebug) { 41 this.isDebug = Boolean.toString(isDebug); 42 } 43 44 /*** 45 * 46 * @param isDebug 47 */ 48 public BasicConfiguration() { 49 super(); 50 } 51 52 /*** 53 * 54 * @param root 55 * @throws IOException 56 */ 57 public void createPropertiesByConfigurationLocation(final File root) 58 throws IOException { 59 60 this.createClientLockManager(root); 61 this.createGlobal(root); 62 this.createInitialServices(root); 63 this.createScreenLog(root); 64 this.createXMLToolsFactory(root); 65 66 log.info("Created basic configuration fileset"); 67 68 } 69 70 /*** 71 * 72 * @param root 73 * @throws IOException 74 */ 75 private void createClientLockManager(final File root) throws IOException { 76 this.settings.clear(); 77 settings.put("lockServerAddress", "localhost"); 78 settings.put("lockServerPort", "9010"); 79 settings.put("useLockServer", "false"); 80 FileUtil.createPropertyFile("ClientLockManager", new File(root 81 .getAbsolutePath() 82 + "/atg/dynamo/service"), ClientLockManager.class, settings); 83 } 84 85 /*** 86 * 87 * @param root 88 * @throws IOException 89 */ 90 private void createGlobal(final File root) throws IOException { 91 this.settings.clear(); 92 settings.put("logListeners", "/atg/dynamo/service/logging/ScreenLog"); 93 settings.put("loggingDebug", isDebug); 94 FileUtil.createPropertyFile("GLOBAL", 95 new File(root.getAbsolutePath() + "/"), null, settings); 96 97 } 98 99 /*** 100 * 101 * Creates initial services properties like Initial, AppServerConfig, Nucleus, 102 * etc, etc. 103 * 104 * @param root 105 * @throws IOException 106 */ 107 private void createInitialServices(final File root) throws IOException { 108 this.settings.clear(); 109 settings.put("initialServiceName", "/Initial"); 110 FileUtil.createPropertyFile("Nucleus", root, Nucleus.class, settings); 111 } 112 113 /*** 114 * 115 * @param root 116 * @throws IOException 117 */ 118 private void createScreenLog(final File root) throws IOException { 119 120 this.settings.clear(); 121 settings.put("cropStackTrace", "false"); 122 settings.put("loggingEnabled", isDebug); 123 FileUtil.createPropertyFile("ScreenLog", new File(root.getAbsolutePath() 124 + "/atg/dynamo/service/logging"), PrintStreamLogger.class, settings); 125 } 126 127 /*** 128 * 129 * @param root 130 * @throws IOException 131 */ 132 private void createXMLToolsFactory(final File root) throws IOException { 133 FileUtil.createPropertyFile("XMLToolsFactory", new File(root 134 .getAbsolutePath() 135 + "/atg/dynamo/service/xml"), ApacheXMLToolsFactory.class, 136 new HashMap<String, String>()); 137 } 138 139 }