diff --git a/src/main/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDir.java b/src/main/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDir.java
index d97cf1a..dc7696f 100644
--- a/src/main/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDir.java
+++ b/src/main/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDir.java
@@ -40,6 +40,17 @@
@TempDir(factory = JimfsTempDirFactory.class)
public @interface JimfsTempDir {
+ /**
+ * Configuration parameter to set the default {@link Configuration Configuration} for the
+ * in-memory file system.
+ *
+ * If this configuration parameter is not set, the default is {@link
+ * Configuration#FOR_CURRENT_PLATFORM}.
+ *
+ * @since 0.2.0
+ */
+ String DEFAULT_CONFIGURATION_PARAMETER_NAME = "jimfs.junit.jupiter.tempdir.configuration.default";
+
/**
* Configuration for the in-memory file system.
*
@@ -47,7 +58,7 @@
*
* @return the configuration to use for the in-memory file system
*/
- Configuration value() default Configuration.FOR_CURRENT_PLATFORM;
+ Configuration value() default Configuration.DEFAULT;
/**
* Enumeration of configurations for the in-memory file system.
@@ -56,7 +67,14 @@
*/
enum Configuration {
/**
- * Configuration appropriate to the current operating system.
+ * Default configuration.
+ *
+ * @see #DEFAULT_CONFIGURATION_PARAMETER_NAME
+ * @since 0.2.0
+ */
+ DEFAULT(com.google.common.jimfs.Configuration::forCurrentPlatform),
+ /**
+ * Configuration appropriate to the current platform.
*
* @see com.google.common.jimfs.Configuration#forCurrentPlatform()
*/
diff --git a/src/main/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDirFactory.java b/src/main/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDirFactory.java
index 2c4f03e..8fac281 100644
--- a/src/main/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDirFactory.java
+++ b/src/main/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDirFactory.java
@@ -21,7 +21,9 @@
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.Locale;
import java.util.Optional;
+import java.util.function.Function;
import java.util.function.Supplier;
import org.junit.jupiter.api.extension.AnnotatedElementContext;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -31,28 +33,33 @@
* {@link TempDirFactory} implementation that creates an in-memory temporary directory via {@link
* Jimfs}, using {@value DEFAULT_PREFIX} as the name prefix.
*
- *
If used as a standalone factory within the {@link org.junit.jupiter.api.io.TempDir}
- * annotation, or set as value for the {@value DEFAULT_FACTORY_PROPERTY_NAME} configuration
- * property, the factory configures the underlying file system {@link
- * Configuration#forCurrentPlatform() appropriately for the current operating system}.
+ *
When used as a standalone factory within the {@link org.junit.jupiter.api.io.TempDir}
+ * annotation, or set as value for the {@value
+ * org.junit.jupiter.api.io.TempDir#DEFAULT_FACTORY_PROPERTY_NAME} configuration parameter, the
+ * factory configures the underlying file system appropriately for the {@link
+ * com.google.common.jimfs.Configuration#forCurrentPlatform() current platform}.
*
- *
For better control over the underlying in-memory file system, consider using the {@link
- * JimfsTempDir} composed annotation and its {@link JimfsTempDir#value() value} attribute.
+ *
For better control over the underlying in-memory file system, consider using one of the
+ * following options:
+ *
+ *
+ * - The {@link JimfsTempDir} composed annotation and its {@link JimfsTempDir#value() value}
+ * attribute.
+ *
- The {@value JimfsTempDir#DEFAULT_CONFIGURATION_PARAMETER_NAME} configuration parameter.
+ *
*
* Please note that only annotated fields or parameters of type {@link java.nio.file.Path} are
* supported as Jimfs is a non-default file system, and {@link java.io.File} instances are
* associated with the default file system only.
*
- * @see Jimfs#newFileSystem(Configuration)
- * @see Configuration#forCurrentPlatform()
+ * @see Jimfs#newFileSystem(com.google.common.jimfs.Configuration)
+ * @see com.google.common.jimfs.Configuration#forCurrentPlatform()
*/
public final class JimfsTempDirFactory implements TempDirFactory {
private static final String DEFAULT_PREFIX = "junit-";
-
- @SuppressWarnings("unused")
- private static final String DEFAULT_FACTORY_PROPERTY_NAME =
- org.junit.jupiter.api.io.TempDir.DEFAULT_FACTORY_PROPERTY_NAME;
+ private static final Function CONFIGURATION_TRANSFORMER =
+ value -> JimfsTempDir.Configuration.valueOf(value.trim().toUpperCase(Locale.ROOT));
private FileSystem fileSystem;
@@ -69,14 +76,27 @@ public Path createTempDirectory(
Supplier configuration =
annotation
.map(JimfsTempDir::value)
+ .filter(JimfsTempDirFactory::isNotDefaultConfiguration)
.map(JimfsTempDir.Configuration::getConfiguration)
- .orElse(Configuration::forCurrentPlatform);
+ .orElseGet(
+ () ->
+ extensionContext
+ .getConfigurationParameter(
+ JimfsTempDir.DEFAULT_CONFIGURATION_PARAMETER_NAME,
+ CONFIGURATION_TRANSFORMER)
+ .filter(JimfsTempDirFactory::isNotDefaultConfiguration)
+ .map(JimfsTempDir.Configuration::getConfiguration)
+ .orElse(Configuration::forCurrentPlatform));
fileSystem = Jimfs.newFileSystem(configuration.get());
Path root = fileSystem.getRootDirectories().iterator().next();
return Files.createTempDirectory(root, DEFAULT_PREFIX);
}
+ private static boolean isNotDefaultConfiguration(JimfsTempDir.Configuration value) {
+ return value != JimfsTempDir.Configuration.DEFAULT;
+ }
+
/** {@inheritDoc} */
@Override
public void close() throws IOException {
diff --git a/src/test/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDirFactoryTests.java b/src/test/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDirFactoryTests.java
index e57bdee..f67d970 100644
--- a/src/test/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDirFactoryTests.java
+++ b/src/test/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDirFactoryTests.java
@@ -22,7 +22,6 @@
import static io.github.scordio.jimfs.junit.jupiter.Requirements.windowsFileSystem;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.condition.OS.MAC;
-import static org.junit.jupiter.api.condition.OS.WINDOWS;
import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass;
import static org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.request;
@@ -32,18 +31,22 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
import org.junit.platform.testkit.engine.EngineExecutionResults;
+@DisplayName("JimfsTempDirFactory")
class JimfsTempDirFactoryTests {
@Nested
- @DisplayName("with @TempDir factory attribute")
- class with_TempDir_factory_attribute {
+ @DisplayName("with @TempDir factory (annotation attribute)")
+ class with_TempDir_factory_annotation_attribute {
@EnabledOnOs(MAC)
@Test
- void should_use_os_x_configuration() {
+ void should_apply_OS_X_configuration_on_Mac_platform() {
executeTestsForClass(OsXTestCase.class)
.testEvents()
.assertStatistics(stats -> stats.started(1).succeeded(1));
@@ -57,9 +60,9 @@ void test(@TempDir(factory = JimfsTempDirFactory.class) Path tempDir) {
}
}
- @DisabledOnOs({MAC, WINDOWS})
+ @DisabledOnOs({MAC, OS.WINDOWS})
@Test
- void should_use_unix_configuration() {
+ void should_apply_UNIX_configuration_on_Unix_platform() {
executeTestsForClass(UnixTestCase.class)
.testEvents()
.assertStatistics(stats -> stats.started(1).succeeded(1));
@@ -73,9 +76,9 @@ void test(@TempDir(factory = JimfsTempDirFactory.class) Path tempDir) {
}
}
- @EnabledOnOs(WINDOWS)
+ @EnabledOnOs(OS.WINDOWS)
@Test
- void should_use_windows_configuration() {
+ void should_apply_WINDOWS_configuration_on_Windows_platform() {
executeTestsForClass(WindowsTestCase.class)
.testEvents()
.assertStatistics(stats -> stats.started(1).succeeded(1));
@@ -91,8 +94,8 @@ void test(@TempDir(factory = JimfsTempDirFactory.class) Path tempDir) {
}
@Nested
- @DisplayName("with @TempDir default factory configuration property")
- class with_TempDir_default_factory_configuration_property {
+ @DisplayName("with @TempDir default factory (configuration parameter)")
+ class with_TempDir_default_factory_config_parameter {
private static EngineExecutionResults executeTestsForClass(Class> testClass) {
return executeTests(
@@ -105,7 +108,7 @@ private static EngineExecutionResults executeTestsForClass(Class> testClass) {
@EnabledOnOs(MAC)
@Test
- void should_use_os_x_configuration() {
+ void should_apply_OS_X_configuration_on_Mac_platform() {
executeTestsForClass(OsXTestCase.class)
.testEvents()
.assertStatistics(stats -> stats.started(1).succeeded(1));
@@ -119,9 +122,9 @@ void test(@TempDir Path tempDir) {
}
}
- @DisabledOnOs({MAC, WINDOWS})
+ @DisabledOnOs({MAC, OS.WINDOWS})
@Test
- void should_use_unix_configuration() {
+ void should_apply_UNIX_configuration_on_Unix_platform() {
executeTestsForClass(UnixTestCase.class)
.testEvents()
.assertStatistics(stats -> stats.started(1).succeeded(1));
@@ -135,9 +138,9 @@ void test(@TempDir Path tempDir) {
}
}
- @EnabledOnOs(WINDOWS)
+ @EnabledOnOs(OS.WINDOWS)
@Test
- void should_use_windows_configuration() {
+ void should_apply_WINDOWS_configuration_on_Windows_platform() {
executeTestsForClass(WindowsTestCase.class)
.testEvents()
.assertStatistics(stats -> stats.started(1).succeeded(1));
@@ -151,4 +154,129 @@ void test(@TempDir Path tempDir) {
}
}
}
+
+ @Nested
+ @DisplayName("with Jimfs default configuration (configuration parameter)")
+ class with_Jimfs_default_configuration_config_parameter {
+
+ private static EngineExecutionResults executeTestsForClass(
+ Class> testClass, String configuration) {
+ return executeTests(
+ request()
+ .selectors(selectClass(testClass))
+ .configurationParameter(
+ TempDir.DEFAULT_FACTORY_PROPERTY_NAME, JimfsTempDirFactory.class.getName())
+ .configurationParameter(
+ JimfsTempDir.DEFAULT_CONFIGURATION_PARAMETER_NAME, configuration)
+ .build());
+ }
+
+ @EnabledOnOs(MAC)
+ @ParameterizedTest
+ @ValueSource(strings = {"DEFAULT", "default"})
+ void should_apply_OS_X_configuration_with_DEFAULT_parameter_on_Mac_platform(
+ String configuration) {
+ executeTestsForClass(OsXTestCase.class, configuration)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ @EnabledOnOs(MAC)
+ @ParameterizedTest
+ @ValueSource(strings = {"FOR_CURRENT_PLATFORM", "for_current_platform"})
+ void should_apply_OS_X_configuration_with_FOR_CURRENT_PLATFORM_parameter_on_Mac_platform(
+ String configuration) {
+ executeTestsForClass(OsXTestCase.class, configuration)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"OS_X", "os_x"})
+ void should_apply_OS_X_configuration_with_OS_X_parameter(String configuration) {
+ executeTestsForClass(OsXTestCase.class, configuration)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ static class OsXTestCase {
+
+ @Test
+ void test(@TempDir Path tempDir) {
+ assertThat(tempDir).satisfies(osXFileSystem());
+ }
+ }
+
+ @DisabledOnOs({MAC, OS.WINDOWS})
+ @ParameterizedTest
+ @ValueSource(strings = {"DEFAULT", "default"})
+ void should_apply_UNIX_configuration_with_DEFAULT_parameter_on_Unix_platform(
+ String configuration) {
+ executeTestsForClass(UnixTestCase.class, configuration)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ @DisabledOnOs({MAC, OS.WINDOWS})
+ @ParameterizedTest
+ @ValueSource(strings = {"FOR_CURRENT_PLATFORM", "for_current_platform"})
+ void should_apply_UNIX_configuration_with_FOR_CURRENT_PLATFORM_parameter_on_Unix_platform(
+ String configuration) {
+ executeTestsForClass(UnixTestCase.class, configuration)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"UNIX", "unix"})
+ void should_apply_UNIX_configuration_with_UNIX_parameter(String configuration) {
+ executeTestsForClass(UnixTestCase.class, configuration)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ static class UnixTestCase {
+
+ @Test
+ void test(@TempDir Path tempDir) {
+ assertThat(tempDir).satisfies(unixFileSystem());
+ }
+ }
+
+ @EnabledOnOs(OS.WINDOWS)
+ @ParameterizedTest
+ @ValueSource(strings = {"DEFAULT", "default"})
+ void should_apply_WINDOWS_configuration_with_DEFAULT_parameter_on_Windows_platform(
+ String configuration) {
+ executeTestsForClass(WindowsTestCase.class, configuration)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ @EnabledOnOs(OS.WINDOWS)
+ @ParameterizedTest
+ @ValueSource(strings = {"FOR_CURRENT_PLATFORM", "for_current_platform"})
+ void should_apply_WINDOWS_configuration_with_FOR_CURRENT_PLATFORM_parameter_on_Windows_platform(
+ String configuration) {
+ executeTestsForClass(WindowsTestCase.class, configuration)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"WINDOWS", "windows"})
+ void should_apply_WINDOWS_configuration_with_WINDOWS_parameter(String configuration) {
+ executeTestsForClass(WindowsTestCase.class, configuration)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ static class WindowsTestCase {
+
+ @Test
+ void test(@TempDir Path tempDir) {
+ assertThat(tempDir).satisfies(windowsFileSystem());
+ }
+ }
+ }
}
diff --git a/src/test/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDirTests.java b/src/test/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDirTests.java
index c2cb71d..d25d8d7 100644
--- a/src/test/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDirTests.java
+++ b/src/test/java/io/github/scordio/jimfs/junit/jupiter/JimfsTempDirTests.java
@@ -15,183 +15,326 @@
*/
package io.github.scordio.jimfs.junit.jupiter;
+import static io.github.scordio.jimfs.junit.jupiter.JimfsTempDir.Configuration.DEFAULT;
import static io.github.scordio.jimfs.junit.jupiter.JimfsTempDir.Configuration.FOR_CURRENT_PLATFORM;
import static io.github.scordio.jimfs.junit.jupiter.JimfsTempDir.Configuration.OS_X;
import static io.github.scordio.jimfs.junit.jupiter.JimfsTempDir.Configuration.UNIX;
import static io.github.scordio.jimfs.junit.jupiter.JimfsTempDir.Configuration.WINDOWS;
+import static io.github.scordio.jimfs.junit.jupiter.JimfsTempDir.DEFAULT_CONFIGURATION_PARAMETER_NAME;
+import static io.github.scordio.jimfs.junit.jupiter.JupiterEngineTestKit.executeTests;
import static io.github.scordio.jimfs.junit.jupiter.JupiterEngineTestKit.executeTestsForClass;
import static io.github.scordio.jimfs.junit.jupiter.Requirements.osXFileSystem;
import static io.github.scordio.jimfs.junit.jupiter.Requirements.unixFileSystem;
import static io.github.scordio.jimfs.junit.jupiter.Requirements.windowsFileSystem;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.condition.OS.MAC;
+import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass;
+import static org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.request;
import java.nio.file.Path;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.junit.platform.testkit.engine.EngineExecutionResults;
+@DisplayName("JimfsTempDir")
class JimfsTempDirTests {
@Nested
- class With_Default_Configuration {
+ @DisplayName("without configuration parameters")
+ class without_config_parameters {
- @EnabledOnOs(MAC)
- @Test
- void should_use_os_x_configuration() {
- executeTestsForClass(OsXTestCase.class)
- .testEvents()
- .assertStatistics(stats -> stats.started(1).succeeded(1));
- }
+ @Nested
+ class with_DEFAULT_configuration {
- static class OsXTestCase {
+ @EnabledOnOs(MAC)
+ @Test
+ void should_apply_OS_X_configuration_on_Mac_platform() {
+ executeTestsForClass(OsXTestCase.class)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ static class OsXTestCase {
+
+ @Test
+ void test(@JimfsTempDir Path tempDir1, @JimfsTempDir(DEFAULT) Path tempDir2) {
+ assertThat(tempDir1).satisfies(osXFileSystem());
+ assertThat(tempDir2).satisfies(osXFileSystem());
+ }
+ }
+
+ @DisabledOnOs({MAC, OS.WINDOWS})
+ @Test
+ void should_apply_UNIX_configuration_on_Unix_platform() {
+ executeTestsForClass(UnixTestCase.class)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ static class UnixTestCase {
+
+ @Test
+ void test(@JimfsTempDir Path tempDir1, @JimfsTempDir(DEFAULT) Path tempDir2) {
+ assertThat(tempDir1).satisfies(unixFileSystem());
+ assertThat(tempDir2).satisfies(unixFileSystem());
+ }
+ }
+ @EnabledOnOs(OS.WINDOWS)
@Test
- void test(@JimfsTempDir Path tempDir) {
- assertThat(tempDir).satisfies(osXFileSystem());
+ void should_apply_WINDOWS_configuration_on_Windows_platform() {
+ executeTestsForClass(WindowsTestCase.class)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ static class WindowsTestCase {
+
+ @Test
+ void test(@JimfsTempDir Path tempDir1, @JimfsTempDir(DEFAULT) Path tempDir2) {
+ assertThat(tempDir1).satisfies(windowsFileSystem());
+ assertThat(tempDir2).satisfies(windowsFileSystem());
+ }
}
}
- @DisabledOnOs({MAC, OS.WINDOWS})
- @Test
- void should_use_unix_configuration() {
- executeTestsForClass(UnixTestCase.class)
- .testEvents()
- .assertStatistics(stats -> stats.started(1).succeeded(1));
+ @Nested
+ class with_FOR_CURRENT_PLATFORM_configuration {
+
+ @EnabledOnOs(MAC)
+ @Test
+ void should_apply_OS_X_configuration_on_Mac_platform() {
+ executeTestsForClass(OsXTestCase.class)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ static class OsXTestCase {
+
+ @Test
+ void test(@JimfsTempDir(FOR_CURRENT_PLATFORM) Path tempDir) {
+ assertThat(tempDir).satisfies(osXFileSystem());
+ }
+ }
+
+ @DisabledOnOs({MAC, OS.WINDOWS})
+ @Test
+ void should_apply_UNIX_configuration_on_Unix_platform() {
+ executeTestsForClass(UnixTestCase.class)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ static class UnixTestCase {
+
+ @Test
+ void test(@JimfsTempDir(FOR_CURRENT_PLATFORM) Path tempDir) {
+ assertThat(tempDir).satisfies(unixFileSystem());
+ }
+ }
+
+ @EnabledOnOs(OS.WINDOWS)
+ @Test
+ void should_apply_WINDOWS_configuration_on_Windows_platform() {
+ executeTestsForClass(WindowsTestCase.class)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ static class WindowsTestCase {
+
+ @Test
+ void test(@JimfsTempDir(FOR_CURRENT_PLATFORM) Path tempDir) {
+ assertThat(tempDir).satisfies(windowsFileSystem());
+ }
+ }
}
- static class UnixTestCase {
+ @Nested
+ class with_OS_X_configuration {
@Test
- void test(@JimfsTempDir Path tempDir) {
- assertThat(tempDir).satisfies(unixFileSystem());
+ void should_apply_OS_X_configuration() {
+ executeTestsForClass(TestCase.class)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ static class TestCase {
+
+ @Test
+ void test(@JimfsTempDir(OS_X) Path tempDir) {
+ assertThat(tempDir).satisfies(osXFileSystem());
+ }
}
}
- @EnabledOnOs(OS.WINDOWS)
- @Test
- void should_use_windows_configuration() {
- executeTestsForClass(WindowsTestCase.class)
- .testEvents()
- .assertStatistics(stats -> stats.started(1).succeeded(1));
+ @Nested
+ class with_UNIX_configuration {
+
+ @Test
+ void should_apply_UNIX_configuration() {
+ executeTestsForClass(TestCase.class)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ static class TestCase {
+
+ @Test
+ void test(@JimfsTempDir(UNIX) Path tempDir) {
+ assertThat(tempDir).satisfies(unixFileSystem());
+ }
+ }
}
- static class WindowsTestCase {
+ @Nested
+ class with_WINDOWS_configuration {
@Test
- void test(@JimfsTempDir Path tempDir) {
- assertThat(tempDir).satisfies(windowsFileSystem());
+ void should_apply_WINDOWS_configuration_with_WINDOWS_value() {
+ executeTestsForClass(TestCase.class)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
+ }
+
+ static class TestCase {
+
+ @Test
+ void test(@JimfsTempDir(WINDOWS) Path tempDir) {
+ assertThat(tempDir).satisfies(windowsFileSystem());
+ }
}
}
}
@Nested
- class With_FOR_CURRENT_PLATFORM_Configuration {
+ @DisplayName("with Jimfs default configuration (configuration parameter)")
+ class with_Jimfs_default_configuration_config_parameter {
+
+ private static EngineExecutionResults executeTestsForClass(
+ Class> testClass, String configuration) {
+ return executeTests(
+ request()
+ .selectors(selectClass(testClass))
+ .configurationParameter(DEFAULT_CONFIGURATION_PARAMETER_NAME, configuration)
+ .build());
+ }
@EnabledOnOs(MAC)
- @Test
- void should_use_os_x_configuration() {
- executeTestsForClass(OsXTestCase.class)
+ @ParameterizedTest
+ @ValueSource(strings = {"DEFAULT", "default"})
+ void should_apply_OS_X_configuration_with_DEFAULT_parameter_on_Mac_platform(
+ String configuration) {
+ executeTestsForClass(OsXTestCase.class, configuration)
.testEvents()
.assertStatistics(stats -> stats.started(1).succeeded(1));
}
- static class OsXTestCase {
-
- @Test
- void test(@JimfsTempDir(FOR_CURRENT_PLATFORM) Path tempDir) {
- assertThat(tempDir).satisfies(osXFileSystem());
- }
+ @EnabledOnOs(MAC)
+ @ParameterizedTest
+ @ValueSource(strings = {"FOR_CURRENT_PLATFORM", "for_current_platform"})
+ void should_apply_OS_X_configuration_with_FOR_CURRENT_PLATFORM_parameter_on_Mac_platform(
+ String configuration) {
+ executeTestsForClass(OsXTestCase.class, configuration)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
}
- @DisabledOnOs({MAC, OS.WINDOWS})
- @Test
- void should_use_unix_configuration() {
- executeTestsForClass(UnixTestCase.class)
+ @ParameterizedTest
+ @ValueSource(strings = {"OS_X", "os_x"})
+ void should_apply_OS_X_configuration_with_OS_X_parameter(String configuration) {
+ executeTestsForClass(OsXTestCase.class, configuration)
.testEvents()
.assertStatistics(stats -> stats.started(1).succeeded(1));
}
- static class UnixTestCase {
+ static class OsXTestCase {
@Test
- void test(@JimfsTempDir(FOR_CURRENT_PLATFORM) Path tempDir) {
- assertThat(tempDir).satisfies(unixFileSystem());
+ void test(@JimfsTempDir Path tempDir1, @JimfsTempDir(DEFAULT) Path tempDir2) {
+ assertThat(tempDir1).satisfies(osXFileSystem());
+ assertThat(tempDir2).satisfies(osXFileSystem());
}
}
- @EnabledOnOs(OS.WINDOWS)
- @Test
- void should_use_windows_configuration() {
- executeTestsForClass(WindowsTestCase.class)
+ @DisabledOnOs({MAC, OS.WINDOWS})
+ @ParameterizedTest
+ @ValueSource(strings = {"DEFAULT", "default"})
+ void should_apply_UNIX_configuration_with_DEFAULT_parameter_on_Unix_platform(
+ String configuration) {
+ executeTestsForClass(UnixTestCase.class, configuration)
.testEvents()
.assertStatistics(stats -> stats.started(1).succeeded(1));
}
- static class WindowsTestCase {
-
- @Test
- void test(@JimfsTempDir(FOR_CURRENT_PLATFORM) Path tempDir) {
- assertThat(tempDir).satisfies(windowsFileSystem());
- }
+ @DisabledOnOs({MAC, OS.WINDOWS})
+ @ParameterizedTest
+ @ValueSource(strings = {"FOR_CURRENT_PLATFORM", "for_current_platform"})
+ void should_apply_UNIX_configuration_with_FOR_CURRENT_PLATFORM_parameter_on_Unix_platform(
+ String configuration) {
+ executeTestsForClass(UnixTestCase.class, configuration)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
}
- }
- @Nested
- class With_OS_X_Configuration {
-
- @Test
- void should_use_os_x_configuration() {
- executeTestsForClass(TestCase.class)
+ @ParameterizedTest
+ @ValueSource(strings = {"UNIX", "unix"})
+ void should_apply_UNIX_configuration_with_UNIX_parameter(String configuration) {
+ executeTestsForClass(UnixTestCase.class, configuration)
.testEvents()
.assertStatistics(stats -> stats.started(1).succeeded(1));
}
- static class TestCase {
+ static class UnixTestCase {
@Test
- void test(@JimfsTempDir(OS_X) Path tempDir) {
- assertThat(tempDir).satisfies(osXFileSystem());
+ void test(@JimfsTempDir Path tempDir1, @JimfsTempDir(DEFAULT) Path tempDir2) {
+ assertThat(tempDir1).satisfies(unixFileSystem());
+ assertThat(tempDir2).satisfies(unixFileSystem());
}
}
- }
-
- @Nested
- class With_UNIX_Configuration {
- @Test
- void should_use_os_x_configuration() {
- executeTestsForClass(TestCase.class)
+ @EnabledOnOs(OS.WINDOWS)
+ @ParameterizedTest
+ @ValueSource(strings = {"DEFAULT", "default"})
+ void should_apply_WINDOWS_configuration_with_DEFAULT_parameter_on_Windows_platform(
+ String configuration) {
+ executeTestsForClass(WindowsTestCase.class, configuration)
.testEvents()
.assertStatistics(stats -> stats.started(1).succeeded(1));
}
- static class TestCase {
-
- @Test
- void test(@JimfsTempDir(UNIX) Path tempDir) {
- assertThat(tempDir).satisfies(unixFileSystem());
- }
+ @EnabledOnOs(OS.WINDOWS)
+ @ParameterizedTest
+ @ValueSource(strings = {"FOR_CURRENT_PLATFORM", "for_current_platform"})
+ void should_apply_WINDOWS_configuration_with_FOR_CURRENT_PLATFORM_parameter_on_Windows_platform(
+ String configuration) {
+ executeTestsForClass(WindowsTestCase.class, configuration)
+ .testEvents()
+ .assertStatistics(stats -> stats.started(1).succeeded(1));
}
- }
- @Nested
- class With_WINDOWS_Configuration {
-
- @Test
- void should_use_windows_configuration() {
- executeTestsForClass(TestCase.class)
+ @ParameterizedTest
+ @ValueSource(strings = {"WINDOWS", "windows"})
+ void should_apply_WINDOWS_configuration_with_WINDOWS_parameter(String configuration) {
+ executeTestsForClass(WindowsTestCase.class, configuration)
.testEvents()
.assertStatistics(stats -> stats.started(1).succeeded(1));
}
- static class TestCase {
+ static class WindowsTestCase {
@Test
- void test(@JimfsTempDir(WINDOWS) Path tempDir) {
- assertThat(tempDir).satisfies(windowsFileSystem());
+ void test(@JimfsTempDir Path tempDir1, @JimfsTempDir(DEFAULT) Path tempDir2) {
+ assertThat(tempDir1).satisfies(windowsFileSystem());
+ assertThat(tempDir2).satisfies(windowsFileSystem());
}
}
}