5 Replies Latest reply on May 8, 2006 11:56 AM by anil.saldhana

    XXXSetUp and tearDown method

    anil.saldhana

      Seems like the XXXSetUp (not the JBossTestSetUp) pattern does not invoke the tearDown() method on a test failure. I want a second opinion on this because the testsuite has a lot of this pattern including the AOPTestSetUp. These XXXSetup extend JBossTestSetUp.

      But in the case of SecurePerfTestCase, the following pattern:

      Setup wrapper = new Setup(suite, "secure-perf.jar", true);
       return wrapper;
      

      was not invoking the tearDown method, after the testfailure -thus having a side effect on EJBSpecUnitTestCase.

      From: jboss-cvs-commits-admin@lists.sourceforge.net on behalf of Anil Saldhana
      Sent: Mon 4/17/2006 10:22 PM
      To: jboss-cvs-commits@lists.sourceforge.net
      Subject: [jboss-cvs] jbosstest/src/main/org/jboss/test/perf/test ...
      
      
       User: asaldhana
       Date: 06/04/17 23:22:31
      
       Modified: src/main/org/jboss/test/perf/test Tag: Branch_4_0
       SecurePerfStressTestCase.java
       Log:
       Fix the issue that the failing test is not undeploying the jar file. This eliminates the side effects on the other testcase org.jboss.test.security.test.EJBSpecUnitTestCase.
      
       Revision Changes Path
       No revision
      
      
       No revision
      
      
       1.6.6.2 +25 -25 jbosstest/src/main/org/jboss/test/perf/test/SecurePerfStressTestCase.java
      
       (In the diff below, changes in quantity of whitespace are not shown.)
      
       Index: SecurePerfStressTestCase.java
       ===================================================================
       RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/perf/test/SecurePerfStressTestCase.java,v
       retrieving revision 1.6.6.1
       retrieving revision 1.6.6.2
       diff -u -b -r1.6.6.1 -r1.6.6.2
       --- SecurePerfStressTestCase.java 29 Oct 2005 05:05:41 -0000 1.6.6.1
       +++ SecurePerfStressTestCase.java 18 Apr 2006 03:22:31 -0000 1.6.6.2
       @@ -21,39 +21,22 @@
       */
       package org.jboss.test.perf.test;
      
      
       public class SecurePerfStressTestCase extends PerfStressTestCase //JBossTestCase
       {
       @@ -78,7 +61,24 @@
       suite.addTest(new TestSuite(SecurePerfStressTestCase.class));
      
       // Create an initializer for the test suite
       - Setup wrapper = new Setup(suite, "secure-perf.jar", true);
       + /*Setup wrapper = new Setup(suite, "secure-perf.jar", true);
       + return wrapper; */
       + //Create an initializer for the test suite
       + TestSetup wrapper = new JBossTestSetup(suite)
       + {
       + protected void setUp() throws Exception
       + {
       + super.setUp();
       + Configuration.setConfiguration(new XMLLoginConfigImpl());
       + redeploy("secure-perf.jar");
       + }
       + protected void tearDown() throws Exception
       + {
       + undeploy("secure-perf.jar");
       + super.tearDown();
       +
       + }
       + };
       return wrapper;
       }
       }
      
      


        • 1. Re: XXXSetUp and tearDown method

          You aren't preserving the behavior of org.jboss.test.perf.test.Setup::setUp():

           if( isSecure )
           {
           login();
           }
           deploy(filename);
           removeAll();
           createEntityBeans(getBeanCount());
           createEntity2Beans(getBeanCount());
          


          ??

          • 2. Re: XXXSetUp and tearDown method

            Also, junit.framework.TestSetup::run() doesn't guarantee that tearDown() will be called if the "test" fails:

             public void run(final TestResult result) {
             Protectable p= new Protectable() {
             public void protect() throws Exception {
             setUp();
             basicRun(result);
             tearDown();
             }
             };
             result.runProtected(this, p);
             }
            


            • 3. Re: XXXSetUp and tearDown method
              anil.saldhana

               

              "ryan.campbell@jboss.com" wrote:
              You aren't preserving the behavior of org.jboss.test.perf.test.Setup::setUp():

               if( isSecure )
               {
               login();
               }
               deploy(filename);
               removeAll();
               createEntityBeans(getBeanCount());
               createEntity2Beans(getBeanCount());
              


              ??


              Yes, I need to bring this back. It is on the back of my mind. The way to solve the problem, is that if the test fails to deploy the archives, then do the undeploy process, while catching the exception & rethrowing it (ofcourse).

              The problem is the sideeffects (like security) of orphan archives on the jboss server.

              • 4. Re: XXXSetUp and tearDown method

                Ok, my last post is wrong. TestSetup.tearDown() should be called since any exception in the test is obviously caught by TestCase.runBare():

                 public void runBare() throws Throwable {
                 Throwable exception= null;
                 setUp();
                 try {
                 runTest();
                 } catch (Throwable running) {
                 exception= running;
                 }
                 finally {
                 try {
                 tearDown();
                 } catch (Throwable tearingDown) {
                 if (exception == null) exception= tearingDown;
                 }
                 }
                 if (exception != null) throw exception;
                 }
                



                But my question as to why org.jboss.test.perf.test.Setup::setUp() is no longer needed still applies.

                It seems to me that there could be an exception thrown in perf.test.Setup::tearDown() before undeploy is called?

                • 5. Re: XXXSetUp and tearDown method
                  anil.saldhana

                  I reverted the test setup for the perfStressTestCases as the original CMP deployment issue was fixed by Alexey.
                  http://jira.jboss.com/jira/browse/JBAS-3192