diff options
author | Håkon Hallingstad <hakon@oath.com> | 2018-01-25 15:37:57 +0100 |
---|---|---|
committer | Håkon Hallingstad <hakon@oath.com> | 2018-01-25 15:37:57 +0100 |
commit | 3d8e7c4b1c26ba7742fa96a37438335f56f4c63a (patch) | |
tree | 01442ff4e2ef8cbf7d53f349ae83a2252de71443 /testutil | |
parent | ce0178998956ae2fea340d5e23e9f17c0e5c3db6 (diff) |
Move TestFileSystem to testutil
Diffstat (limited to 'testutil')
-rw-r--r-- | testutil/pom.xml | 5 | ||||
-rw-r--r-- | testutil/src/main/java/com/yahoo/vespa/test/file/TestFileSystem.java | 24 |
2 files changed, 29 insertions, 0 deletions
diff --git a/testutil/pom.xml b/testutil/pom.xml index 00f606860a4..491c144fdb0 100644 --- a/testutil/pom.xml +++ b/testutil/pom.xml @@ -46,6 +46,11 @@ <artifactId>junit</artifactId> <scope>compile</scope> </dependency> + <dependency> + <groupId>com.google.jimfs</groupId> + <artifactId>jimfs</artifactId> + <scope>compile</scope> + </dependency> </dependencies> <build> <plugins> diff --git a/testutil/src/main/java/com/yahoo/vespa/test/file/TestFileSystem.java b/testutil/src/main/java/com/yahoo/vespa/test/file/TestFileSystem.java new file mode 100644 index 00000000000..751825b0c2a --- /dev/null +++ b/testutil/src/main/java/com/yahoo/vespa/test/file/TestFileSystem.java @@ -0,0 +1,24 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +package com.yahoo.vespa.test.file; + +import com.google.common.jimfs.Configuration; +import com.google.common.jimfs.Feature; +import com.google.common.jimfs.Jimfs; +import com.google.common.jimfs.PathType; + +import java.nio.file.FileSystem; + +public class TestFileSystem { + public static FileSystem create() { + // This configuration is based on Configuration.unix(), except: + // - Use "posix" attribute view which is necessary for permissions, owner, and group. + Configuration configuration = Configuration.builder(PathType.unix()) + .setRoots("/") + .setWorkingDirectory("/work") + .setAttributeViews("posix") + .setSupportedFeatures(Feature.LINKS, Feature.SYMBOLIC_LINKS, Feature.SECURE_DIRECTORY_STREAM, Feature.FILE_CHANNEL) + .build(); + return Jimfs.newFileSystem(configuration); + } +} |