|
27 | 27 | import java.math.BigInteger; |
28 | 28 | import java.util.ArrayList; |
29 | 29 | import java.util.Arrays; |
| 30 | +import java.util.HashMap; |
30 | 31 | import java.util.List; |
| 32 | +import java.util.Map; |
31 | 33 |
|
32 | 34 | import org.apache.commons.lang3.AbstractLangTest; |
33 | 35 | import org.apache.commons.lang3.reflect.MethodUtils; |
@@ -69,6 +71,19 @@ public int hashCode() { |
69 | 71 | } |
70 | 72 | } |
71 | 73 |
|
| 74 | + static class TestArrayList extends ArrayList<String> { |
| 75 | + |
| 76 | + private static final long serialVersionUID = 1L; |
| 77 | + |
| 78 | + private final int extra; |
| 79 | + |
| 80 | + TestArrayList(final int extra, final String... elements) { |
| 81 | + super(Arrays.asList(elements)); |
| 82 | + this.extra = extra; |
| 83 | + } |
| 84 | + |
| 85 | + } |
| 86 | + |
72 | 87 | public static class TestBCanEqualA { |
73 | 88 | private final int b; |
74 | 89 |
|
@@ -106,6 +121,19 @@ static class TestEmptySubObject extends TestObject { |
106 | 121 | } |
107 | 122 | } |
108 | 123 |
|
| 124 | + static class TestHashMap extends HashMap<String, String> { |
| 125 | + |
| 126 | + private static final long serialVersionUID = 1L; |
| 127 | + |
| 128 | + private final int extra; |
| 129 | + |
| 130 | + TestHashMap(final int extra, final Map<String, String> map) { |
| 131 | + super(map); |
| 132 | + this.extra = extra; |
| 133 | + } |
| 134 | + |
| 135 | + } |
| 136 | + |
109 | 137 | static class TestObject { |
110 | 138 | private int a; |
111 | 139 |
|
@@ -1381,6 +1409,18 @@ private void testReflectionHierarchyEquals(final boolean testTransients) { |
1381 | 1409 | assertFalse(EqualsBuilder.reflectionEquals(tso1, this)); |
1382 | 1410 | } |
1383 | 1411 |
|
| 1412 | + @Test |
| 1413 | + void testReflectionOnCustomArrayList() { |
| 1414 | + assertTrue(EqualsBuilder.reflectionEquals(new TestArrayList(1, "2", "3", "4"), new TestArrayList(1, "2", "3", "4"))); |
| 1415 | + assertFalse(EqualsBuilder.reflectionEquals(new TestArrayList(1, "2", "3", "4"), new TestArrayList(2, "2", "3", "4"))); |
| 1416 | + } |
| 1417 | + |
| 1418 | + @Test |
| 1419 | + void testReflectionOnCustomHashMap() { |
| 1420 | + assertTrue(EqualsBuilder.reflectionEquals(new TestHashMap(1, new HashMap<>()), new TestHashMap(1, new HashMap<>()))); |
| 1421 | + assertFalse(EqualsBuilder.reflectionEquals(new TestHashMap(1, new HashMap<>()), new TestHashMap(2, new HashMap<>()))); |
| 1422 | + } |
| 1423 | + |
1384 | 1424 | @Test |
1385 | 1425 | void testReset() { |
1386 | 1426 | final EqualsBuilder equalsBuilder = new EqualsBuilder(); |
|
0 commit comments