From fdc6e02b498e8b685ce5d50a6198f58d959ac1c2 Mon Sep 17 00:00:00 2001 From: dotasek Date: Wed, 26 Jan 2022 09:31:58 -0500 Subject: [PATCH] Don't log requests when rebuilding cache --- .../tests/CacheVerificationLogger.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/utilities/tests/CacheVerificationLogger.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/utilities/tests/CacheVerificationLogger.java index f467b11fa..ef8d0287c 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/utilities/tests/CacheVerificationLogger.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/utilities/tests/CacheVerificationLogger.java @@ -10,20 +10,24 @@ public class CacheVerificationLogger implements ToolingClientLogger { public static final String FHIR_TXCACHE_REBUILD = "fhir.txcache.rebuild"; + public static final String isRebuildingCache = System.getProperty(FHIR_TXCACHE_REBUILD); + @Getter int requests = 0; @Override public void logRequest(String method, String url, List headers, byte[] body) { - System.err.println("Unexpected request to server"); - System.err.println(method); - System.err.println(url); - for (String header : headers) { - System.err.println("Header: " + header); + if (!isRebuildingCache()) { + System.err.println("Unexpected request to server"); + System.err.println(method); + System.err.println(url); + for (String header : headers) { + System.err.println("Header: " + header); + } + System.err.println("Body"); + System.err.println("----"); + System.err.println(new String(body, StandardCharsets.UTF_8)); } - System.err.println("Body"); - System.err.println("----"); - System.err.println(new String(body, StandardCharsets.UTF_8)); requests++; } @@ -42,10 +46,13 @@ public class CacheVerificationLogger implements ToolingClientLogger { } - public boolean verifyHasNoRequests() { - String isRebuildingCache = System.getProperty(FHIR_TXCACHE_REBUILD); + private boolean isRebuildingCache() { + return isRebuildingCache != null && "TRUE".equals(isRebuildingCache.toUpperCase()); + } - if (isRebuildingCache != null && "TRUE".equals(isRebuildingCache.toUpperCase())) { + public boolean verifyHasNoRequests() { + + if (isRebuildingCache()) { return true; } else { if (requests != 0) {