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 org.apache.commons.vfs2.FileName;
20 import org.apache.commons.vfs2.FileType;
21 import org.junit.Assert;
22 import org.junit.Test;
23
24 public class AbstractFileNameTest {
25 @Test
26 public void testHashSignEncoded() {
27 final AbstractFileName fileName = new AbstractFileName("file", "/foo/bar/file#name.txt", FileType.FILE) {
28 @Override
29 protected void appendRootUri(final StringBuilder buffer, final boolean addPassword) {
30 if (addPassword) {
31 buffer.append("pass");
32 }
33 }
34
35 @Override
36 public FileName createName(final String absolutePath, final FileType fileType) {
37 return null;
38 }
39 };
40
41 Assert.assertEquals("pass/foo/bar/file%23name.txt", fileName.getURI());
42 Assert.assertEquals("/foo/bar/file%23name.txt", fileName.getFriendlyURI());
43 }
44 }