From 6f8c223b2ee3d9363d23432b5c7be57d1b227817 Mon Sep 17 00:00:00 2001 From: pz2 Date: Wed, 21 Feb 2024 14:25:20 +0100 Subject: [PATCH] fix test for alpine java --- .../hofund/java/HofundJavaInfoE2ETest.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hofund-spring-boot-e2e/src/test/java/dev/logchange/hofund/java/HofundJavaInfoE2ETest.java b/hofund-spring-boot-e2e/src/test/java/dev/logchange/hofund/java/HofundJavaInfoE2ETest.java index d9fa190..650d01a 100644 --- a/hofund-spring-boot-e2e/src/test/java/dev/logchange/hofund/java/HofundJavaInfoE2ETest.java +++ b/hofund-spring-boot-e2e/src/test/java/dev/logchange/hofund/java/HofundJavaInfoE2ETest.java @@ -9,6 +9,8 @@ import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.server.LocalServerPort; +import static dev.logchange.hofund.StringUtils.emptyIfNull; + @Slf4j @AutoConfigureObservability @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -24,17 +26,17 @@ void shouldContainsHofundJavaInfo() { //given: String path = "http://localhost:" + port + "/actuator/prometheus"; - String jvmName = System.getProperty("java.vm.name"); - String jvmVendor = System.getProperty("java.vm.vendor"); - String jvmVersion = System.getProperty("java.vm.version"); + String jvmName = emptyIfNull(System.getProperty("java.vm.name")); + String jvmVendor = emptyIfNull(System.getProperty("java.vm.vendor")); + String jvmVersion = emptyIfNull(System.getProperty("java.vm.version")); - String runtimeName = System.getProperty("java.runtime.name"); - String runtimeVersion = System.getProperty("java.runtime.version"); + String runtimeName = emptyIfNull(System.getProperty("java.runtime.name")); + String runtimeVersion = emptyIfNull(System.getProperty("java.runtime.version")); - String vendor = System.getProperty("java.vendor"); - String vendorVersion = System.getProperty("java.vendor.version"); + String vendor = emptyIfNull(System.getProperty("java.vendor")); + String vendorVersion = emptyIfNull(System.getProperty("java.vendor.version")); - String javaVersion = System.getProperty("java.version"); + String javaVersion = emptyIfNull(System.getProperty("java.version")); String expected = "# HELP hofund_java_info Basic information about java that is running this application\n" +