KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > vfs > test > UrlStructureTests


1 /*
2  * Copyright 2002-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.vfs.test;
17
18 import org.apache.commons.vfs.Capability;
19 import org.apache.commons.vfs.FileObject;
20 import org.apache.commons.vfs.provider.http.HttpFileSystem;
21
22 import java.io.IOException JavaDoc;
23
24 /**
25  * URL Test cases for providers that supply structural info.
26  *
27  * @author <a HREF="mailto:adammurdoch@apache.org">Adam Murdoch</a>
28  */

29 public class UrlStructureTests
30     extends AbstractProviderTestCase
31 {
32     /**
33      * Returns the capabilities required by the tests of this test case.
34      */

35     protected Capability[] getRequiredCaps()
36     {
37         return new Capability[]
38         {
39             Capability.GET_TYPE,
40             Capability.URI
41         };
42     }
43
44     /**
45      * Tests that folders have no content.
46      */

47     public void testFolderURL() throws Exception JavaDoc
48     {
49         final FileObject folder = getReadFolder().resolveFile("dir1");
50         if (folder.getFileSystem() instanceof HttpFileSystem)
51         {
52             // bad hack, but this test might not fail on HttpFileSystem as there are no direcotries.
53
// A Directory do have a content on http. e.g a generated directory listing or the index.html page.
54
return;
55         }
56
57         assertTrue(folder.exists());
58
59         // Try getting the content of a folder
60
try
61         {
62             folder.getURL().openConnection().getInputStream();
63             fail();
64         }
65         catch (final IOException JavaDoc e)
66         {
67             assertSameMessage("vfs.provider/read-not-file.error", folder, e);
68         }
69     }
70 }
71
Popular Tags