mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-14 20:42:21 +00:00
Fix tests on newer java versions (#5182)
This commit is contained in:
1 parent
d8c499bb85
commit
ab5d044dcc
2 files changed
+20
-11
No files matched your search
@@ -43,6 +43,9 @@ import java.util.regex.Pattern;
|
||||
|
||||
import hudson.util.VersionNumber;
|
||||
import jenkins.model.Jenkins;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -517,7 +520,8 @@ public class FunctionsTest {
|
||||
stack1.cause(stack2);
|
||||
stack2.cause(stack1);
|
||||
//Format changed in 11.0.9 / 8.0.272 (JDK-8226809 / JDK-8252444 / JDK-8252489)
|
||||
if ((getVersion().getDigitAt(0) == 11 && getVersion().isNewerThanOrEqualTo(new VersionNumber("11.0.9"))) ||
|
||||
|
||||
if ((getVersion().isNewerThanOrEqualTo(new VersionNumber("11.0.9"))) ||
|
||||
(getVersion().getDigitAt(0) == 8 && getVersion().isNewerThanOrEqualTo(new VersionNumber("8.0.272")))) {
|
||||
assertPrintThrowable(stack1,
|
||||
"p.Exc1\n" +
|
||||
@@ -554,10 +558,10 @@ public class FunctionsTest {
|
||||
private static void assertPrintThrowable(Throwable t, String traditional, String custom) {
|
||||
StringWriter sw = new StringWriter();
|
||||
t.printStackTrace(new PrintWriter(sw));
|
||||
assertEquals(sw.toString().replace(System.lineSeparator(), "\n"), traditional);
|
||||
assertThat(sw.toString().replace(System.lineSeparator(), "\n"), is(traditional));
|
||||
String actual = Functions.printThrowable(t);
|
||||
System.out.println(actual);
|
||||
assertEquals(actual.replace(System.lineSeparator(), "\n"), custom);
|
||||
assertThat(actual.replace(System.lineSeparator(), "\n"), is(custom));
|
||||
}
|
||||
private static final class Stack extends Throwable {
|
||||
private static final Pattern LINE = Pattern.compile("(.+)[.](.+)[.](.+):(\\d+)");
|
||||
|
||||
Reference in new issue
Block a user