Skip to content

Commit 171e71a

Browse files
committed
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.
1 parent 1522d56 commit 171e71a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

spring-data-geode-test/src/test/java/org/springframework/data/gemfire/tests/integration/IntegrationTestsSupportUnitTests.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
1919

20-
import java.time.LocalDateTime;
21-
import java.time.format.DateTimeFormatter;
22-
2320
import org.junit.Test;
2421

2522
/**
@@ -35,15 +32,16 @@ public class IntegrationTestsSupportUnitTests {
3532
@Test
3633
public void asDirectoryNameIsCorrect() {
3734

38-
LocalDateTime now = LocalDateTime.now();
39-
4035
String directoryName = IntegrationTestsSupport.asDirectoryName(OuterType.InnerType.class);
4136

42-
assertThat(directoryName).isNotBlank();
43-
assertThat(directoryName).matches(String.format("%s\\.%s\\.%s-%s-",
44-
IntegrationTestsSupportUnitTests.class.getSimpleName(), OuterType.class.getSimpleName(), OuterType.InnerType.class.getSimpleName(),
45-
DateTimeFormatter.ofPattern(IntegrationTestsSupport.DATE_TIME_PATTERN).format(now)).concat("[\\w-]+"));
37+
Object[] args = {
38+
IntegrationTestsSupportUnitTests.class.getSimpleName(),
39+
OuterType.class.getSimpleName(),
40+
OuterType.InnerType.class.getSimpleName()
41+
};
4642

43+
assertThat(directoryName).isNotBlank();
44+
assertThat(directoryName).matches(String.format("%s\\.%s\\.%s", args).concat("[\\w-]+"));
4745
}
4846

4947
interface OuterType {

0 commit comments

Comments
 (0)