aherbert commented on a change in pull request #731:
URL: https://github.com/apache/commons-lang/pull/731#discussion_r596269673
##########
File path: src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
##########
@@ -1131,6 +1140,24 @@ public void test_isAssignable_Widening() {
assertTrue(ClassUtils.isAssignable(Boolean.TYPE, Boolean.TYPE),
"boolean -> boolean");
}
+ /**
+ * Test for {@link ClassUtils#isOverridable(Method, Class)}.
+ */
+ @Test
+ public void test_isOverridable() throws Exception {
+ final Method publicMethod =
ABG.class.getDeclaredMethod("publicMethod", null);
+ assertTrue(ClassUtils.isOverridable(publicMethod, Object.class));
+ assertFalse(ClassUtils.isOverridable(null, Object.class));
+ final Method privateMethod =
ABG.class.getDeclaredMethod("privateMethod", null);
+ assertFalse(ClassUtils.isOverridable(privateMethod, ABG.class));
+ final Method defaultMethod =
ABG.class.getDeclaredMethod("defaultMethod", null);
Review comment:
The test case should also pull in a default method from a super class
declared in another package and test that the result is false. Try putting a
public class in `src/test/o.a.c.lang3/reflect/testbed` with a default method
then extending that in your test class (e.g. `ClassUtilsTest.ABG2`) and see if
the method detects the package is incorrect and it cannot be overridden
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]