1 19 20 package org.netbeans.core.startup; 21 22 import java.io.*; 23 import java.io.File ; 24 import java.util.Collections ; 25 import java.util.Locale ; 26 import java.util.jar.*; 27 import org.netbeans.Module; 28 import org.netbeans.ModuleManager; 29 import org.netbeans.junit.*; 30 import junit.textui.TestRunner; 31 import org.openide.filesystems.Repository; 32 33 37 public class ModuleFormatSatisfiedTest extends SetupHid { 38 private File moduleJarFile; 39 40 public ModuleFormatSatisfiedTest(String name) { 41 super(name); 42 } 43 44 protected void setUp() throws Exception { 45 super.setUp(); 46 System.setProperty("org.netbeans.core.modules.NbInstaller.noAutoDeps", "true"); 47 48 File tmp = File.createTempFile ("ModuleFormatTest", ".jar"); 49 moduleJarFile = tmp; 50 51 Manifest man = new Manifest (); 52 man.getMainAttributes ().putValue ("Manifest-Version", "1.0"); 53 man.getMainAttributes ().putValue ("OpenIDE-Module", "org.test.FormatDependency/1"); 54 55 56 String req = "org.openide.modules.ModuleFormat1"; 57 58 man.getMainAttributes ().putValue ("OpenIDE-Module-Requires", req); 59 60 JarOutputStream os = new JarOutputStream (new FileOutputStream (tmp), man); 61 os.putNextEntry (new JarEntry ("empty/test.txt")); 62 os.close (); 63 } 64 65 66 public void testTryToInstallTheModule () throws Exception { 67 Main.getModuleSystem (); 69 70 71 72 final FakeEvents ev = new FakeEvents(); 73 org.netbeans.core.startup.NbInstaller installer = new org.netbeans.core.startup.NbInstaller(ev); 74 ModuleManager mgr = new ModuleManager(installer, ev); 75 installer.registerManager(mgr); 76 mgr.mutexPrivileged().enterWriteAccess(); 77 try { 78 addOpenideModules(mgr); 79 Module m1 = mgr.create(moduleJarFile, null, false, false, false); 80 assertEquals(Collections.EMPTY_SET, m1.getProblems()); 81 mgr.enable(m1); 82 mgr.disable(m1); 83 mgr.delete(m1); 84 } finally { 85 mgr.mutexPrivileged().exitWriteAccess(); 86 } 87 } 88 89 90 static void addOpenideModules (ModuleManager mgr) throws Exception { 91 ClassLoader l = SetupHid.class.getClassLoader(); 92 String openide = 93 "Manifest-Version: 1.0\n" + 94 "OpenIDE-Module: org.openide.modules\n" + 95 "OpenIDE-Module-Localizing-Bundle: org/openide/modules/Bundle.properties\n" + 96 "Specification-Title: NetBeans\n" + 97 "OpenIDE-Module-Specification-Version: 6.2\n" + 98 "\n" + 99 "Name: /org/openide/modules/\n" + 100 "Package-Title: org.openide.modules\n"; 101 102 Manifest mani = new Manifest (new java.io.ByteArrayInputStream (openide.getBytes ())); 103 mgr.enable(mgr.createFixed(mani, null, l)); 104 } 105 106 107 } 108 | Popular Tags |