struberg commented on code in PR #1328:
URL: https://github.com/apache/commons-lang/pull/1328#discussion_r1871947649
##########
src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java:
##########
@@ -229,21 +230,33 @@ public void assertReflectionArray(final String expected,
final Object actual) {
*/
@Test
public void test_setUpToClass_invalid() {
- final Integer val = Integer.valueOf(5);
+ final HirAFixture val = new HirAFixture();
final ReflectionToStringBuilder test = new
ReflectionToStringBuilder(val);
assertThrows(IllegalArgumentException.class, () ->
test.setUpToClass(String.class));
test.toString();
}
+ private static class HirAFixture extends HirBFixture {
+ int x = 1;
+ }
+
+ private static class HirBFixture extends HirCFixture {
+ int y = 2;
+ }
+
+ private static class HirCFixture {
+ int z = 3;
+ }
+
/**
* Tests ReflectionToStringBuilder setUpToClass().
*/
@Test
public void test_setUpToClass_valid() {
- final Integer val = Integer.valueOf(5);
+ final HirAFixture val = new HirAFixture();
final ReflectionToStringBuilder test = new
ReflectionToStringBuilder(val);
- test.setUpToClass(Number.class);
Review Comment:
In this very case this test simply makes no sense. setUpToClass is INCLUDING
the very class given. But if you introspect into any java.lang.Number, then it
will just blow up your whole application from Java9 onwards...
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]