1 19 20 package org.openide.filesystems; 21 22 import java.io.File ; 23 import java.io.FileOutputStream ; 24 import java.io.IOException ; 25 import java.util.jar.JarOutputStream ; 26 import java.util.zip.ZipEntry ; 27 import junit.framework.Test; 28 import org.netbeans.junit.NbTestSuite; 29 30 33 public class JarFileSystemTest extends FileSystemFactoryHid { 34 JarFileSystem jfs; 35 36 public JarFileSystemTest(Test test) { 37 super(test); 38 } 39 40 public static void main(String args[]) { 41 junit.textui.TestRunner.run(suite()); 42 } 43 44 45 public static Test suite() { 46 NbTestSuite suite = new NbTestSuite(); 47 suite.addTestSuite(RepositoryTestHid.class); 48 suite.addTestSuite(FileSystemTestHid.class); 49 suite.addTestSuite(FileObjectTestHid.class); 50 51 suite.addTestSuite(URLMapperTestHidden.class); 52 suite.addTestSuite(URLMapperTestInternalHidden.class); 53 suite.addTestSuite(FileUtilTestHidden.class); 54 55 return new JarFileSystemTest(suite); 56 } 57 protected void destroyFileSystem (String testName) throws IOException {} 58 59 protected FileSystem[] createFileSystem (String testName, String [] resources) throws IOException { 60 File jar = TestUtilHid.locationOfTempFolder("jfstest"); 61 jar.mkdir(); 62 63 File f = new File (jar,"jfstest.jar"); 64 if (!f.exists()) { 65 f.getParentFile().mkdirs(); 66 f.createNewFile(); 67 } 68 JarOutputStream jos = new JarOutputStream (new FileOutputStream (f)); 69 70 for (int i = 0; i < resources.length; i++) { 71 String entryName = resources[i]; 72 if (entryName.startsWith("/")) entryName = entryName.substring(1); 73 jos.putNextEntry(new ZipEntry (entryName)); 74 } 75 76 77 jos.close(); 78 79 jfs = new JarFileSystem (); 80 try { 81 jfs.setJarFile(f); 82 } catch (Exception ex) {} 83 84 return new FileSystem[] {jfs}; 85 } 86 } 87 | Popular Tags |