Last active
June 12, 2017 12:28
-
-
Save shelaf/885fe42695fef50b3103fc1e5a8b8aa3 to your computer and use it in GitHub Desktop.
Javaでオーバーライドされた元のメソッドを呼ぶ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class clazz = Application.class; | |
Method method = clazz.getDeclaredMethod("validate", String.class); | |
method.setAccessible(true); | |
method.invoke(null, "1w"); | |
Field field = clazz.getSuperclass().getDeclaredField("validation"); | |
field.setAccessible(true); | |
Validation v = (Validation) field.get(null); | |
assertEquals(1, v.errorsMap().size()); | |
Method m = v.getClass().getDeclaredMethod("clear"); | |
m.invoke(null); | |
assertEquals(0, v.errorsMap().size()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment