1 16 17 package org.apache.commons.logging; 18 19 import java.util.Properties ; 20 21 import junit.framework.Test; 22 import junit.framework.TestResult; 23 import junit.framework.TestSuite; 24 25 105 public class PathableTestSuite extends TestSuite { 106 107 111 private ClassLoader contextLoader; 112 113 123 public PathableTestSuite(Class testClass, ClassLoader contextClassLoader) { 124 super(testClass); 125 contextLoader = contextClassLoader; 126 } 127 128 136 public void runTest(Test test, TestResult result) { 137 ClassLoader origContext = Thread.currentThread().getContextClassLoader(); 138 Properties oldSysProps = (Properties ) System.getProperties().clone(); 139 try { 140 Thread.currentThread().setContextClassLoader(contextLoader); 141 test.run(result); 142 } finally { 143 System.setProperties(oldSysProps); 144 Thread.currentThread().setContextClassLoader(origContext); 145 } 146 } 147 } 148 | Popular Tags |