Skip to content

Commit

Permalink
Merge branch 'main' into marc/jdk-21
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp authored May 6, 2024
2 parents c923492 + be2f711 commit f991e5d
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 19 deletions.
42 changes: 41 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@
<profile>
<id>java12</id>
<activation>
<jdk>[12,)</jdk>
<jdk>[12,20)</jdk>
</activation>
<properties>
<!-- JDK 12 minimal source and target versions are 1.7 -->
Expand Down Expand Up @@ -631,5 +631,45 @@
</plugins>
</reporting>
</profile>
<profile>
<id>java20</id>
<activation>
<jdk>[20,)</jdk>
</activation>
<properties>
<!-- JDK 20 minimal source and target versions are 1.8 -->
<jdkVersion>1.8</jdkVersion>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<source>1.8</source>
<failOnError>false</failOnError>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-Xdoclint:none</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<source>1.8</source>
<failOnError>false</failOnError>
</configuration>
</plugin>
</plugins>
</reporting>
</profile>
</profiles>
</project>
2 changes: 1 addition & 1 deletion src/test/java/junit/samples/SimpleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 28 additions & 5 deletions src/test/java/junit/tests/framework/AssertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,19 @@ 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;
}
fail();
}

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;
Expand All @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/junit/samples/ListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
2 changes: 1 addition & 1 deletion src/test/java/org/junit/samples/SimpleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/org/junit/tests/assertion/AssertionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,4 @@ public void dataPointsCollectionShouldBeRecognizedIgnoringStrangeTypes() throws

assertEquals(1, assignments.size());
}
}
}

0 comments on commit f991e5d

Please sign in to comment.