1 22 package org.jboss.test; 23 24 import junit.framework.Test; 25 import junit.framework.TestSuite; 26 27 import org.jboss.logging.Logger; 28 29 42 public class AbstractTestCaseWithSetup extends AbstractTestCase 43 { 44 45 private AbstractTestSetup setup; 46 47 52 public AbstractTestCaseWithSetup(String name) 53 { 54 super(name); 55 } 56 57 60 public Logger getLog() 61 { 62 return getDelegate().getLog(); 63 } 64 65 69 protected void enableTrace(String name) 70 { 71 getDelegate().enableTrace(name); 72 } 73 74 79 protected AbstractTestDelegate getDelegate() 80 { 81 return AbstractTestSetup.delegate; 82 } 83 84 91 protected void setUp() throws Exception 92 { 93 if (AbstractTestSetup.delegate == null) 95 { 96 setup = new AbstractTestSetup(this.getClass(), this); 97 setup.setUp(); 98 } 99 super.setUp(); 100 } 101 102 protected void tearDown() throws Exception 103 { 104 super.tearDown(); 105 if (setup != null) 106 setup.tearDown(); 107 } 108 109 117 public static Test suite(Class clazz) 118 { 119 TestSuite suite = new TestSuite(clazz); 120 return new AbstractTestSetup(clazz, suite); 121 } 122 } 123 | Popular Tags |