You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/03/29 19:27:03 UTC
[lang] Some reflection tests must account for classes files being
instrumented by Jacoco.
Repository: commons-lang
Updated Branches:
refs/heads/master 56b7ae44f -> 17f9d22f3
Some reflection tests must account for classes files being instrumented
by Jacoco.
Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/17f9d22f
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/17f9d22f
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/17f9d22f
Branch: refs/heads/master
Commit: 17f9d22f334c91e701808808170bf60aae7342f9
Parents: 56b7ae4
Author: Gary Gregory <ga...@gmail.com>
Authored: Thu Mar 29 13:26:59 2018 -0600
Committer: Gary Gregory <ga...@gmail.com>
Committed: Thu Mar 29 13:26:59 2018 -0600
----------------------------------------------------------------------
.../commons/lang3/reflect/FieldUtilsTest.java | 21 ++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/17f9d22f/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
index 16a3f59..dbf114d 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java
@@ -165,7 +165,15 @@ public class FieldUtilsTest {
assertArrayEquals(fieldsNumber, FieldUtils.getAllFields(Number.class));
final Field[] fieldsInteger = Integer.class.getDeclaredFields();
assertArrayEquals(ArrayUtils.addAll(fieldsInteger, fieldsNumber), FieldUtils.getAllFields(Integer.class));
- assertEquals(5, FieldUtils.getAllFields(PublicChild.class).length);
+ final Field[] allFields = FieldUtils.getAllFields(PublicChild.class);
+ // Under Jacoco,0.8.1 and Java 10, the field count is 7.
+ int expected = 5;
+ for (Field field : allFields) {
+ if (field.getName().equals("$jacocoData")) {
+ expected++;
+ }
+ }
+ assertEquals(Arrays.toString(allFields), expected, allFields.length);
}
@Test
@@ -177,7 +185,16 @@ public class FieldUtilsTest {
final List<Field> allFieldsInteger = new ArrayList<>(fieldsInteger);
allFieldsInteger.addAll(fieldsNumber);
assertEquals(allFieldsInteger, FieldUtils.getAllFieldsList(Integer.class));
- assertEquals(5, FieldUtils.getAllFieldsList(PublicChild.class).size());
+ final List<Field> allFields = FieldUtils.getAllFieldsList(PublicChild.class);
+ // Under Jacoco,0.8.1 and Java 10, the field count is 7.
+ int expected = 5;
+ for (Field field : allFields) {
+ if (field.getName().equals("$jacocoData")) {
+ expected++;
+ }
+ }
+ assertEquals(allFields.toString(), expected, allFields.size());
+
}
@Test