1 19 20 package org.netbeans.core.startup; 21 22 import java.io.*; 23 import java.lang.reflect.Field ; 24 import java.lang.reflect.Method ; 25 import java.util.*; 26 import org.netbeans.Module; 27 import org.netbeans.ModuleManager; 28 import org.netbeans.core.startup.ModuleHistory; 29 import org.netbeans.junit.*; 30 import junit.textui.TestRunner; 31 import org.netbeans.core.startup.layers.SessionManager; 32 import org.openide.filesystems.FileSystem; 33 34 38 public class NbInstallerTest8 extends SetupHid { 39 40 public NbInstallerTest8(String name) { 41 super(name); 42 } 43 44 public static void main(String [] args) { 45 System.setProperty("org.netbeans.core.modules", "0"); 47 if (System.getProperty("nbjunit.workdir") == null) { 49 System.setProperty("nbjunit.workdir", System.getProperty("java.io.tmpdir")); 51 } 52 TestRunner.run(new NbTestSuite(NbInstallerTest8.class)); 53 } 54 55 private static File home, user, homeMod, userMod; 56 private File moduleJar; 57 protected void setUp() throws Exception { 58 super.setUp(); 59 System.setProperty("org.netbeans.core.modules.NbInstaller.noAutoDeps", "true"); 60 moduleJar = new File(jars, "look-for-myself.jar"); 62 } 63 64 68 public void testEarlyModuleInfoLookup() throws Exception { 69 ModuleManager mgr = Main.getModuleSystem().getManager(); 71 mgr.mutexPrivileged().enterWriteAccess(); 72 try { 73 Module m = mgr.get("lookformyself"); 74 assertNull(m); 75 m = mgr.create(moduleJar, new ModuleHistory(moduleJar.getAbsolutePath()), false, false, false); 76 assertEquals("look-for-myself.jar can be enabled", Collections.EMPTY_SET, m.getProblems()); 77 mgr.enable(m); 78 Class c = m.getClassLoader().loadClass("lookformyself.Loder"); 79 Method meth = c.getMethod("foundNow", null); 80 assertTrue("ModuleInfo is found after startup", ((Boolean )meth.invoke(null, null)).booleanValue()); 81 Field f = c.getField("foundEarly"); 82 assertTrue("ModuleInfo is found during dataloader section initialization", ((Boolean )f.get(null)).booleanValue()); 83 } finally { 84 mgr.mutexPrivileged().exitWriteAccess(); 85 } 86 } 87 88 } 89 | Popular Tags |