[webbeans-commits] Webbeans SVN: r921 - ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Tue Jan 13 11:31:13 EST 2009


Author: pete.muir at jboss.org
Date: 2009-01-13 11:31:13 -0500 (Tue, 13 Jan 2009)
New Revision: 921

Modified:
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java
Log:
Add RunInDependentContext

Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java	2009-01-13 15:50:31 UTC (rev 920)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java	2009-01-13 16:31:13 UTC (rev 921)
@@ -24,6 +24,37 @@
 
 public class AbstractTest
 {
+   
+   protected abstract static class RunInDependentContext 
+   {
+      
+      protected void setup()
+      {
+         AbstractTest.activateDependentContext();
+      }
+      
+      protected void cleanup()
+      {
+         AbstractTest.deactivateDependentContext();
+      }
+      
+      public final void run()
+      {
+         try
+         {
+            setup();
+            execute();
+         }
+         finally
+         {
+            cleanup();
+         }
+      }
+      
+      protected abstract void execute();
+      
+   }
+   
    protected static final int BUILT_IN_BEANS = 3;
    
    protected ManagerImpl manager;
@@ -32,7 +63,7 @@
    public static boolean visited = false;
 
    @BeforeMethod
-   public final void before()
+   public void before() throws Exception
    {
       webBeansBootstrap = new MockBootstrap();
       manager = webBeansBootstrap.getManager();
@@ -87,12 +118,12 @@
       return in.readObject();
    }
 
-   protected void activateDependentContext()
+   protected static void activateDependentContext()
    {
       DependentContext.INSTANCE.setActive(true);
    }
    
-   protected void deactivateDependentContext()
+   protected static void deactivateDependentContext()
    {
       DependentContext.INSTANCE.setActive(false);
    }




More information about the weld-commits mailing list