KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > masterfs > filebasedfs > FileBasedFileSystemTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.masterfs.filebasedfs;
21
22 import junit.framework.*;
23 import java.io.File JavaDoc;
24 import java.io.IOException JavaDoc;
25 import java.util.StringTokenizer JavaDoc;
26 import org.netbeans.junit.MockServices;
27 import org.netbeans.junit.NbTestSuite;
28 import org.netbeans.modules.masterfs.MasterFileObjectTestHid;
29 import org.netbeans.modules.masterfs.MasterFileSystem;
30 import org.netbeans.modules.masterfs.MasterFileSystemTest;
31 import org.netbeans.modules.masterfs.MasterURLMapper;
32 import org.netbeans.modules.masterfs.providers.AutoMountProvider;
33 import org.netbeans.modules.masterfs.providers.FileSystemProvider;
34 import org.netbeans.modules.masterfs.providers.MountSupport;
35 import org.netbeans.modules.masterfs.providers.ProvidedExtensionsTest;
36 import org.openide.filesystems.FileObject;
37 import org.openide.filesystems.FileObjectTestHid;
38 import org.openide.filesystems.FileSystem;
39 import org.openide.filesystems.FileSystemFactoryHid;
40 import org.openide.filesystems.FileSystemTestHid;
41 import org.openide.filesystems.FileUtil;
42 import org.openide.filesystems.FileUtilTestHidden;
43 import org.openide.filesystems.URLMapperTestHidden;
44 import org.openide.util.Lookup;
45 import org.openide.util.lookup.AbstractLookup;
46 import org.openide.util.lookup.InstanceContent;
47 import org.openide.util.lookup.Lookups;
48 import org.openide.util.lookup.ProxyLookup;
49
50 /**
51  * @author rmatous
52  */

53 public class FileBasedFileSystemTest extends FileSystemFactoryHid {
54     public FileBasedFileSystemTest(Test test) {
55         super(test);
56     }
57     
58     protected void setUp() throws Exception JavaDoc {
59         super.setUp();
60         MockServices.setServices(new Class JavaDoc[] {FileBasedURLMapper.class});
61     }
62
63     protected void tearDown() throws Exception JavaDoc {
64         super.tearDown();
65     }
66     
67     public static void main(String JavaDoc args[]) {
68         junit.textui.TestRunner.run(suite());
69     }
70     
71     public static Test suite() {
72         NbTestSuite suite = new NbTestSuite();
73         suite.addTestSuite(FileSystemTestHid.class);
74         suite.addTestSuite(FileObjectTestHid.class);
75         suite.addTestSuite(URLMapperTestHidden.class);
76         suite.addTestSuite(FileUtilTestHidden.class);
77         return new FileBasedFileSystemTest(suite);
78     }
79         
80     private File JavaDoc getWorkDir() {
81         String JavaDoc workDirProperty = System.getProperty("workdir");//NOI18N
82
workDirProperty = (workDirProperty != null) ? workDirProperty : System.getProperty("java.io.tmpdir");//NOI18N
83
return new File JavaDoc(workDirProperty);
84     }
85             
86     protected FileSystem[] createFileSystem(String JavaDoc testName, String JavaDoc[] resources) throws IOException JavaDoc {
87         FileBasedFileSystem.reinitForTests();
88         FileObject workFo = FileBasedFileSystem.getFileObject(getWorkDir());
89         assertNotNull(workFo);
90         for (int i = 0; i < resources.length; i++) {
91             String JavaDoc res = resources[i];
92             if (res.endsWith("/")) {
93                 assertNotNull(FileUtil.createFolder(workFo,res));
94             } else {
95                 assertNotNull(FileUtil.createData(workFo,res));
96             }
97         }
98         return new FileSystem[]{workFo.getFileSystem()};
99     }
100     
101     protected void destroyFileSystem(String JavaDoc testName) throws IOException JavaDoc {}
102
103     protected String JavaDoc getResourcePrefix(String JavaDoc testName, String JavaDoc[] resources) {
104         return getWorkDir().getAbsolutePath();
105     }
106 }
107
Popular Tags