mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-07 18:48:39 +00:00
Additional tests for MethodUtils from Nathan Beyer - LANG-712
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1142380 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e3cb1c6c0a
commit
f5cb67acd9
@ -33,6 +33,15 @@
|
||||
* @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 static String bar(String s) {
|
||||
public static String bar(Object o) {
|
||||
return "bar(Object)";
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void privateStuff() {
|
||||
}
|
||||
|
||||
|
||||
public String foo() {
|
||||
return "foo()";
|
||||
@ -247,6 +261,13 @@ public void testGetAccessibleInterfaceMethod() throws Exception {
|
||||
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 void testGetAccessiblePublicMethodFromDescription() throws Exception {
|
||||
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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user