1 19 20 package org.netbeans.modules.masterfs.filebasedfs; 21 22 import junit.framework.*; 23 import java.io.File ; 24 import java.io.IOException ; 25 import java.util.StringTokenizer ; 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 53 public class FileBasedFileSystemTest extends FileSystemFactoryHid { 54 public FileBasedFileSystemTest(Test test) { 55 super(test); 56 } 57 58 protected void setUp() throws Exception { 59 super.setUp(); 60 MockServices.setServices(new Class [] {FileBasedURLMapper.class}); 61 } 62 63 protected void tearDown() throws Exception { 64 super.tearDown(); 65 } 66 67 public static void main(String 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 getWorkDir() { 81 String workDirProperty = System.getProperty("workdir"); workDirProperty = (workDirProperty != null) ? workDirProperty : System.getProperty("java.io.tmpdir"); return new File (workDirProperty); 84 } 85 86 protected FileSystem[] createFileSystem(String testName, String [] resources) throws IOException { 87 FileBasedFileSystem.reinitForTests(); 88 FileObject workFo = FileBasedFileSystem.getFileObject(getWorkDir()); 89 assertNotNull(workFo); 90 for (int i = 0; i < resources.length; i++) { 91 String 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 testName) throws IOException {} 102 103 protected String getResourcePrefix(String testName, String [] resources) { 104 return getWorkDir().getAbsolutePath(); 105 } 106 } 107 | Popular Tags |