From 77c5adb09e89e013c4bc4982f541110bf76e83a7 Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Fri, 26 May 2023 16:00:12 +0000 Subject: [PATCH] 8308935: jdk.management.jfr.RecordingInfo.toString() lacks test coverage Reviewed-by: mgronlun --- test/jdk/jdk/jfr/jmx/info/TestRecordingInfo.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/jdk/jdk/jfr/jmx/info/TestRecordingInfo.java b/test/jdk/jdk/jfr/jmx/info/TestRecordingInfo.java index 66ac05912e535..a653af76dc0c7 100644 --- a/test/jdk/jdk/jfr/jmx/info/TestRecordingInfo.java +++ b/test/jdk/jdk/jfr/jmx/info/TestRecordingInfo.java @@ -35,6 +35,7 @@ import jdk.management.jfr.FlightRecorderMXBean; import jdk.management.jfr.RecordingInfo; import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.Asserts; /** * @test @@ -62,6 +63,16 @@ public static void main(String[] args) throws Throwable { FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); RecordingInfo info = JmxHelper.verifyExists(recording.getId(), bean.getRecordings()); + String text = info.toString(); + assertContains(text, "name"); + assertContains(text, String.valueOf(info.getName())); + assertContains(text, "id"); + assertContains(text, String.valueOf(info.getId())); + assertContains(text, "maxAge"); + assertContains(text, String.valueOf(info.getMaxAge())); + assertContains(text, "maxSize"); + assertContains(text, String.valueOf(info.getMaxSize())); + System.out.println(JmxHelper.asString(recording)); System.out.println(JmxHelper.asString(info)); JmxHelper.verifyEquals(info, recording); @@ -70,4 +81,9 @@ public static void main(String[] args) throws Throwable { recording.close(); } + private static void assertContains(String text, String match) { + if (!text.contains(match)) { + Asserts.fail("Expected '" + text + "' to contain '" + match + '"'); + } + } }