1 package JSci.tests; 2 3 import java.util.Iterator ; 4 import java.util.HashMap ; 5 import java.util.Map ; 6 import junit.framework.Test; 7 import junit.framework.TestResult; 8 import junitx.extensions.TestSetup; 9 10 34 public class TestProperties extends TestSetup { 35 36 private static final ThreadLocal PROPERTIES = new ThreadLocal () { 37 protected Object initialValue() { 38 return new HashMap (); 39 } 40 }; 41 44 public static Map getProperties() { 45 return (Map ) PROPERTIES.get(); 46 } 47 48 private final Map properties; 49 52 public TestProperties(Test test, Map properties) { 53 super(test); 54 this.properties = properties; 55 } 56 59 protected void setUp() throws Exception { 60 getProperties().putAll(properties); 61 } 62 65 protected void tearDown() throws Exception { 66 final Map threadLocalProperties = getProperties(); 67 for(Iterator iter = properties.keySet().iterator(); iter.hasNext(); ) { 68 threadLocalProperties.remove(iter.next()); 69 } 70 } 71 } 72 73 | Popular Tags |