From cc18aa19490a549d9ed067914c03e8781a08c06c Mon Sep 17 00:00:00 2001 From: John Blum Date: Mon, 17 Oct 2022 12:43:11 -0700 Subject: [PATCH] Refactor IntegrationTestsSupportUnitTests.asDirectoryNameIsCorrect() test case method to be more resilient to temporal-based test failures. Previously, the test case method could fail based on a race condition involving a timestamp in the (test) working directory name. --- .../IntegrationTestsSupportUnitTests.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/spring-data-geode-test/src/test/java/org/springframework/data/gemfire/tests/integration/IntegrationTestsSupportUnitTests.java b/spring-data-geode-test/src/test/java/org/springframework/data/gemfire/tests/integration/IntegrationTestsSupportUnitTests.java index 51eee4d..68e47e4 100644 --- a/spring-data-geode-test/src/test/java/org/springframework/data/gemfire/tests/integration/IntegrationTestsSupportUnitTests.java +++ b/spring-data-geode-test/src/test/java/org/springframework/data/gemfire/tests/integration/IntegrationTestsSupportUnitTests.java @@ -17,9 +17,6 @@ package org.springframework.data.gemfire.tests.integration; import static org.assertj.core.api.Assertions.assertThat; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; - import org.junit.Test; /** @@ -35,15 +32,16 @@ public class IntegrationTestsSupportUnitTests { @Test public void asDirectoryNameIsCorrect() { - LocalDateTime now = LocalDateTime.now(); - String directoryName = IntegrationTestsSupport.asDirectoryName(OuterType.InnerType.class); - assertThat(directoryName).isNotBlank(); - assertThat(directoryName).matches(String.format("%s\\.%s\\.%s-%s-", - IntegrationTestsSupportUnitTests.class.getSimpleName(), OuterType.class.getSimpleName(), OuterType.InnerType.class.getSimpleName(), - DateTimeFormatter.ofPattern(IntegrationTestsSupport.DATE_TIME_PATTERN).format(now)).concat("[\\w-]+")); + Object[] args = { + IntegrationTestsSupportUnitTests.class.getSimpleName(), + OuterType.class.getSimpleName(), + OuterType.InnerType.class.getSimpleName() + }; + assertThat(directoryName).isNotBlank(); + assertThat(directoryName).matches(String.format("%s\\.%s\\.%s", args).concat("[\\w-]+")); } interface OuterType {