1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  package org.apache.commons.vfs2.provider.http4;
18  
19  import static org.junit.jupiter.api.Assertions.assertEquals;
20  
21  import java.util.Locale;
22  
23  import org.apache.commons.vfs2.FileObject;
24  import org.apache.commons.vfs2.FileSystemException;
25  import org.apache.commons.vfs2.FileSystemManager;
26  import org.apache.commons.vfs2.VFS;
27  import org.junit.jupiter.api.Test;
28  
29  
30  
31  
32  public class Http4FilesCacheTest {
33  
34      @Test
35      public void testQueryStringUrl0() throws FileSystemException {
36          @SuppressWarnings("resource")
37          final FileSystemManager fileSystemManager = VFS.getManager();
38  
39          final String noQueryStringUrl = "http4://commons.apache.org/";
40          try (FileObject noQueryFile = fileSystemManager.resolveFile(noQueryStringUrl)) {
41              assertEquals(noQueryStringUrl, noQueryFile.getURL().toExternalForm());
42          }
43      }
44  
45      @Test
46      public void testQueryStringUrl1() throws FileSystemException {
47          @SuppressWarnings("resource")
48          final FileSystemManager fileSystemManager = VFS.getManager();
49  
50          final String noQueryStringUrl = "http4://commons.apache.org/vfs";
51          try (FileObject noQueryFile = fileSystemManager.resolveFile(noQueryStringUrl)) {
52              assertEquals(noQueryStringUrl, noQueryFile.getURL().toExternalForm());
53          }
54      }
55  
56      @Test
57      public void testQueryStringUrl2() throws FileSystemException {
58          @SuppressWarnings("resource")
59          final FileSystemManager fileSystemManager = VFS.getManager();
60  
61          final String queryStringUrl = "http4://commons.apache.org/vfs?query=string";
62          try (FileObject queryFile = fileSystemManager.resolveFile(queryStringUrl)) {
63              assertEquals(queryStringUrl, queryFile.getURL().toExternalForm()); 
64          }
65      }
66  
67      @Test
68      public void testQueryStringUrl3() throws FileSystemException {
69          @SuppressWarnings("resource")
70          final FileSystemManager fileSystemManager = VFS.getManager();
71  
72          final String queryStringUrl2 = "http4://commons.apache.org/vfs?query=string&more=stuff";
73          try (FileObject queryFile2 = fileSystemManager.resolveFile(queryStringUrl2)) {
74              assertEquals(queryStringUrl2, queryFile2.getURL().toExternalForm()); 
75          }
76      }
77  
78      @Test
79      public void testQueryStringUrl4() throws FileSystemException {
80          @SuppressWarnings("resource")
81          final FileSystemManager fileSystemManager = VFS.getManager();
82  
83          
84          
85          final String queryStringUrl3 = "http4://alice%5C1234:secret@localhost:8080/";
86          try (FileObject queryFile3 = fileSystemManager.resolveFile(queryStringUrl3)) {
87              assertEquals(queryStringUrl3.toLowerCase(Locale.ROOT), queryFile3.getURL().toExternalForm());
88          }
89      }
90  
91      @Test
92      public void testQueryStringUrl5() throws FileSystemException {
93          @SuppressWarnings("resource")
94          final FileSystemManager fileSystemManager = VFS.getManager();
95  
96          
97          final String queryStringUrl4 = "http4://alice%5c1234:secret@localhost:8080/";
98          try (FileObject queryFile4 = fileSystemManager.resolveFile(queryStringUrl4)) {
99              assertEquals(queryStringUrl4, queryFile4.getURL().toExternalForm());
100         }
101     }
102 
103     @Test
104     public void testQueryStringUrl6() throws FileSystemException {
105         @SuppressWarnings("resource")
106         final FileSystemManager fileSystemManager = VFS.getManager();
107 
108         
109         final String queryStringUrl4 = "http4://alice:secret@localhost:8080/";
110         try (FileObject queryFile4 = fileSystemManager.resolveFile(queryStringUrl4)) {
111             assertEquals(queryStringUrl4, queryFile4.getURL().toExternalForm());
112         }
113     }
114 
115     @Test
116     public void testQueryStringUrl7() throws FileSystemException {
117         @SuppressWarnings("resource")
118         final FileSystemManager fileSystemManager = VFS.getManager();
119 
120         
121         final String queryStringUrl4 = "http4://localhost:8080/";
122         try (FileObject queryFile4 = fileSystemManager.resolveFile(queryStringUrl4)) {
123             assertEquals(queryStringUrl4, queryFile4.getURL().toExternalForm());
124         }
125     }
126 
127 }