vmassol     2003/10/27 22:59:24

  Modified:    framework/src/java/j2ee13/org/apache/cactus/extension/jetty
                        Tag: CACTUS_15_BRANCH JettyTestSetup.java
               documentation/docs/xdocs Tag: CACTUS_15_BRANCH changes.xml
  Log:
  The Jetty Test Setup was not shutting Jetty down if an error ocurred during setUp. 
Fixes bug 24072.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.2.2.2   +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.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- JettyTestSetup.java       9 Aug 2003 16:51:39 -0000       1.2.2.1
  +++ JettyTestSetup.java       28 Oct 2003 06:59:24 -0000      1.2.2.2
  @@ -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);
  +            }
           } 
       }
   
  
  
  
  No                   revision
  No                   revision
  1.120.2.10 +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.120.2.9
  retrieving revision 1.120.2.10
  diff -u -r1.120.2.9 -r1.120.2.10
  --- changes.xml       25 Oct 2003 20:54:26 -0000      1.120.2.9
  +++ changes.xml       28 Oct 2003 06:59:24 -0000      1.120.2.10
  @@ -67,6 +67,13 @@
           <person name="Julien Ruaux" email="[EMAIL PROTECTED]" id="JRU"/>
         </devs>
   
  +      <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]">
             The Cactus Ant integration now reports the HTTP error code when it 
  
  
  

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

Reply via email to