Skip to content

Commit

Permalink
OutputAnalyzer to ignore additional deprecation messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinjwalls committed Sep 5, 2024
1 parent 7aa89ae commit 4a5357d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021 NTT DATA.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -75,10 +75,7 @@ public static void main(String[] args) throws Exception {
System.out.println(out.getStdout());
System.err.println(out.getStderr());

out.shouldMatch("WARNING: --connect is deprecated");
// --connect is deprecated. When removed, can revert to:
// out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();

out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
out.shouldMatch("^java/lang/Object @0x[0-9a-f]+$"); // for "class java.lang.Object"
out.shouldHaveExitValue(0);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -70,47 +70,31 @@ private static void runJSTACK(String serverID) throws IOException, InterruptedEx
OutputAnalyzer out = runJHSDB("jstack", serverID);

out.shouldContain("LingeredApp");

out.shouldMatch("WARNING: --connect is deprecated");
// --connect is deprecated. When removed, can revert to:
// out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();

out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
out.shouldHaveExitValue(0);
}

private static void runJMAP(String serverID) throws IOException, InterruptedException {
OutputAnalyzer out = runJHSDB("jmap", serverID);

out.shouldContain("JVM version is");

out.shouldMatch("WARNING: --connect is deprecated");
// --connect is deprecated. When removed, can revert to:
// out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();

out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
out.shouldHaveExitValue(0);
}

private static void runJINFO(String serverID) throws IOException, InterruptedException {
OutputAnalyzer out = runJHSDB("jinfo", serverID);

out.shouldContain("Java System Properties:");

out.shouldMatch("WARNING: --connect is deprecated");
// --connect is deprecated. When removed, can revert to:
// out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();

out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
out.shouldHaveExitValue(0);
}

private static void runJSNAP(String serverID) throws IOException, InterruptedException {
OutputAnalyzer out = runJHSDB("jsnap", serverID);

out.shouldContain("java.vm.name=");

out.shouldMatch("WARNING: --connect is deprecated");
// --connect is deprecated. When removed, can revert to:
// out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();

out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
out.shouldHaveExitValue(0);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021 NTT DATA.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -69,10 +69,7 @@ private static void test(String serverName) throws IOException, InterruptedExcep
System.out.println(out.getStdout());
System.err.println(out.getStderr());

out.shouldMatch("WARNING: --connect is deprecated");
// --connect is deprecated. When removed, can revert to:
// out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();

out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
out.shouldContain("Attaching to remote server localhost:10000");
out.shouldContain("java.vm.version");
out.shouldHaveExitValue(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021 NTT DATA.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -64,10 +64,7 @@ public static void main(String[] args) throws Exception {
System.out.println(out.getStdout());
System.err.println(out.getStderr());

out.shouldMatch("WARNING: --connect is deprecated");
// --connect is deprecated. When removed, can revert to:
// out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();

out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
out.shouldMatch("^0x[0-9a-f]+.+libjvm\\.so$"); // Find libjvm from output
out.shouldHaveExitValue(0);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021 NTT DATA.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -74,10 +74,7 @@ public static void main(String[] args) throws Exception {
System.out.println(out.getStdout());
System.err.println(out.getStderr());

out.shouldMatch("WARNING: --connect is deprecated");
// --connect is deprecated. When removed, can revert to:
// out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();

out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
out.shouldMatch("^0x[0-9a-f]+: .+/libjvm\\.(so|dylib) \\+ 0x[0-9a-f]+$");
out.shouldHaveExitValue(0);

Expand Down
9 changes: 6 additions & 3 deletions test/lib/jdk/test/lib/process/OutputAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public final class OutputAnalyzer {

private static final String jvmwarningmsg = ".* VM warning:.*";

private static final String deprecatedmsg = ".* VM warning:.* deprecated.*";
private static final String VM_DEPRECATED_MSG = ".* VM warning:.* deprecated.*";
private static final String OTHER_DEPRECATED_MSG = "^WARNING: .* is deprecated.*";

private static final String FATAL_ERROR_PAT = "# A fatal error has been detected.*";

Expand Down Expand Up @@ -182,7 +183,8 @@ public OutputAnalyzer stderrShouldBeEmptyIgnoreWarnings() {
* If stderr was not empty
*/
public OutputAnalyzer stderrShouldBeEmptyIgnoreDeprecatedWarnings() {
if (!getStderr().replaceAll(deprecatedmsg + "\\R", "").isEmpty()) {
if (!getStderr().replaceAll(VM_DEPRECATED_MSG + "\\R", "").isEmpty() &&
!getStderr().replaceAll(OTHER_DEPRECATED_MSG + "\\R", "").isEmpty()) {
reportDiagnosticSummary();
throw new RuntimeException("stderr was not empty");
}
Expand Down Expand Up @@ -689,7 +691,8 @@ public OutputAnalyzer stderrShouldMatchIgnoreVMWarnings(String pattern) {
* @throws RuntimeException If the pattern was not found
*/
public OutputAnalyzer stderrShouldMatchIgnoreDeprecatedWarnings(String pattern) {
String stderr = getStderr().replaceAll(deprecatedmsg + "\\R", "");
String stderr = getStderr().replaceAll(VM_DEPRECATED_MSG + "\\R", "");
stderr = getStderr().replaceAll(OTHER_DEPRECATED_MSG + "\\R", "");
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
if (!matcher.find()) {
reportDiagnosticSummary();
Expand Down

0 comments on commit 4a5357d

Please sign in to comment.