📄 singletontestcontext.java
字号:
/** * $Source: /home/ws/rz65/CVS-Repository/WorkflowProjects/JBPM-Demo/src/test/testjbpmdemo/SingletonTestContext.java,v $ * $Revision: 1.1 $ * $Date: 2005/03/05 12:16:30 $ * $Author: rz65 $ * * Copyright (c) 2005 Universitaet Karlsruhe (TH) / Rechenzentrum (RZ-UNI-UKA) * * RZ-UNI-KA makes no representations or warranties about the suitability * of this software, either express or implied, including but not limited * to the implied warranties of merchantability, fitness for a particular * purpose, or non-infringement. RZ-UNI-KA shall not be liable for any * damages as a result of using, modifying or distributing this software * or its derivatives. */package testjbpmdemo;import java.util.Properties;import java.util.Enumeration;import java.util.Hashtable;import java.util.StringTokenizer;import java.io.File;import jbpmdemo.logging.LoggableObject;import jbpmdemo.logging.LoggingConfigurator;/** * This is the singleton test context for all OSWFDemo test cases. * * <p> * * @version $Revision: 1.1 $ * @author mailto:harald.meyer@rz.uni-karlsruhe.de */public class SingletonTestContext extends LoggableObject { /** * The system property key for the definition of the root of the test work * directories. */ public static final String SYSPROP_KEY_TEST_WORK_ROOT = "jbpmdemo.test.work.root"; /** * Hidden constructor. Clients must not create SingletonTestContext * instances directly. */ private SingletonTestContext() { String mn = MN_INIT; instance = this; LoggingConfigurator.configure(); // show system properties Properties prop = System.getProperties(); Enumeration enum = prop.propertyNames(); for (int i = 0; enum.hasMoreElements(); i++) { String name = (String) enum.nextElement(); String value = prop.getProperty(name); info(mn, "System property[" + i + "]: " + name + " => " + value); } // prepare test work root String path = System.getProperty(SYSPROP_KEY_TEST_WORK_ROOT); if (path == null) suicide(mn, "System property not found: " + SYSPROP_KEY_TEST_WORK_ROOT); testWorkRoot = new File(path); debug(mn, "test work root: " + testWorkRoot); if (!testWorkRoot.exists()) suicide(mn, "Test work directory does not exist: " + testWorkRoot); if (!testWorkRoot.isDirectory()) suicide(mn, "Not a directory: " + testWorkRoot); testWorkDirTable = new Hashtable(); } private static SingletonTestContext instance = null; private File testWorkRoot; private Hashtable testWorkDirTable; /** * Returns the singleton reference. If no instance was created before, it * will now be created. * * @return The reference. */ public static synchronized SingletonTestContext getInstance() { if (instance == null) new SingletonTestContext(); return instance; } /** * Returns the root directory of the test data. * * @return The directory. */ public File getTestWorkRoot() { return testWorkRoot; } /** * Returns the work directory for a given class. * * @param fcqn * The fully qualified class name. * @return The directory. */ public File getTestWorkDir(String fcqn) { String mn = "getTestWorkDir"; File dir = (File) testWorkDirTable.get(fcqn); if (dir == null) { debug(mn, "directory not found for FCQN: " + fcqn); dir = testWorkRoot; StringTokenizer st = new StringTokenizer(fcqn, "."); while (st.hasMoreTokens()) { dir = new File(dir, st.nextToken()); } testWorkDirTable.put(fcqn, dir); debug(mn, "directory added to table: " + dir); } if (!dir.exists()) { debug(mn, "directory does not exist => creating... " + dir); dir.mkdirs(); } return dir; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -