use of org.syncany.util.NormalizedPath in project syncany by syncany.
the class NormalizedPathTest method testNameAndParentPathForNormalizedPaths.
private void testNameAndParentPathForNormalizedPaths(OperatingSystem operatingSystem) {
EnvironmentUtil.setOperatingSystem(operatingSystem);
// Test 1: For a file called 'A black\white telephone ☎.jpg'
// Note: "A black" is NOT a directory, it's part of the filename (invalid on Windows!)
String alreadyNormalizedRelativePathFileStr = "Pictures/A black\\white telephone ☎.jpg";
NormalizedPath normalizedPathFile = new NormalizedPath(null, alreadyNormalizedRelativePathFileStr);
assertEquals("Pictures/A black\\white telephone ☎.jpg", normalizedPathFile.toString());
assertEquals("Pictures", normalizedPathFile.getParent().toString());
// Test 2: For directory called 'black\\white telephones ☎'
String alreadyNormalizedRelativePathDirStr = "Pictures/black\\white telephones ☎";
NormalizedPath normalizedPathDir = new NormalizedPath(null, alreadyNormalizedRelativePathDirStr);
assertEquals("Pictures/black\\white telephones ☎", normalizedPathDir.toString());
assertEquals("Pictures", normalizedPathDir.getParent().toString());
// Test 3: For directory called 'black\\white telephones ☎'
String alreadyNormalizedRelativePathFileWithBackslashesDirStr = "Pictures/Black\\White Pictures/Mostly\\Black Pictures/blacky.jpg";
NormalizedPath normalizedPathWithBackslashesDir = new NormalizedPath(null, alreadyNormalizedRelativePathFileWithBackslashesDirStr);
assertEquals("Pictures/Black\\White Pictures/Mostly\\Black Pictures/blacky.jpg", normalizedPathWithBackslashesDir.toString());
assertEquals("Pictures/Black\\White Pictures/Mostly\\Black Pictures", normalizedPathWithBackslashesDir.getParent().toString());
}
use of org.syncany.util.NormalizedPath in project syncany by syncany.
the class NormalizedPathTest method testCreatablizationOnWindows.
@Test
public void testCreatablizationOnWindows() throws Exception {
EnvironmentUtil.setOperatingSystem(OperatingSystem.WINDOWS);
File root = new File("C:\\Philipp");
assertEquals("Philipp", new NormalizedPath(root, "Philipp").toCreatable("filename conflict", true).toString());
assertEquals("Philipp", new NormalizedPath(root, "Philipp").toCreatable("filename conflict", true).toString());
assertEquals("Philipp/image.jpg", new NormalizedPath(root, "Philipp/image.jpg").toCreatable("filename conflict", true).toString());
assertEquals("Philipp/image", new NormalizedPath(root, "Philipp/image").toCreatable("filename conflict", true).toString());
// Cannot happen on Windows
assertEquals("Philipp/filewithcolons (filename conflict).txt", new NormalizedPath(root, "Philipp/file:with:colons.txt").toCreatable("filename conflict", true).toString());
assertEquals("Philipp/filewithbackslashes (filename conflict).txt", new NormalizedPath(root, "Philipp/file\\with\\backslashes.txt").toCreatable("filename conflict", true).toString());
assertEquals("Philipp/folderwithbackslashes (filename conflict)", new NormalizedPath(root, "Philipp/folder\\with\\backslashes").toCreatable("filename conflict", true).toString());
}
Aggregations