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  
18  package org.apache.commons.vfs2.provider.res;
19  
20  import java.net.URI;
21  import java.net.URISyntaxException;
22  
23  import org.apache.commons.vfs2.FileSystemException;
24  import org.apache.commons.vfs2.VFS;
25  import org.junit.Assert;
26  import org.junit.Test;
27  
28  public class ResSchemeTestCase {
29  
30      @Test
31      public void test_resolveFile_String() throws FileSystemException {
32          Assert.assertTrue(VFS.getManager().resolveFile("res:test.properties").exists());
33      }
34  
35      @Test
36      public void test_resolveFile_String_S() throws FileSystemException {
37          Assert.assertTrue(VFS.getManager().resolveFile("res:/test.properties").exists());
38      }
39  
40      @Test
41      public void test_resolveFile_String_SS() throws FileSystemException {
42          Assert.assertTrue(VFS.getManager().resolveFile("res://test.properties").exists());
43      }
44  
45      @Test
46      public void test_resolveFile_String_SSS() throws FileSystemException {
47          Assert.assertTrue(VFS.getManager().resolveFile("res://test.properties").exists());
48      }
49  
50      @Test(expected = FileSystemException.class)
51      public void test_resolveFile_String_SSSnull() throws FileSystemException {
52          // Resulting path is empty
53          Assert.assertTrue(VFS.getManager().resolveFile("res:///").exists());
54      }
55  
56      @Test
57      public void test_resolveFile_URI() throws FileSystemException, URISyntaxException {
58          Assert.assertTrue(VFS.getManager().resolveFile(new URI("res:test.properties")).exists());
59      }
60  
61      @Test
62      public void test_resolveFile_URI_S() throws FileSystemException, URISyntaxException {
63          Assert.assertTrue(VFS.getManager().resolveFile(new URI("res:/test.properties")).exists());
64      }
65  
66      @Test
67      public void test_resolveFile_URI_SS() throws FileSystemException, URISyntaxException {
68          Assert.assertTrue(VFS.getManager().resolveFile(new URI("res://test.properties")).exists());
69      }
70  
71      @Test
72      public void test_resolveFile_URI_SSS() throws FileSystemException, URISyntaxException {
73          Assert.assertTrue(VFS.getManager().resolveFile(new URI("res://test.properties")).exists());
74      }
75  
76      @Test
77      public void test_resolveURI_String() throws FileSystemException {
78          Assert.assertTrue(VFS.getManager().resolveURI("res:test.properties").isFile());
79      }
80  
81      @Test
82      public void test_resolveURI_String_S() throws FileSystemException {
83          Assert.assertTrue(VFS.getManager().resolveURI("res:/test.properties").isFile());
84      }
85  
86      @Test
87      public void test_resolveURI_String_SS() throws FileSystemException {
88          Assert.assertTrue(VFS.getManager().resolveURI("res://test.properties").isFile());
89      }
90  
91      @Test
92      public void test_resolveURI_String_SSS() throws FileSystemException {
93          Assert.assertTrue(VFS.getManager().resolveURI("res:///test.properties").isFile());
94      }
95  
96      @Test(expected = FileSystemException.class)
97      public void test_resolveURI_String_SSSnull() throws FileSystemException {
98          // Resulting path is empty
99          Assert.assertTrue(VFS.getManager().resolveURI("res:///").isFile());
100     }
101 }