diff --git a/pom.xml b/pom.xml index 234c4682c69a..3bf1d0573009 100644 --- a/pom.xml +++ b/pom.xml @@ -591,7 +591,7 @@ java12 - [12,) + [12,20) @@ -631,5 +631,45 @@ + + java20 + + [20,) + + + + 1.8 + + + + + maven-javadoc-plugin + + 1.8 + false + + + + maven-compiler-plugin + + + -Xdoclint:none + + + + + + + + + maven-javadoc-plugin + + 1.8 + false + + + + + diff --git a/src/test/java/junit/samples/SimpleTest.java b/src/test/java/junit/samples/SimpleTest.java index 5177f48a256e..42a7f25b38cc 100644 --- a/src/test/java/junit/samples/SimpleTest.java +++ b/src/test/java/junit/samples/SimpleTest.java @@ -60,7 +60,7 @@ public void testDivideByZero() { public void testEquals() { assertEquals(12, 12); assertEquals(12L, 12L); - assertEquals(new Long(12), new Long(12)); + assertEquals(Long.valueOf(12), Long.valueOf(12)); assertEquals("Size", 12, 13); assertEquals("Capacity", 12.0, 11.99, 0.0); diff --git a/src/test/java/junit/tests/framework/AssertTest.java b/src/test/java/junit/tests/framework/AssertTest.java index d971a1ef8426..82e0f5093af5 100644 --- a/src/test/java/junit/tests/framework/AssertTest.java +++ b/src/test/java/junit/tests/framework/AssertTest.java @@ -140,7 +140,7 @@ public void testAssertSame() { Object o = new Object(); assertSame(o, o); try { - assertSame(new Integer(1), new Integer(1)); + assertSame(new MyInt(1), new MyInt(1)); } catch (AssertionFailedError e) { return; } @@ -148,11 +148,11 @@ public void testAssertSame() { } public void testAssertNotSame() { - assertNotSame(new Integer(1), null); - assertNotSame(null, new Integer(1)); - assertNotSame(new Integer(1), new Integer(1)); + assertNotSame(new MyInt(1), null); + assertNotSame(null, new MyInt(1)); + assertNotSame(new MyInt(1), new MyInt(1)); try { - Integer obj = new Integer(1); + MyInt obj = new MyInt(1); assertNotSame(obj, obj); } catch (AssertionFailedError e) { return; @@ -168,4 +168,27 @@ public void testAssertNotSameFailsNull() { } fail(); } + + private static final class MyInt { + private final int value; + + MyInt(int value) { + this.value = value; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof MyInt && value == ((MyInt) obj).value; + } + + @Override + public int hashCode() { + return value; + } + + @Override + public String toString() { + return Integer.toString(value); + } + } } diff --git a/src/test/java/org/junit/runners/parameterized/TestWithParametersTest.java b/src/test/java/org/junit/runners/parameterized/TestWithParametersTest.java index b8156e9fbd7b..511e835ec0a6 100644 --- a/src/test/java/org/junit/runners/parameterized/TestWithParametersTest.java +++ b/src/test/java/org/junit/runners/parameterized/TestWithParametersTest.java @@ -106,7 +106,7 @@ public void isNotEqualToTestWithDifferentParameters() { public void isNotEqualToObjectWithDifferentClass() { TestWithParameters test = new TestWithParameters(DUMMY_NAME, DUMMY_TEST_CLASS, DUMMY_PARAMETERS); - assertNotEquals(test, new Integer(3)); + assertNotEquals(test, Integer.valueOf(3)); } @Test diff --git a/src/test/java/org/junit/samples/ListTest.java b/src/test/java/org/junit/samples/ListTest.java index 02ade826a888..fec96a4975f8 100644 --- a/src/test/java/org/junit/samples/ListTest.java +++ b/src/test/java/org/junit/samples/ListTest.java @@ -85,7 +85,7 @@ public void removeAll() { @Test public void removeElement() { - fFull.remove(new Integer(3)); + fFull.remove(Integer.valueOf(3)); assertTrue(!fFull.contains(3)); } } \ No newline at end of file diff --git a/src/test/java/org/junit/samples/SimpleTest.java b/src/test/java/org/junit/samples/SimpleTest.java index 02bae09e5f9b..947e9f8a679e 100644 --- a/src/test/java/org/junit/samples/SimpleTest.java +++ b/src/test/java/org/junit/samples/SimpleTest.java @@ -38,7 +38,7 @@ public void divideByZero() { public void testEquals() { assertEquals(12, 12); assertEquals(12L, 12L); - assertEquals(new Long(12), new Long(12)); + assertEquals(Long.valueOf(12), Long.valueOf(12)); assertEquals("Size", 12, 13); assertEquals("Capacity", 12.0, 11.99, 0.0); diff --git a/src/test/java/org/junit/tests/assertion/AssertionTest.java b/src/test/java/org/junit/tests/assertion/AssertionTest.java index 22907e07c56f..ccc4ec4b2a1f 100644 --- a/src/test/java/org/junit/tests/assertion/AssertionTest.java +++ b/src/test/java/org/junit/tests/assertion/AssertionTest.java @@ -217,7 +217,7 @@ public void oneDimensionalBooleanArraysAreNotEqual() { @Test(expected = AssertionError.class) public void IntegerDoesNotEqualLong() { - assertEquals(new Integer(1), new Long(1)); + assertEquals(Integer.valueOf(1), Long.valueOf(1)); } @Test @@ -678,7 +678,7 @@ public void implicitTypecastEquality() { @Test public void errorMessageDistinguishesDifferentValuesWithSameToString() { try { - assertEquals("4", new Integer(4)); + assertEquals("4", Integer.valueOf(4)); } catch (AssertionError e) { assertEquals("expected: java.lang.String<4> but was: java.lang.Integer<4>", e.getMessage()); return; @@ -788,8 +788,8 @@ public void objectsWithDifferentReferencesAreNotEqual() { @Test public void assertNotEqualsIncludesCorrectMessage() { - Integer value1 = new Integer(1); - Integer value2 = new Integer(1); + Integer value1 = 1; + Integer value2 = 1; String message = "The values should be different"; try { @@ -804,8 +804,8 @@ public void assertNotEqualsIncludesCorrectMessage() { @Test public void assertNotEqualsIncludesTheValueBeingTested() { - Integer value1 = new Integer(1); - Integer value2 = new Integer(1); + Integer value1 = 1; + Integer value2 = 1; try { assertNotEquals(value1, value2); diff --git a/src/test/java/org/junit/tests/description/SuiteDescriptionTest.java b/src/test/java/org/junit/tests/description/SuiteDescriptionTest.java index 5b17d1e91b35..8fda46dea11d 100644 --- a/src/test/java/org/junit/tests/description/SuiteDescriptionTest.java +++ b/src/test/java/org/junit/tests/description/SuiteDescriptionTest.java @@ -20,7 +20,7 @@ public void equalsIsCorrect() { assertFalse(childless.equals(namedB)); assertEquals(childless, twoKids); assertEquals(twoKids, anotherTwoKids); - assertFalse(twoKids.equals(new Integer(5))); + assertFalse(twoKids.equals(Integer.valueOf(5))); } @Test diff --git a/src/test/java/org/junit/tests/description/TestDescriptionTest.java b/src/test/java/org/junit/tests/description/TestDescriptionTest.java index 3bc07f403a74..2b84473524ec 100644 --- a/src/test/java/org/junit/tests/description/TestDescriptionTest.java +++ b/src/test/java/org/junit/tests/description/TestDescriptionTest.java @@ -9,7 +9,7 @@ public class TestDescriptionTest { @Test public void equalsIsFalseForNonTestDescription() { - assertFalse(Description.createTestDescription(getClass(), "a").equals(new Integer(5))); + assertFalse(Description.createTestDescription(getClass(), "a").equals(Integer.valueOf(5))); } @Test diff --git a/src/test/java/org/junit/tests/experimental/theories/internal/AllMembersSupplierTest.java b/src/test/java/org/junit/tests/experimental/theories/internal/AllMembersSupplierTest.java index 64e77b1e668a..87c9e2963989 100644 --- a/src/test/java/org/junit/tests/experimental/theories/internal/AllMembersSupplierTest.java +++ b/src/test/java/org/junit/tests/experimental/theories/internal/AllMembersSupplierTest.java @@ -206,4 +206,4 @@ public void dataPointsCollectionShouldBeRecognizedIgnoringStrangeTypes() throws assertEquals(1, assignments.size()); } -} \ No newline at end of file +}