1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.vfs2.provider.local;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertTrue;
21
22 import java.io.File;
23 import java.io.IOException;
24 import java.net.URISyntaxException;
25 import java.net.URL;
26 import java.nio.file.Files;
27
28 import org.apache.commons.vfs2.FileObject;
29 import org.apache.commons.vfs2.FileSystemManager;
30 import org.apache.commons.vfs2.VFS;
31 import org.junit.Ignore;
32 import org.junit.Test;
33
34
35
36
37
38
39 public class ConversionTestCase {
40
41 @Test
42 @Ignore
43 public void testFileNameWithCharacters() throws URISyntaxException, IOException {
44 final File file = new File("target", "+# %&.txt");
45 final String fileURL = file.toURI().toURL().toExternalForm();
46 assertEquals(file.getAbsoluteFile(), new File(file.toURI().getPath()));
47 assertEquals(file.getAbsoluteFile(), new File(new URL(fileURL).toURI().getPath()));
48 try {
49 Files.newOutputStream(file.toPath()).close();
50 assertTrue(file.exists());
51
52 final FileSystemManager manager = VFS.getManager();
53 final FileObject fo = manager.resolveFile(fileURL);
54 assertTrue(fo.exists());
55 assertEquals(file.getAbsoluteFile(), new File(new URL(fo.getURL().toExternalForm()).toURI().getPath()));
56 } finally {
57 file.delete();
58 }
59 }
60
61 @Test
62 @Ignore
63 public void testFileNameWithSpaces() throws URISyntaxException, IOException {
64 final File file = new File("target", "a name.txt");
65 final String fileURL = file.toURI().toURL().toExternalForm();
66 assertEquals(file.getAbsoluteFile(), new File(file.toURI().getPath()));
67 assertEquals(file.getAbsoluteFile(), new File(new URL(fileURL).toURI().getPath()));
68
69 final FileSystemManager manager = VFS.getManager();
70 final FileObject fo = manager.resolveFile(fileURL);
71 assertEquals(file.getAbsoluteFile(), new File(new URL(fo.getURL().toExternalForm()).toURI().getPath()));
72 }
73
74 }