Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-71810] Token Macro tests fail on Java 21 #191

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import java.util.Map;
import java.util.TimeZone;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.matchesPattern;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -74,8 +74,8 @@ public void testShouldPrintDate()

String content = changesSinceLastBuildMacro.evaluate(currentBuild, listener, ChangesSinceLastBuildMacro.MACRO_NAME);

// Java 9 changed the SHORT date format... https://www.oracle.com/technetwork/java/javase/9-relnote-issues-3704069.html#JDK-8008577
assertTrue(content.matches("Oct 21, 2013,? 7:39:00 PM"));
// Java 21 changed the SHORT date format... https://bugs.openjdk.org/browse/JDK-8225245
assertThat(content, matchesPattern("Oct 21, 2013, 7:39:00\\hPM"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import static junit.framework.Assert.assertEquals;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.matchesPattern;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -148,10 +150,10 @@ public void testShouldPrintDate()

String contentStr = content.evaluate(currentBuild, listener, ChangesSinceLastSuccessfulBuildMacro.MACRO_NAME);

// Date format changed in Java 9, so we have to accomodate the potential additional comma
// See https://www.oracle.com/technetwork/java/javase/9-relnote-issues-3704069.html#JDK-8008577
Assert.assertTrue(contentStr.matches(
"Changes for Build #41\n" + "Oct 21, 2013,? 7:39:00 PM\n" + "Changes for Build #42\n" + "Oct 21, 2013,? 7:39:00 PM\n"));
// Date format changed in Java 21, so we have to accomodate the potential narrow no-break space
// See https://bugs.openjdk.org/browse/JDK-8225245
assertThat(contentStr, matchesPattern(
"Changes for Build #41\n" + "Oct 21, 2013, 7:39:00\\hPM\n" + "Changes for Build #42\n" + "Oct 21, 2013, 7:39:00\\hPM\n"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import java.util.Map;
import java.util.TimeZone;

import static junit.framework.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.matchesPattern;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -151,10 +153,10 @@ public void testShouldPrintDate()

String contentStr = content.evaluate(currentBuild, listener, ChangesSinceLastUnstableBuildMacro.MACRO_NAME);

// Date format changed in Java 9, so we have to accomodate the potential additional comma
// See https://www.oracle.com/technetwork/java/javase/9-relnote-issues-3704069.html#JDK-8008577
Assert.assertTrue(contentStr.matches(
"Changes for Build #41\n" + "Oct 21, 2013,? 7:39:00 PM\n" + "Changes for Build #42\n" + "Oct 21, 2013,? 7:39:00 PM\n"));
// Date format changed in Java 21, so we have to accomodate the potential narrow no-break space
// See https://bugs.openjdk.org/browse/JDK-8225245
assertThat(contentStr, matchesPattern(
"Changes for Build #41\n" + "Oct 21, 2013, 7:39:00\\hPM\n" + "Changes for Build #42\n" + "Oct 21, 2013, 7:39:00\\hPM\n"));
}

@Test
Expand Down