Refactor IntegrationTestsSupport.asDirectoryName(:Class) logic into descriptive methods.
Adds the asTimestampedDirectoryName(:Class) and asUniqueDirectoryName(:Class) methods to uniquely and temporally identify a forked JVM (child) process (test) working directory.
This commit is contained in:
@@ -40,6 +40,8 @@ import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.sun.istack.NotNull;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
|
||||
@@ -512,11 +514,7 @@ public abstract class IntegrationTestsSupport {
|
||||
}
|
||||
|
||||
protected static @NonNull String asDirectoryName(@NonNull Class<?> type) {
|
||||
|
||||
String baseDirectoryName = String.format(DIRECTORY_NAME_FORMAT, asQualifiedDirectoryName(type),
|
||||
LocalDateTime.now().format(DateTimeFormatter.ofPattern(DATE_TIME_PATTERN)));
|
||||
|
||||
return baseDirectoryName.concat(File.separator).concat(UUID.randomUUID().toString());
|
||||
return asUniqueDirectoryName(type);
|
||||
}
|
||||
|
||||
private static @NonNull String asQualifiedDirectoryName(@NonNull Class<?> type) {
|
||||
@@ -533,6 +531,15 @@ public abstract class IntegrationTestsSupport {
|
||||
return qualifiedDirectoryName;
|
||||
}
|
||||
|
||||
private static @NotNull String asTimestampedDirectoryName(@NonNull Class<?> type) {
|
||||
return String.format(DIRECTORY_NAME_FORMAT, asQualifiedDirectoryName(type),
|
||||
LocalDateTime.now().format(DateTimeFormatter.ofPattern(DATE_TIME_PATTERN)));
|
||||
}
|
||||
|
||||
private static @NotNull String asUniqueDirectoryName(@NonNull Class<?> type) {
|
||||
return String.format(DIRECTORY_NAME_FORMAT, asTimestampedDirectoryName(type), UUID.randomUUID());
|
||||
}
|
||||
|
||||
protected static @NonNull File createDirectory(@NonNull String pathname) {
|
||||
return createDirectory(new File(pathname));
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.data.gemfire.tests.integration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@@ -41,10 +40,9 @@ public class IntegrationTestsSupportUnitTests {
|
||||
String directoryName = IntegrationTestsSupport.asDirectoryName(OuterType.InnerType.class);
|
||||
|
||||
assertThat(directoryName).isNotBlank();
|
||||
assertThat(directoryName).startsWith(String.format("%s.%s.%s-%s%s",
|
||||
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),
|
||||
File.separator));
|
||||
DateTimeFormatter.ofPattern(IntegrationTestsSupport.DATE_TIME_PATTERN).format(now)).concat("[\\w-]+"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user