From 3e5a2f4951876aae6262b43a731aea3ad832486d Mon Sep 17 00:00:00 2001 From: Justin Bertram Date: Thu, 15 Nov 2018 13:03:40 -0600 Subject: [PATCH] NO-JIRA improve logging for test System prop cleanup --- .../utils/CleanupSystemPropertiesRule.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/CleanupSystemPropertiesRule.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/CleanupSystemPropertiesRule.java index ced11d247d..3dfddd1ce7 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/CleanupSystemPropertiesRule.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/CleanupSystemPropertiesRule.java @@ -68,14 +68,24 @@ public class CleanupSystemPropertiesRule extends ExternalResource { System.out.println("======================================================================================================"); - for (Object key : newProperties) { - System.out.println("Cleaning up system property " + key); - System.clearProperty(key.toString()); + if (!newProperties.isEmpty()) { + System.out.println("Clearing system property..."); + + int i = 1; + for (Object key : newProperties) { + System.out.printf("\t%3d. %s = %s%n", i++, key, System.getProperty(key.toString())); + System.clearProperty(key.toString()); + } } - for (Map.Entry entry : changed.entrySet()) { - System.out.println("Setting up old system property, key=" + entry.getKey() + ", value = " + entry.getValue()); - System.setProperty(entry.getKey().toString(), entry.getValue().toString()); + if (!changed.isEmpty()) { + System.out.println("Resetting system property..."); + + int i = 1; + for (Map.Entry entry : changed.entrySet()) { + System.out.printf("\t%3d. %s = %s (was %s)%n", i++, entry.getKey(), entry.getValue(), System.getProperty(entry.getKey().toString())); + System.setProperty(entry.getKey().toString(), entry.getValue().toString()); + } } System.out.println("======================================================================================================");