View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.vfs2.provider.res;
18  
19  import static org.junit.jupiter.api.Assertions.assertThrows;
20  import static org.junit.jupiter.api.Assertions.assertTrue;
21  
22  import java.net.URI;
23  import java.net.URISyntaxException;
24  
25  import org.apache.commons.vfs2.FileSystemException;
26  import org.apache.commons.vfs2.VFS;
27  import org.junit.jupiter.api.Test;
28  
29  public class ResSchemeTest {
30  
31      @Test
32      public void testResolveFileString() throws FileSystemException {
33          assertTrue(VFS.getManager().resolveFile("res:test.properties").exists());
34      }
35  
36      @Test
37      public void testResolveFileStringS() throws FileSystemException {
38          assertTrue(VFS.getManager().resolveFile("res:/test.properties").exists());
39      }
40  
41      @Test
42      public void testResolveFileStringSS() throws FileSystemException {
43          assertTrue(VFS.getManager().resolveFile("res://test.properties").exists());
44      }
45  
46      @Test
47      public void testResolveFileStringSSS() throws FileSystemException {
48          assertTrue(VFS.getManager().resolveFile("res://test.properties").exists());
49      }
50  
51      @Test
52      public void testResolveFileStringSSSnull() {
53          // Resulting path is empty
54          assertThrows(FileSystemException.class, () -> VFS.getManager().resolveFile("res:///").exists());
55      }
56  
57      @Test
58      public void testResolveFileURI() throws FileSystemException, URISyntaxException {
59          assertTrue(VFS.getManager().resolveFile(new URI("res:test.properties")).exists());
60      }
61  
62      @Test
63      public void testResolveFileURIS() throws FileSystemException, URISyntaxException {
64          assertTrue(VFS.getManager().resolveFile(new URI("res:/test.properties")).exists());
65      }
66  
67      @Test
68      public void testResolveFileURISS() throws FileSystemException, URISyntaxException {
69          assertTrue(VFS.getManager().resolveFile(new URI("res://test.properties")).exists());
70      }
71  
72      @Test
73      public void testResolveFileURISSS() throws FileSystemException, URISyntaxException {
74          assertTrue(VFS.getManager().resolveFile(new URI("res://test.properties")).exists());
75      }
76  
77      @Test
78      public void testResolveURIString() throws FileSystemException {
79          assertTrue(VFS.getManager().resolveURI("res:test.properties").isFile());
80      }
81  
82      @Test
83      public void testResolveURIStringS() throws FileSystemException {
84          assertTrue(VFS.getManager().resolveURI("res:/test.properties").isFile());
85      }
86  
87      @Test
88      public void testResolveURIStringSS() throws FileSystemException {
89          assertTrue(VFS.getManager().resolveURI("res://test.properties").isFile());
90      }
91  
92      @Test
93      public void testResolveURIStringSSS() throws FileSystemException {
94          assertTrue(VFS.getManager().resolveURI("res:///test.properties").isFile());
95      }
96  
97      @Test
98      public void testResolveURIStringSSSnull() {
99          // Resulting path is empty
100         assertThrows(FileSystemException.class, () -> VFS.getManager().resolveURI("res:///").isFile());
101     }
102 
103 }