Author: bayard Date: Sun Jul 3 06:59:59 2011 New Revision: 1142380 URL: http://svn.apache.org/viewvc?rev=1142380&view=rev Log: Additional tests for MethodUtils from Nathan Beyer - LANG-712
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=1142380&r1=1142379&r2=1142380&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 Sun Jul 3 06:59:59 2011 @@ -33,6 +33,15 @@ import org.apache.commons.lang3.mutable. * @version $Id$ */ public class MethodUtilsTest extends TestCase { + + private static interface PrivateInterface {} + + static class TestBeanWithInterfaces implements PrivateInterface { + public String foo() { + return "foo()"; + } + } + public static class TestBean { public static String bar() { @@ -58,6 +67,11 @@ public class MethodUtilsTest extends Tes public static String bar(Object o) { return "bar(Object)"; } + + @SuppressWarnings("unused") + private void privateStuff() { + } + public String foo() { return "foo()"; @@ -247,6 +261,13 @@ public class MethodUtilsTest extends Tes assertSame(Mutable.class, accessibleMethod.getDeclaringClass()); } } + + public void testGetAccessibleMethodPrivateInterface() throws Exception { + Method expected = TestBeanWithInterfaces.class.getMethod("foo"); + assertNotNull(expected); + Method actual = MethodUtils.getAccessibleMethod(TestBeanWithInterfaces.class, "foo"); + assertNull(actual); + } public void testGetAccessibleInterfaceMethodFromDescription() throws Exception { @@ -269,6 +290,12 @@ public class MethodUtilsTest extends Tes MutableObject.class, "getValue", ArrayUtils.EMPTY_CLASS_ARRAY) .getDeclaringClass()); } + + public void testGetAccessibleMethodInaccessible() throws Exception { + Method expected = TestBean.class.getDeclaredMethod("privateStuff"); + Method actual = MethodUtils.getAccessibleMethod(expected); + assertNull(actual); + } public void testGetMatchingAccessibleMethod() throws Exception { expectMatchingAccessibleMethodParameterTypes(TestBean.class, "foo",