vmassol     02/04/14 04:15:30

  Modified:    framework/src/test/share/org/apache/cactus
                        TestAbstractTestCaseInterceptorTestCase.java
  Log:
  corrected last checkstyle reported errors ! :-)
  
  Revision  Changes    Path
  1.2       +141 -118  
jakarta-cactus/framework/src/test/share/org/apache/cactus/TestAbstractTestCaseInterceptorTestCase.java
  
  Index: TestAbstractTestCaseInterceptorTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/framework/src/test/share/org/apache/cactus/TestAbstractTestCaseInterceptorTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestAbstractTestCaseInterceptorTestCase.java      14 Apr 2002 10:49:37 -0000     
 1.1
  +++ TestAbstractTestCaseInterceptorTestCase.java      14 Apr 2002 11:15:30 -0000     
 1.2
  @@ -70,7 +70,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Vincent Massol</a>
    *
  - * @version $Id: TestAbstractTestCaseInterceptorTestCase.java,v 1.1 2002/04/14 
10:49:37 vmassol Exp $
  + * @version $Id: TestAbstractTestCaseInterceptorTestCase.java,v 1.2 2002/04/14 
11:15:30 vmassol Exp $
    */
   public class TestAbstractTestCaseInterceptorTestCase
       extends AbstractTestCase
  @@ -129,140 +129,163 @@
   
           } catch (AssertionFailedError e) {
   
  -            // ------ Tests for begin methods --------------------------------
  +            // Perform asserts
  +            if (!verifyBeginMethodsOk(e.getMessage()) &&
  +                !verifyEndMethodsOk(e.getMessage())) {
   
  -            // Test that when a begin method for a given test does not have the
  -            // correct return type (i.e. void), a
  -            // <code>AssertionFailedError</code> exception is returned.
  -            if (this.getCurrentTestMethod().equals(
  -                    "testBeginMethodBadReturnType")) {
  -
  -                assertEquals("The begin method " +
  -                    "[beginBeginMethodBadReturnType] should return void and " +
  -                    "not [java.lang.String]", e.getMessage());
  -                return;
  +                throw e;
               }
   
  -            // Test that when a begin method for a given test is not declared
  -            // public a <code>AssertionFailedError</code> exception is returned.
  -            if (this.getCurrentTestMethod().equals(
  -                    "testBeginMethodNotPublic")) {
  -
  -                assertEquals("Method [beginBeginMethodNotPublic] should be " +
  -                    "declared public", e.getMessage());
  -                return;
  -            }
  +        }
   
  -            // Test that when a begin method for a given test has the wrong
  -            // type of parameters, a <code>AssertionFailedError</code> exception
  -            // is returned.
  -            if (this.getCurrentTestMethod().equals(
  -                    "testBeginMethodBadParamType")) {
  -
  -                assertEquals("The begin method " +
  -                    "[beginBeginMethodBadParamType] must accept a single " +
  -                    "parameter derived from class " +
  -                    "[org.apache.cactus.WebRequest], but " +
  -                    "found a [java.lang.String] parameter instead",
  -                    e.getMessage());
  -                return;
  -            }
  +    }
   
  -            // Test that when a begin method for a given test has the wrong
  -            // number of parameters, a <code>AssertionFailedError</code>
  -            // exception is returned.
  -            if (this.getCurrentTestMethod().equals(
  -                    "testBeginMethodBadParamNumber")) {
  -
  -                assertEquals("The begin method " +
  -                    "[beginBeginMethodBadParamNumber] must accept a single " +
  -                    "parameter derived from class " +
  -                    "[org.apache.cactus.WebRequest], but 2 " +
  -                    "parameters were found",
  -                    e.getMessage());
  -                return;
  -            }
  +    /**
  +     * Assert begin method tests.
  +     *
  +     * @param theMessage the error message from the exception
  +     * @return false is no test matches
  +     */
  +    private boolean verifyBeginMethodsOk(String theMessage)
  +    {
  +        // Test that when a begin method for a given test does not have the
  +        // correct return type (i.e. void), a
  +        // <code>AssertionFailedError</code> exception is returned.
  +        if (this.getCurrentTestMethod().equals(
  +                "testBeginMethodBadReturnType")) {
  +
  +            assertEquals("The begin method " +
  +                "[beginBeginMethodBadReturnType] should return void and " +
  +                "not [java.lang.String]", theMessage);
  +            return true;
  +        }
   
  -            // Verify that the begin method with a
  -            // <code>WebRequest</code> parameter is called correctly.
  -            if (this.getCurrentTestMethod().equals("testBeginMethodOK")) {
  -                assertEquals("beginBeginMethodOK", e.getMessage());
  -                return;
  -            }
  +        // Test that when a begin method for a given test is not declared
  +        // public a <code>AssertionFailedError</code> exception is returned.
  +        if (this.getCurrentTestMethod().equals(
  +                "testBeginMethodNotPublic")) {
  +
  +            assertEquals("Method [beginBeginMethodNotPublic] should be " +
  +                "declared public", theMessage);
  +            return true;
  +        }
   
  -            // ------ Tests for end methods ----------------------------------
  +        // Test that when a begin method for a given test has the wrong
  +        // type of parameters, a <code>AssertionFailedError</code> exception
  +        // is returned.
  +        if (this.getCurrentTestMethod().equals(
  +                "testBeginMethodBadParamType")) {
  +
  +            assertEquals("The begin method " +
  +                "[beginBeginMethodBadParamType] must accept a single " +
  +                "parameter derived from class " +
  +                "[org.apache.cactus.WebRequest], but " +
  +                "found a [java.lang.String] parameter instead",
  +                theMessage);
  +            return true;
  +        }
   
  -            // Test that when an end method for a given test does not have the
  -            // correct return type (i.e. void), a
  -            // <code>AssertionFailedError</code> exception is returned.
  -            if (this.getCurrentTestMethod().equals(
  -                    "testEndMethodBadReturnType")) {
  -
  -                assertEquals("The end method " +
  -                    "[endEndMethodBadReturnType] should return void and " +
  -                    "not [java.lang.String]", e.getMessage());
  -                return;
  -            }
  +        // Test that when a begin method for a given test has the wrong
  +        // number of parameters, a <code>AssertionFailedError</code>
  +        // exception is returned.
  +        if (this.getCurrentTestMethod().equals(
  +                "testBeginMethodBadParamNumber")) {
  +
  +            assertEquals("The begin method " +
  +                "[beginBeginMethodBadParamNumber] must accept a single " +
  +                "parameter derived from class " +
  +                "[org.apache.cactus.WebRequest], but 2 " +
  +                "parameters were found",
  +                theMessage);
  +            return true;
  +        }
   
  -            // Test that when an end method for a given test is not declared
  -            // public a <code>AssertionFailedError</code> exception is returned.
  -            if (this.getCurrentTestMethod().equals("testEndMethodNotPublic")) {
  -                assertEquals("Method [endEndMethodNotPublic] should be " +
  -                    "declared public", e.getMessage());
  -                return;
  -            }
  +        // Verify that the begin method with a
  +        // <code>WebRequest</code> parameter is called correctly.
  +        if (this.getCurrentTestMethod().equals("testBeginMethodOK")) {
  +            assertEquals("beginBeginMethodOK", theMessage);
  +            return true;
  +        }
   
  -            // Test that when an end method for a given test has the wrong
  -            // type of parameters, a <code>AssertionFailedError</code> exception
  -            // is returned.
  -            if (this.getCurrentTestMethod().equals(
  -                    "testEndMethodBadParamType")) {
  -
  -                assertEquals("The end method [endEndMethodBadParamType] " +
  -                    "has a bad parameter of type [java.lang.String]",
  -                    e.getMessage());
  -                return;
  -            }
  +        return false;
  +    }
   
  -            // Test that when an end method for a given test has the wrong
  -            // number of parameters, a <code>AssertionFailedError</code>
  -            // exception is returned.
  -            if (this.getCurrentTestMethod().equals(
  -                    "testEndMethodBadParamNumber")) {
  -
  -                assertEquals("The end method [endEndMethodBadParamNumber] " +
  -                    "must only have a single parameter", e.getMessage());
  -                return;
  -            }
  +    /**
  +     * Assert end method tests.
  +     *
  +     * @param theMessage the error message from the exception
  +     * @return false is no test matches
  +     */
  +    private boolean verifyEndMethodsOk(String theMessage)
  +    {
  +        // Test that when an end method for a given test does not have the
  +        // correct return type (i.e. void), a
  +        // <code>AssertionFailedError</code> exception is returned.
  +        if (this.getCurrentTestMethod().equals(
  +                "testEndMethodBadReturnType")) {
  +
  +            assertEquals("The end method " +
  +                "[endEndMethodBadReturnType] should return void and " +
  +                "not [java.lang.String]", theMessage);
  +            return true;
  +        }
   
  -            // Test that the end method is called correctly when it's signature
  -            // contains a <code>org.apache.cactus.WebResponse</code>
  -            // parameter.
  -            if (this.getCurrentTestMethod().equals("testEndMethodOK1")) {
  -                assertEquals("endEndMethodOK1", e.getMessage());
  -                return;
  -            }
  +        // Test that when an end method for a given test is not declared
  +        // public a <code>AssertionFailedError</code> exception is returned.
  +        if (this.getCurrentTestMethod().equals("testEndMethodNotPublic")) {
  +            assertEquals("Method [endEndMethodNotPublic] should be " +
  +                "declared public", theMessage);
  +            return true;
  +        }
   
  -            // Test that the end method is called correctly when it's signature
  -            // contains a <code>com.meterware.httpunit.WebResponse</code>
  -            // parameter.
  -            if (this.getCurrentTestMethod().equals("testEndMethodOK2")) {
  -                assertEquals("endEndMethodOK2", e.getMessage());
  -                return;
  -            }
  +        // Test that when an end method for a given test has the wrong
  +        // type of parameters, a <code>AssertionFailedError</code> exception
  +        // is returned.
  +        if (this.getCurrentTestMethod().equals(
  +                "testEndMethodBadParamType")) {
  +
  +            assertEquals("The end method [endEndMethodBadParamType] " +
  +                "has a bad parameter of type [java.lang.String]",
  +                theMessage);
  +            return true;
  +        }
   
  -            // Test that the deprecated end method with the
  -            // <code>HttpURLConnection</code> parameter can still be called
  -            // correctly.
  -            if (this.getCurrentTestMethod().equals("testEndMethodOK3")) {
  -                assertEquals("endEndMethodOK3", e.getMessage());
  -                return;
  -            }
  +        // Test that when an end method for a given test has the wrong
  +        // number of parameters, a <code>AssertionFailedError</code>
  +        // exception is returned.
  +        if (this.getCurrentTestMethod().equals(
  +                "testEndMethodBadParamNumber")) {
  +
  +            assertEquals("The end method [endEndMethodBadParamNumber] " +
  +                "must only have a single parameter", theMessage);
  +            return true;
  +        }
   
  -            // If the exception is unknown, let it be raised ...
  -            throw e;
  +        // Test that the end method is called correctly when it's signature
  +        // contains a <code>org.apache.cactus.WebResponse</code>
  +        // parameter.
  +        if (this.getCurrentTestMethod().equals("testEndMethodOK1")) {
  +            assertEquals("endEndMethodOK1", theMessage);
  +            return true;
  +        }
  +
  +        // Test that the end method is called correctly when it's signature
  +        // contains a <code>com.meterware.httpunit.WebResponse</code>
  +        // parameter.
  +        if (this.getCurrentTestMethod().equals("testEndMethodOK2")) {
  +            assertEquals("endEndMethodOK2", theMessage);
  +            return true;
  +        }
   
  +        // Test that the deprecated end method with the
  +        // <code>HttpURLConnection</code> parameter can still be called
  +        // correctly.
  +        if (this.getCurrentTestMethod().equals("testEndMethodOK3")) {
  +            assertEquals("endEndMethodOK3", theMessage);
  +            return true;
           }
   
  +        return false;
       }
  +
   }
  
  
  

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

Reply via email to