1 6 package org.logicalcobwebs.proxool; 7 8 import junit.framework.TestCase; 9 import org.apache.commons.logging.Log; 10 import org.apache.commons.logging.LogFactory; 11 import org.logicalcobwebs.concurrent.ReaderPreferenceReadWriteLock; 12 13 import java.util.Stack ; 14 15 22 public abstract class AbstractProxoolTest extends TestCase { 23 24 private static final Log LOG = LogFactory.getLog(AbstractProxoolTest.class); 25 26 private String alias; 27 28 private static ReaderPreferenceReadWriteLock testLock = new ReaderPreferenceReadWriteLock(); 29 30 private Stack threadNames = new Stack (); 31 32 public AbstractProxoolTest(String alias) { 33 super(alias); 34 this.alias = alias; 35 } 36 37 40 protected void setUp() throws Exception { 41 GlobalTest.globalSetup(); 42 threadNames.push(Thread.currentThread().getName()); 43 LOG.debug("Thread '" + Thread.currentThread().getName() + "' -> '" + alias + "'"); 44 Thread.currentThread().setName(alias); 45 testLock.writeLock().acquire(); 46 } 47 48 51 protected void tearDown() throws Exception { 52 try { 53 GlobalTest.globalTeardown(alias); 54 Thread.currentThread().setName((String ) threadNames.pop()); 55 LOG.debug("Thread '" + alias + "' -> '" + Thread.currentThread().getName() + "'"); 56 } finally { 57 testLock.writeLock().release(); 58 } 59 } 60 61 } 62 63 64 | Popular Tags |