Skip to content

Commit

Permalink
Fix failing tests on JDK 21
Browse files Browse the repository at this point in the history
The problem is explained at https://bugs.openjdk.org/browse/JDK-8304925

Update Byte-Buddy to fix failing tests due to Mockito not able to create
mocks

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
  • Loading branch information
martin-g committed Sep 11, 2023
1 parent 5b82817 commit 2d19d34
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<aspectj.version>1.9.19</aspectj.version>
<assertj-core.version>3.24.2</assertj-core.version>
<bouncycastle.version>1.74</bouncycastle.version>
<byte-buddy.version>1.14.2</byte-buddy.version>
<byte-buddy.version>1.14.7</byte-buddy.version>
<cdi-unit.version>4.1.0</cdi-unit.version>
<commons-collections4.version>4.4</commons-collections4.version>
<commons-fileupload.version>2.0.0-M1</commons-fileupload.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import org.apache.wicket.util.convert.ConversionException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnJre;
import org.junit.jupiter.api.condition.JRE;

import java.time.LocalDateTime;
import java.util.Locale;
Expand All @@ -30,18 +32,36 @@
public class LocalDateTimeConverterTest
{
@Test
public void convertToString() {
@EnabledOnJre({JRE.JAVA_17, JRE.JAVA_18, JRE.JAVA_19})
public void convertToString_upto_jdk19() {
LocalDateTimeConverter converter = new LocalDateTimeConverter();
String date = converter.convertToString(LocalDateTime.of(2016, 7, 11, 1, 2, 3), Locale.ENGLISH);
assertEquals("Jul 11, 2016, 1:02:03 AM", date);
}

@Test
public void convertToObject() {
@EnabledOnJre({JRE.JAVA_20, JRE.JAVA_21}) // See https://bugs.openjdk.org/browse/JDK-8304925
public void convertToString_jdk20_and_newer() {
LocalDateTimeConverter converter = new LocalDateTimeConverter();
String date = converter.convertToString(LocalDateTime.of(2016, 7, 11, 1, 2, 3), Locale.ENGLISH);
assertEquals("Jul 11, 2016, 1:02:03 AM", date);
}

@Test
@EnabledOnJre({JRE.JAVA_17, JRE.JAVA_18, JRE.JAVA_19})
public void convertToObject_upto_jdk19() {
LocalDateTimeConverter converter = new LocalDateTimeConverter();
LocalDateTime date = converter.convertToObject("Jul 11, 2016, 1:02:03 AM", Locale.ENGLISH);
assertEquals(date, LocalDateTime.of(2016, 7, 11, 1, 2, 3));
}

@Test
@EnabledOnJre({JRE.JAVA_20, JRE.JAVA_21}) // See https://bugs.openjdk.org/browse/JDK-8304925
public void convertToObject_jdk20_and_newer() {
LocalDateTimeConverter converter = new LocalDateTimeConverter();
LocalDateTime date = converter.convertToObject("Jul 11, 2016, 1:02:03 AM", Locale.ENGLISH);
assertEquals(date, LocalDateTime.of(2016, 7, 11, 1, 2, 3));
}

@Test
public void convertFails() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,37 @@ public class ZonedDateTimeConverterTest
private final ZoneId zoneUTC = ZoneId.of("Etc/UTC");

@Test
public void convertToString() {
@EnabledOnJre({JRE.JAVA_17, JRE.JAVA_18, JRE.JAVA_19})
public void convertToString_upto_jdk19() {
ZonedDateTimeConverter converter = new ZonedDateTimeConverter();
String date = converter.convertToString(ZonedDateTime.of(2016, 7, 11, 1, 2, 3, 0, zoneUCT), Locale.ENGLISH);
assertEquals("Jul 11, 2016, 1:02:03 AM Coordinated Universal Time", date);
}

@Test
public void convertToObject() {
@EnabledOnJre({JRE.JAVA_20, JRE.JAVA_21}) // See https://bugs.openjdk.org/browse/JDK-8304925
public void convertToString_jdk20_and_newer() {
ZonedDateTimeConverter converter = new ZonedDateTimeConverter();
String date = converter.convertToString(ZonedDateTime.of(2016, 7, 11, 1, 2, 3, 0, zoneUCT), Locale.ENGLISH);
assertEquals("Jul 11, 2016, 1:02:03 AM Coordinated Universal Time", date);
}

@Test
@EnabledOnJre({JRE.JAVA_17, JRE.JAVA_18, JRE.JAVA_19})
public void convertToObject_upto_jdk19() {
ZonedDateTimeConverter converter = new ZonedDateTimeConverter();
ZonedDateTime date = converter.convertToObject("Jul 11, 2016, 1:02:03 AM Coordinated Universal Time", Locale.ENGLISH);
assertEquals(ZonedDateTime.of(2016, 7, 11, 1, 2, 3, 0, zoneUTC), date);
}

@Test
@EnabledOnJre({JRE.JAVA_20, JRE.JAVA_21}) // See https://bugs.openjdk.org/browse/JDK-8304925
public void convertToObject_jdk20_and_newer() {
ZonedDateTimeConverter converter = new ZonedDateTimeConverter();
ZonedDateTime date = converter.convertToObject("Jul 11, 2016, 1:02:03 AM Coordinated Universal Time", Locale.ENGLISH);
assertEquals(ZonedDateTime.of(2016, 7, 11, 1, 2, 3, 0, zoneUTC), date);
}

@Test
public void convertFails() {
ZonedDateTimeConverter converter = new ZonedDateTimeConverter();
Expand Down

0 comments on commit 2d19d34

Please sign in to comment.