vmassol     2003/10/27 22:57:35

  Modified:    framework/src/java/j2ee13/org/apache/cactus/extension/jetty
                        JettyTestSetup.java
               documentation/docs/xdocs changes.xml
  Log:
  The Jetty Test Setup was not shutting Jetty down if an error ocurred during setUp. 
Fixes bug 24072.
  
  Revision  Changes    Path
  1.4       +41 -4     
jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/extension/jetty/JettyTestSetup.java
  
  Index: JettyTestSetup.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/extension/jetty/JettyTestSetup.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JettyTestSetup.java       9 Aug 2003 16:48:34 -0000       1.3
  +++ JettyTestSetup.java       28 Oct 2003 06:57:35 -0000      1.4
  @@ -60,7 +60,9 @@
   import java.net.URL;
   
   import junit.extensions.TestSetup;
  +import junit.framework.Protectable;
   import junit.framework.Test;
  +import junit.framework.TestResult;
   
   import org.apache.cactus.configuration.BaseConfiguration;
   import org.apache.cactus.configuration.Configuration;
  @@ -125,6 +127,34 @@
       }
   
       /**
  +     * Make sure that [EMAIL PROTECTED] #tearDown} is called if [EMAIL PROTECTED] 
#setUp} fails
  +     * to start the container properly. The default 
  +     * [EMAIL PROTECTED] TestSetup#run(TestResult)} method does not provide this 
feature
  +     * unfortunately.
  +     *  
  +     * @see TestSetup#run(TestResult)
  +     */
  +    public void run(final TestResult theResult)
  +    {
  +        Protectable p = new Protectable()
  +        {
  +            public void protect() throws Exception
  +            {
  +                try
  +                {
  +                    setUp();
  +                    basicRun(theResult);
  +                }
  +                finally
  +                {
  +                    tearDown();
  +                }
  +            }
  +        };
  +        theResult.runProtected(this, p);
  +    }  
  +    
  +    /**
        * Start an embedded Jetty server. It is allowed to pass a Jetty XML as
        * a system property (<code>cactus.jetty.config</code>) to further 
        * configure Jetty. Example: 
  @@ -184,9 +214,16 @@
       { 
           if (this.server != null)
           { 
  -            // Stop the Jetty server
  -            this.server.getClass().getMethod("stop", null).invoke(
  -                this.server, null); 
  +            // First, verify if the server is running
  +            boolean started = ((Boolean) this.server.getClass().getMethod(
  +                "isStarted", null).invoke(this.server, null)).booleanValue(); 
  +
  +            // Stop the Jetty server, if started
  +            if (started)
  +            {
  +                this.server.getClass().getMethod("stop", null).invoke(
  +                    this.server, null);
  +            }
           } 
       }
   
  
  
  
  1.141     +7 -0      jakarta-cactus/documentation/docs/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/documentation/docs/xdocs/changes.xml,v
  retrieving revision 1.140
  retrieving revision 1.141
  diff -u -r1.140 -r1.141
  --- changes.xml       25 Oct 2003 20:55:23 -0000      1.140
  +++ changes.xml       28 Oct 2003 06:57:35 -0000      1.141
  @@ -69,6 +69,13 @@
   
         <release version="1.6dev" date="in CVS">
         </release>
  +
  +      <release version="1.5-rc2" date="in CVS">
  +        <action dev="VMA" type="fix" fixes-bug="24072" due-to="James Stangler" 
due-to-email="[EMAIL PROTECTED]">
  +          The Jetty Test Setup was not shutting Jetty down if an error ocurred
  +          during setUp.
  +        </action>
  +      </release>
         
         <release version="1.5-rc1" date="26 October 2003">
           <action dev="VMA" type="fix" fixes-bug="23604" due-to="Norbert Pabis" 
due-to-email="[EMAIL PROTECTED]">
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to