You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2003/07/12 11:04:55 UTC

cvs commit: jakarta-cactus/framework/src/java/share/org/apache/cactus AbstractWebServerTestCase.java AbstractWebClientTestCase.java AbstractClientTestCase.java

vmassol     2003/07/12 02:04:55

  Modified:    framework/src/test/share/org/apache/cactus
                        TestAbstractTestCaseInterceptorTestCase.java
               samples/servlet/src/test-cactus/share/org/apache/cactus/sample/unit
                        TestServerSideExceptions.java
               framework/src/java/share/org/apache/cactus
                        AbstractWebServerTestCase.java
                        AbstractWebClientTestCase.java
                        AbstractClientTestCase.java
  Log:
  Deprecated getCurrentTestMethod() and replaced it by getCurrentTestName() which is a better name. In preparation for defining a CactusTestCase interface which will contain the extension to TestCase and that will be implemented by all XXXTestCase (ServletTestCase, etc). The class hierarchy will also be removed in favor of delegates so that we don't have to make the whole hierarchy API-public. In addition that will prevent users using lots of methods they are not even supposed to see such as callBeginMethod(), createConfiguration(), etc.
  
  Revision  Changes    Path
  1.14      +13 -13    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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TestAbstractTestCaseInterceptorTestCase.java	22 Jun 2003 18:00:26 -0000	1.13
  +++ TestAbstractTestCaseInterceptorTestCase.java	12 Jul 2003 09:04:54 -0000	1.14
  @@ -164,7 +164,7 @@
           // 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"))
  +        if (this.getCurrentTestName().equals("testBeginMethodBadReturnType"))
           {
               assertEquals("The method "
                   + "[beginBeginMethodBadReturnType] should return void and "
  @@ -175,7 +175,7 @@
   
           // 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"))
  +        if (this.getCurrentTestName().equals("testBeginMethodNotPublic"))
           {
               assertEquals("Method [beginBeginMethodNotPublic] should be "
                   + "declared public", theMessage);
  @@ -186,7 +186,7 @@
           // 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"))
  +        if (this.getCurrentTestName().equals("testBeginMethodBadParamType"))
           {
               assertEquals("The method "
                   + "[beginBeginMethodBadParamType] must accept a single "
  @@ -200,7 +200,7 @@
           // 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"))
  +        if (this.getCurrentTestName().equals("testBeginMethodBadParamNumber"))
           {
               assertEquals("The method "
                   + "[beginBeginMethodBadParamNumber] must accept a single "
  @@ -213,7 +213,7 @@
   
           // Verify that the begin method with a
           // <code>WebRequest</code> parameter is called correctly.
  -        if (this.getCurrentTestMethod().equals("testBeginMethodOK"))
  +        if (this.getCurrentTestName().equals("testBeginMethodOK"))
           {
               assertEquals("beginBeginMethodOK", theMessage);
   
  @@ -234,7 +234,7 @@
           // 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"))
  +        if (this.getCurrentTestName().equals("testEndMethodBadReturnType"))
           {
               assertEquals("The method "
                   + "[endEndMethodBadReturnType] should return void and "
  @@ -245,7 +245,7 @@
   
           // 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"))
  +        if (this.getCurrentTestName().equals("testEndMethodNotPublic"))
           {
               assertEquals("Method [endEndMethodNotPublic] should be "
                   + "declared public", theMessage);
  @@ -256,7 +256,7 @@
           // 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"))
  +        if (this.getCurrentTestName().equals("testEndMethodBadParamType"))
           {
               assertEquals("The method [endEndMethodBadParamType] "
                   + "has a bad parameter of type [java.lang.String]", 
  @@ -268,7 +268,7 @@
           // 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"))
  +        if (this.getCurrentTestName().equals("testEndMethodBadParamNumber"))
           {
               assertEquals("The method [endEndMethodBadParamNumber] "
                   + "must only have a single parameter", theMessage);
  @@ -279,7 +279,7 @@
           // 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"))
  +        if (this.getCurrentTestName().equals("testEndMethodOK1"))
           {
               assertEquals("endEndMethodOK1", theMessage);
   
  @@ -289,7 +289,7 @@
           // 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"))
  +        if (this.getCurrentTestName().equals("testEndMethodOK2"))
           {
               assertEquals("endEndMethodOK2", theMessage);
   
  @@ -299,7 +299,7 @@
           // Test that the deprecated end method with the
           // <code>HttpURLConnection</code> parameter can still be called
           // correctly.
  -        if (this.getCurrentTestMethod().equals("testEndMethodOK3"))
  +        if (this.getCurrentTestName().equals("testEndMethodOK3"))
           {
               assertEquals("endEndMethodOK3", theMessage);
   
  
  
  
  1.6       +5 -5      jakarta-cactus/samples/servlet/src/test-cactus/share/org/apache/cactus/sample/unit/TestServerSideExceptions.java
  
  Index: TestServerSideExceptions.java
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/samples/servlet/src/test-cactus/share/org/apache/cactus/sample/unit/TestServerSideExceptions.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestServerSideExceptions.java	26 May 2003 12:15:13 -0000	1.5
  +++ TestServerSideExceptions.java	12 Jul 2003 09:04:54 -0000	1.6
  @@ -124,7 +124,7 @@
               // If the test case is "testAssertionFailedError" and the exception
               // is of type AssertionFailedError and contains the text
               // "test assertion failed error", then the test is ok.
  -            if (this.getCurrentTestMethod().equals("testAssertionFailedError"))
  +            if (this.getCurrentTestName().equals("testAssertionFailedError"))
               {
                   if (e.instanceOf(AssertionFailedError.class))
                   {
  @@ -138,7 +138,7 @@
               // is of type ComparisonFailure and contains the text
               // "test comparison failure", then the test is ok.
               else if (
  -                this.getCurrentTestMethod().equals("testComparisonFailure"))
  +                this.getCurrentTestName().equals("testComparisonFailure"))
               {
                   if (e.instanceOf(AssertionFailedError.class))
                   {
  @@ -156,7 +156,7 @@
               // TestServletTestCaseHelper1_ExceptionNotSerializable
               // and contains the text "test non serializable exception", then
               // the test is ok.
  -            if (this.getCurrentTestMethod().equals(
  +            if (this.getCurrentTestName().equals(
                   "testExceptionNotSerializable"))
               {
                   if (e.instanceOf(NotSerializableException.class))
  @@ -172,7 +172,7 @@
               // is of type TestServletTestCaseHelper1_ExceptionSerializable
               // and contains the text "test serializable exception", then
               // the test is ok.
  -            if (this.getCurrentTestMethod().equals("testExceptionSerializable"))
  +            if (this.getCurrentTestName().equals("testExceptionSerializable"))
               {
                   assertTrue(e.instanceOf(SerializableException.class));
   
  
  
  
  1.14      +5 -4      jakarta-cactus/framework/src/java/share/org/apache/cactus/AbstractWebServerTestCase.java
  
  Index: AbstractWebServerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/AbstractWebServerTestCase.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- AbstractWebServerTestCase.java	9 Jul 2003 16:36:06 -0000	1.13
  +++ AbstractWebServerTestCase.java	12 Jul 2003 09:04:54 -0000	1.14
  @@ -65,6 +65,7 @@
   
   import org.apache.cactus.client.connector.http.DefaultHttpClient;
   import org.apache.cactus.configuration.WebConfiguration;
  +import org.apache.cactus.util.UniqueGenerator;
   import org.apache.commons.logging.LogFactory;
   
   /**
  @@ -160,18 +161,18 @@
               // methods of this class but excludes the
               // inherited ones.
               runMethod = getWrappedTest().getClass().getMethod(
  -                this.getCurrentTestMethod(), new Class[0]);
  +                this.getCurrentTestName(), new Class[0]);
           }
           catch (NoSuchMethodException e)
           {
  -            fail("Method [" + this.getCurrentTestMethod()
  +            fail("Method [" + this.getCurrentTestName()
                   + "()] does not exist for class [" 
                   + getWrappedTest().getClass().getName() + "].");
           }
   
           if ((runMethod != null) && !Modifier.isPublic(runMethod.getModifiers()))
           {
  -            fail("Method [" + this.getCurrentTestMethod()
  +            fail("Method [" + this.getCurrentTestName()
                   + "()] should be public");
           }
   
  @@ -246,7 +247,7 @@
           // automatic session creation flag to the request
           RequestDirectives directives = new RequestDirectives(theRequest);
           directives.setClassName(this.getClass().getName());
  -        directives.setMethodName(this.getCurrentTestMethod());
  +        directives.setMethodName(this.getCurrentTestName());
           directives.setAutoSession(
               theRequest.getAutomaticSession() ? "true" : "false");
   
  
  
  
  1.5       +2 -2      jakarta-cactus/framework/src/java/share/org/apache/cactus/AbstractWebClientTestCase.java
  
  Index: AbstractWebClientTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/AbstractWebClientTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractWebClientTestCase.java	26 May 2003 11:45:23 -0000	1.4
  +++ AbstractWebClientTestCase.java	12 Jul 2003 09:04:54 -0000	1.5
  @@ -190,7 +190,7 @@
                   {
                       fail("There can only be one method ["
                           + methods[i].getName() + "] per test case. "
  -                        + "Test case [" + this.getCurrentTestMethod()
  +                        + "Test case [" + this.getCurrentTestName()
                           + "] has two at least !");
                   }
   
  
  
  
  1.6       +12 -3     jakarta-cactus/framework/src/java/share/org/apache/cactus/AbstractClientTestCase.java
  
  Index: AbstractClientTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/AbstractClientTestCase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractClientTestCase.java	26 May 2003 11:45:23 -0000	1.5
  +++ AbstractClientTestCase.java	12 Jul 2003 09:04:54 -0000	1.6
  @@ -412,12 +412,21 @@
       }
   
       /**
  +     * @see #getCurrentTestName()
  +     * @deprecated Use {@link #getCurrentTestName()} instead
  +     */
  +    protected String getCurrentTestMethod()
  +    {
  +        return getCurrentTestName();
  +    }
  +
  +    /**
        * @return the name of the current test case being executed (it corresponds
        *         to the name of the test method with the "test" prefix removed.
        *         For example, for "testSomeTestOk" would return "someTestOk".
        */
  -    protected String getCurrentTestMethod()
  +    protected String getCurrentTestName()
       {
  -        return JUnitVersionHelper.getTestCaseName(this);
  +        return JUnitVersionHelper.getTestCaseName(this);        
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org