log.debug("Created sub directories " + subsubdir);
Path copiedFile = testDir.resolve("copiedFile.txt");
log.debug("Resolved " + copiedFile);
+ Path relativeCopiedFile = testDir.relativize(copiedFile);
+ assertEquals(copiedFile.getFileName().toString(), relativeCopiedFile.toString());
+ log.debug("Relative copied file " + relativeCopiedFile);
try (OutputStream out = Files.newOutputStream(copiedFile); InputStream in = Files.newInputStream(testPath)) {
IOUtils.copy(in, out);
}
assertEquals(6, attrs.size());
log.debug("Read attributes of " + copiedFile + ": " + attrs.keySet());
}
+
+ public void testIllegalCharacters() throws Exception {
+ FileSystemProvider fsProvider = new JackrabbitMemoryFsProvider();
+ String fileName = "tüßçt[1].txt";
+ String pathStr = "/testDir/" + fileName;
+ Path testDir = fsProvider.getPath(new URI("jcr+memory:/testDir"));
+ Files.createDirectory(testDir);
+ Path testPath = testDir.resolve(fileName);
+ assertEquals(pathStr, testPath.toString());
+ Files.createFile(testPath);
+ DirectoryStream<Path> files = Files.newDirectoryStream(testDir);
+ Path listedPath = files.iterator().next();
+ assertEquals(pathStr, listedPath.toString());
+
+ String dirName = "*[~WeirdDir~]*";
+ Path subDir = testDir.resolve(dirName);
+ Files.createDirectory(subDir);
+ subDir = testDir.resolve(dirName);
+ assertEquals(dirName, subDir.getFileName().toString());
+ }
}