ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/optional/junit JUnitVersionHelperTest.java
Date Mon, 16 Sep 2002 14:08:38 GMT
bodewig     2002/09/16 07:08:38

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/junit
                        JUnitVersionHelper.java
               src/testcases/org/apache/tools/ant/taskdefs/optional/junit
                        JUnitVersionHelperTest.java
  Log:
  Support name() accessors as well.
  
  Submitted by:	Andrew Everitt <Andrew.Everitt at gbr.xerox.com>
  
  Revision  Changes    Path
  1.6       +11 -4     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
  
  Index: JUnitVersionHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JUnitVersionHelper.java	13 Sep 2002 10:03:11 -0000	1.5
  +++ JUnitVersionHelper.java	16 Sep 2002 14:08:38 -0000	1.6
  @@ -96,9 +96,16 @@
               } catch (Throwable e) {}
           } else {
               try {
  -                Method getNameMethod = 
  -                    t.getClass().getMethod("getName", new Class [0]);
  -                if (getNameMethod.getReturnType() == String.class) {
  +                Method getNameMethod = null;
  +                try {
  +                    getNameMethod = 
  +                        t.getClass().getMethod("getName", new Class [0]);
  +                } catch (NoSuchMethodException e) {
  +                    getNameMethod = t.getClass().getMethod("name", 
  +                                                           new Class [0]);
  +                }
  +                if (getNameMethod != null &&
  +                    getNameMethod.getReturnType() == String.class) {
                       return (String) getNameMethod.invoke(t, new Object[0]);
                   }
               } catch (Throwable e) {}
  
  
  
  1.2       +11 -1     jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java
  
  Index: JUnitVersionHelperTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JUnitVersionHelperTest.java	13 Sep 2002 10:03:11 -0000	1.1
  +++ JUnitVersionHelperTest.java	16 Sep 2002 14:08:38 -0000	1.2
  @@ -87,6 +87,11 @@
                        JUnitVersionHelper.getTestCaseName(new Foo3()));
       }
   
  +    public void testNameNotGetName() {
  +        assertEquals("I'm a foo, too", 
  +                     JUnitVersionHelper.getTestCaseName(new Foo4()));
  +    }
  +
       public void testNull() {
           assertEquals("unknown", JUnitVersionHelper.getTestCaseName(null));
       }
  @@ -106,4 +111,9 @@
   
       public static class Foo3 extends Foo {
       }
  +
  +    public static class Foo4 extends Foo {
  +        public String name() {return "I'm a foo, too";}
  +    }
  +
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message