use of java.nio.file.FileStore in project lucene-solr by apache.
the class TestIOUtils method testTmpfsDoesntSpin.
public void testTmpfsDoesntSpin() throws Exception {
Path dir = createTempDir();
dir = FilterPath.unwrap(dir).toRealPath();
// fake tmpfs
FileStore root = new MockFileStore(dir.toString() + " (/dev/sda1)", "tmpfs", "/dev/sda1");
Map<String, FileStore> mappings = Collections.singletonMap(dir.toString(), root);
FileSystem mockLinux = new MockLinuxFileSystemProvider(dir.getFileSystem(), mappings, dir).getFileSystem(null);
Path mockPath = mockLinux.getPath(dir.toString());
assertFalse(IOUtils.spinsLinux(mockPath));
}
use of java.nio.file.FileStore in project lucene-solr by apache.
the class TestIOUtils method testGetFileStore.
public void testGetFileStore() throws Exception {
Path dir = createTempDir();
dir = FilterPath.unwrap(dir).toRealPath();
// now we can create some fake mount points:
FileStore root = new MockFileStore(dir.toString() + " (/dev/sda1)", "ntfs", "/dev/sda1");
FileStore usr = new MockFileStore(dir.resolve("usr").toString() + " (/dev/sda2)", "xfs", "/dev/sda2");
// associate some preset files to these
Map<String, FileStore> mappings = new HashMap<>();
mappings.put(dir.toString(), root);
mappings.put(dir.resolve("foo.txt").toString(), root);
mappings.put(dir.resolve("usr").toString(), usr);
mappings.put(dir.resolve("usr/bar.txt").toString(), usr);
FileSystem mockLinux = new MockLinuxFileSystemProvider(dir.getFileSystem(), mappings, dir).getFileSystem(null);
Path mockPath = mockLinux.getPath(dir.toString());
// sanity check our mock:
assertSame(usr, Files.getFileStore(mockPath.resolve("usr")));
assertSame(usr, Files.getFileStore(mockPath.resolve("usr/bar.txt")));
// for root filesystem we get a crappy one
assertNotSame(root, Files.getFileStore(mockPath));
assertNotSame(usr, Files.getFileStore(mockPath));
assertNotSame(root, Files.getFileStore(mockPath.resolve("foo.txt")));
assertNotSame(usr, Files.getFileStore(mockPath.resolve("foo.txt")));
// now test our method:
assertSame(usr, IOUtils.getFileStore(mockPath.resolve("usr")));
assertSame(usr, IOUtils.getFileStore(mockPath.resolve("usr/bar.txt")));
assertSame(root, IOUtils.getFileStore(mockPath));
assertSame(root, IOUtils.getFileStore(mockPath.resolve("foo.txt")));
}
Aggregations