commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1166220 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
Date Wed, 07 Sep 2011 15:18:07 GMT
Author: ggregory
Date: Wed Sep  7 15:18:06 2011
New Revision: 1166220

URL: http://svn.apache.org/viewvc?rev=1166220&view=rev
Log:
Convert to JUnit 4 from 3.

Modified:
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java?rev=1166220&r1=1166219&r2=1166220&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java
Wed Sep  7 15:18:06 2011
@@ -16,23 +16,32 @@
  */
 package org.apache.commons.lang3.reflect;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.math.NumberUtils;
 import org.apache.commons.lang3.mutable.Mutable;
 import org.apache.commons.lang3.mutable.MutableObject;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 /**
  * Unit tests MethodUtils
  * @version $Id$
  */
-public class MethodUtilsTest extends TestCase {
+public class MethodUtilsTest {
   
     private static interface PrivateInterface {}
     
@@ -96,6 +105,10 @@ public class MethodUtilsTest extends Tes
         public String foo(Object o) {
             return "foo(Object)";
         }
+        
+        public void oneParameter(String s) {
+            // empty
+        }
     }
 
     private static class TestMutable implements Mutable<Object> {
@@ -108,24 +121,20 @@ public class MethodUtilsTest extends Tes
     }
 
     private TestBean testBean;
-    private Map<Class<?>, Class<?>[]> classCache;
-
-    public MethodUtilsTest(String name) {
-        super(name);
-        classCache = new HashMap<Class<?>, Class<?>[]>();
-    }
+    private Map<Class<?>, Class<?>[]> classCache = new HashMap<Class<?>,
Class<?>[]>();
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Before
+    public void setUp() throws Exception {
         testBean = new TestBean();
         classCache.clear();
     }
 
+    @Test
     public void testConstructor() throws Exception {
         assertNotNull(MethodUtils.class.newInstance());
     }
 
+    @Test
     public void testInvokeMethod() throws Exception {
         assertEquals("foo()", MethodUtils.invokeMethod(testBean, "foo",
                 (Object[]) ArrayUtils.EMPTY_CLASS_ARRAY));
@@ -149,6 +158,7 @@ public class MethodUtilsTest extends Tes
                 NumberUtils.DOUBLE_ONE));
     }
 
+    @Test
     public void testInvokeExactMethod() throws Exception {
         assertEquals("foo()", MethodUtils.invokeExactMethod(testBean, "foo",
                 (Object[]) ArrayUtils.EMPTY_CLASS_ARRAY));
@@ -185,6 +195,12 @@ public class MethodUtilsTest extends Tes
         }
     }
 
+    @Test
+    public void testInvokeExactMethodNoParam() throws Exception {
+        assertEquals("foo()", MethodUtils.invokeExactMethod(testBean, "foo"));
+    }
+
+    @Test
     public void testInvokeStaticMethod() throws Exception {
         assertEquals("bar()", MethodUtils.invokeStaticMethod(TestBean.class,
                 "bar", (Object[]) ArrayUtils.EMPTY_CLASS_ARRAY));
@@ -214,6 +230,7 @@ public class MethodUtilsTest extends Tes
         }
     }
 
+    @Test
     public void testInvokeExactStaticMethod() throws Exception {
         assertEquals("bar()", MethodUtils.invokeExactStaticMethod(TestBean.class,
                 "bar", (Object[]) ArrayUtils.EMPTY_CLASS_ARRAY));
@@ -251,8 +268,8 @@ public class MethodUtilsTest extends Tes
         }
     }
 
+    @Test
     public void testGetAccessibleInterfaceMethod() throws Exception {
-
         Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
         for (Class<?>[] element : p) {
             Method method = TestMutable.class.getMethod("getValue", element);
@@ -262,6 +279,7 @@ public class MethodUtilsTest extends Tes
         }
     }
     
+    @Test
     public void testGetAccessibleMethodPrivateInterface() throws Exception {
         Method expected = TestBeanWithInterfaces.class.getMethod("foo");
         assertNotNull(expected);
@@ -269,6 +287,7 @@ public class MethodUtilsTest extends Tes
         assertNull(actual);
     }
 
+    @Test
     public void testGetAccessibleInterfaceMethodFromDescription()
             throws Exception {
         Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
@@ -279,25 +298,29 @@ public class MethodUtilsTest extends Tes
         }
     }
 
+    @Test
     public void testGetAccessiblePublicMethod() throws Exception {
         assertSame(MutableObject.class, MethodUtils.getAccessibleMethod(
                 MutableObject.class.getMethod("getValue",
                         ArrayUtils.EMPTY_CLASS_ARRAY)).getDeclaringClass());
     }
 
+    @Test
     public void testGetAccessiblePublicMethodFromDescription() throws Exception {
         assertSame(MutableObject.class, MethodUtils.getAccessibleMethod(
                 MutableObject.class, "getValue", ArrayUtils.EMPTY_CLASS_ARRAY)
                 .getDeclaringClass());
     }
     
-    public void testGetAccessibleMethodInaccessible() throws Exception {
+    @Test
+   public void testGetAccessibleMethodInaccessible() throws Exception {
         Method expected = TestBean.class.getDeclaredMethod("privateStuff");
         Method actual = MethodUtils.getAccessibleMethod(expected);
         assertNull(actual);
     }
 
-    public void testGetMatchingAccessibleMethod() throws Exception {
+    @Test
+   public void testGetMatchingAccessibleMethod() throws Exception {
         expectMatchingAccessibleMethodParameterTypes(TestBean.class, "foo",
                 ArrayUtils.EMPTY_CLASS_ARRAY, ArrayUtils.EMPTY_CLASS_ARRAY);
         expectMatchingAccessibleMethodParameterTypes(TestBean.class, "foo",
@@ -378,7 +401,8 @@ public class MethodUtilsTest extends Tes
         public void testTwo(GrandParentObject obj) {}
         public void testTwo(ChildInterface obj) {}
     }
-    interface ChildInterface {}
+    
+    interface ChildInterface {}    
     public static class GrandParentObject {}
     public static class ParentObject extends GrandParentObject {}
     public static class ChildObject extends ParentObject implements ChildInterface {}



Mime
View raw message