2011/08/05 - Jakarta Cactus has been retired.

For more information, please explore the Attic.

Clover coverage report - Cactus 1.8dev for J2EE API 1.3
Coverage timestamp: Sun Mar 26 2006 18:50:18 BRT
file stats: LOC: 95   Methods: 1
NCLOC: 47   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
JUnitVersionHelper.java 50% 58.3% 100% 60%
coverage coverage
 1   
 /* 
 2   
  * ========================================================================
 3   
  * 
 4   
  * Copyright 2001-2003 The Apache Software Foundation.
 5   
  *
 6   
  * Licensed under the Apache License, Version 2.0 (the "License");
 7   
  * you may not use this file except in compliance with the License.
 8   
  * You may obtain a copy of the License at
 9   
  * 
 10   
  *   http://www.apache.org/licenses/LICENSE-2.0
 11   
  * 
 12   
  * Unless required by applicable law or agreed to in writing, software
 13   
  * distributed under the License is distributed on an "AS IS" BASIS,
 14   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15   
  * See the License for the specific language governing permissions and
 16   
  * limitations under the License.
 17   
  * 
 18   
  * ========================================================================
 19   
  */
 20   
 package org.apache.cactus.internal.util;
 21   
 
 22   
 import java.lang.reflect.Method;
 23   
 
 24   
 import org.apache.cactus.util.ChainedRuntimeException;
 25   
 
 26   
 import junit.framework.Test;
 27   
 import junit.framework.TestCase;
 28   
 
 29   
 /**
 30   
  * Work around for some changes to the public JUnit API between
 31   
  * different JUnit releases.
 32   
  *
 33   
  * @version $Id: JUnitVersionHelper.java 238991 2004-05-22 11:34:50Z vmassol $
 34   
  */
 35   
 public class JUnitVersionHelper
 36   
 {
 37   
     /**
 38   
      * The <code>Method</code> to use to get the test name from a
 39   
      * <code>TestCase</code> object.
 40   
      */
 41   
     private static Method testCaseName = null;
 42   
 
 43   
     static
 44   
     {
 45  1
         try
 46   
         {
 47  1
             testCaseName = TestCase.class.getMethod("getName", new Class[0]);
 48   
         }
 49   
         catch (NoSuchMethodException e)
 50   
         {
 51   
             // pre JUnit 3.7
 52  0
             try
 53   
             {
 54  0
                 testCaseName = TestCase.class.getMethod("name", new Class[0]);
 55   
             }
 56   
             catch (NoSuchMethodException e2)
 57   
             {
 58  0
                 throw new ChainedRuntimeException("Cannot find method name()");
 59   
             }
 60   
         }
 61   
     }
 62   
 
 63   
     /**
 64   
      * JUnit 3.7 introduces TestCase.getName() and subsequent versions
 65   
      * of JUnit remove the old name() method.  This method provides
 66   
      * access to the name of a TestCase via reflection that is
 67   
      * supposed to work with version before and after JUnit 3.7.
 68   
      *
 69   
      * @param theTest the test case for which to retrieve the name
 70   
      * @return the test case name
 71   
      */
 72  168
     public static String getTestCaseName(Test theTest)
 73   
     {
 74  168
         String name;
 75   
         
 76  168
         if (theTest instanceof TestCase && (testCaseName != null))
 77   
         {
 78  168
             try
 79   
             {
 80  168
                 name = (String) testCaseName.invoke(theTest, new Object[0]);
 81   
             }
 82   
             catch (Throwable e)
 83   
             {
 84  0
                 name = "unknown";
 85   
             }
 86   
         }
 87   
         else
 88   
         {
 89  0
             name = "unknown";
 90   
         }
 91   
 
 92  168
         return name;
 93   
     }
 94   
 }
 95