net.sf.farrago.test
Class FarragoTestCase.CleanupFactory

java.lang.Object
  extended by net.sf.farrago.test.FarragoTestCase.CleanupFactory
Enclosing class:
FarragoTestCase

public static class FarragoTestCase.CleanupFactory
extends Object

CleanupFactory is a factory for Cleanup objects. Test cases overriding FarragoTestCase can provide custom test cleanup by overriding CleanupFactory. This is normally done only for extension projects that have additional repository objects that require special cleanup. Most individual test cases can simply use the setUp/tearDown facility built into JUnit. The alternate CleanupFactory should override newCleanup(String) to return an extension of Cleanup that provides custom cleanup. The extension project test case should provide static helper methods to wrap the Test objects returned by FarragoTestCase's static wrappedSuite methods with code that sets and resets the CleanupFactory. In other words:

 public abstract class ExtensionTestCase extends FarragoTestCase
 {
     public static Test wrappedExtensionSuite(Class clazz)
     {
         TestSuite suite = new TestSuite(clazz);
         return wrappedExtensionSuite(suite);
     }

     public static Test wrappedExtensionSuite(TestSuite suite)
     {
         Test farragoSuite = FarragoTestCase.wrappedSuite(suite);

         TestSetup wrapper =
             new TestSetup(farragoSuite) {
                 protected void setUp() throws Exception
                 {
                     CleanupFactory.setFactory(
                         new ExtensionCleanupFactory());
                 }

                 protected void tearDown() throws Exception
                 {
                     CleanupFactory.resetFactory();
                 }
             };
         return wrapper;
     }
 }
 


Field Summary
private static FarragoTestCase.CleanupFactory defaultFactory
           
private static FarragoTestCase.CleanupFactory factory
           
 
Constructor Summary
FarragoTestCase.CleanupFactory()
           
 
Method Summary
static FarragoTestCase.CleanupFactory getFactory()
           
 FarragoTestCase.Cleanup newCleanup(String name)
           
static void resetFactory()
           
static void setFactory(FarragoTestCase.CleanupFactory altFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultFactory

private static final FarragoTestCase.CleanupFactory defaultFactory

factory

private static FarragoTestCase.CleanupFactory factory
Constructor Detail

FarragoTestCase.CleanupFactory

public FarragoTestCase.CleanupFactory()
Method Detail

setFactory

public static void setFactory(FarragoTestCase.CleanupFactory altFactory)

resetFactory

public static void resetFactory()

getFactory

public static FarragoTestCase.CleanupFactory getFactory()

newCleanup

public FarragoTestCase.Cleanup newCleanup(String name)
                                   throws Exception
Throws:
Exception