1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.vfs2.provider;
18
19 import static org.junit.jupiter.api.Assertions.assertEquals;
20
21 import org.apache.commons.vfs2.FileName;
22 import org.apache.commons.vfs2.FileType;
23 import org.junit.jupiter.api.Test;
24
25 public class AbstractFileNameTest {
26
27 @Test
28 public void testHashSignEncoded() {
29 final AbstractFileName fileName = new AbstractFileName("file", "/foo/bar/file#name.txt", FileType.FILE) {
30 @Override
31 protected void appendRootUri(final StringBuilder buffer, final boolean addPassword) {
32 if (addPassword) {
33 buffer.append("pass");
34 }
35 }
36
37 @Override
38 public FileName createName(final String absolutePath, final FileType fileType) {
39 return null;
40 }
41 };
42
43 assertEquals("pass/foo/bar/file%23name.txt", fileName.getURI());
44 assertEquals("/foo/bar/file%23name.txt", fileName.getFriendlyURI());
45 }
46
47 }