[jboss-user] [JBoss Seam] - Re: Love the test support in seam except for...

andrew.rw.robinson do-not-reply at jboss.com
Fri Dec 21 13:26:08 EST 2007


For those that are interested, here is my hack:
TestBase.java:

  |   private static TestBase instance; 
  |   
  |   /**
  |    * @see org.jboss.seam.mock.SeamTest#init()
  |    */
  |   @Override @BeforeClass @BeforeSuite
  |   public synchronized void init() throws Exception
  |   {
  |     if (instance == null)
  |     {
  |       instance = this;
  |       super.init();
  |     }
  |     else
  |     {
  |       for (Field field : BaseSeamTest.class.getDeclaredFields())
  |       {
  |         field.setAccessible(true);
  |         field.set(this, field.get(instance));
  |       }
  |     }
  |   }
  |   
  |   /**
  |    * @see org.jboss.seam.mock.SeamTest#cleanup()
  |    */
  |   @Override @AfterSuite(alwaysRun = true) @AfterClass
  |   public synchronized void cleanup() throws Exception
  |   {
  |     if (instance == this)
  |     {
  |       super.cleanup();
  |       instance = null;
  |     }
  |     else
  |     {
  |       for (Field field : BaseSeamTest.class.getDeclaredFields())
  |       {
  |         if (field.getType().isPrimitive())
  |         {
  |           continue;
  |         }
  |         field.setAccessible(true);
  |         field.set(this, null);
  |       }      
  |     }
  |   }
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4115090#4115090

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4115090



More information about the jboss-user mailing list