Lines 21-28
Link Here
|
21 |
import java.lang.reflect.*; |
21 |
import java.lang.reflect.*; |
22 |
import org.openide.util.*; |
22 |
import org.openide.util.*; |
23 |
import org.openide.modules.*; |
23 |
import org.openide.modules.*; |
24 |
import java.net.URLClassLoader; |
24 |
import java.net.*; |
25 |
import java.net.URL; |
|
|
26 |
import java.util.jar.JarFile; |
25 |
import java.util.jar.JarFile; |
27 |
import java.util.jar.Manifest; |
26 |
import java.util.jar.Manifest; |
28 |
|
27 |
|
Lines 51-56
Link Here
|
51 |
public static void main(String[] args) { |
50 |
public static void main(String[] args) { |
52 |
// Turn on verbose logging while developing tests: |
51 |
// Turn on verbose logging while developing tests: |
53 |
System.setProperty("org.netbeans.core.modules", "0"); |
52 |
System.setProperty("org.netbeans.core.modules", "0"); |
|
|
53 |
// In case run standalone, need a work dir. |
54 |
if (System.getProperty("nbjunit.workdir") == null) { |
55 |
// Hope java.io.tmpdir is set... |
56 |
System.setProperty("nbjunit.workdir", System.getProperty("java.io.tmpdir")); |
57 |
} |
54 |
TestRunner.run(new NbTestSuite(ModuleManagerTest.class)); |
58 |
TestRunner.run(new NbTestSuite(ModuleManagerTest.class)); |
55 |
} |
59 |
} |
56 |
|
60 |
|
Lines 1195-1200
Link Here
|
1195 |
// 8 - too late |
1199 |
// 8 - too late |
1196 |
// 9 - must give some rel vers, else ~ -1 |
1200 |
// 9 - must give some rel vers, else ~ -1 |
1197 |
assertEquals(ok, new HashSet(mgr.simulateEnable(all))); |
1201 |
assertEquals(ok, new HashSet(mgr.simulateEnable(all))); |
|
|
1202 |
} finally { |
1203 |
mgr.mutexPrivileged().exitWriteAccess(); |
1204 |
} |
1205 |
} |
1206 |
|
1207 |
/** Test #21114: after deleting a module, its JARs are released. |
1208 |
* Would probably always pass on Unix, but on Windows it matters. |
1209 |
*/ |
1210 |
public void testModuleDeletion() throws Exception { |
1211 |
FakeModuleInstaller installer = new FakeModuleInstaller(); |
1212 |
FakeEvents ev = new FakeEvents(); |
1213 |
ModuleManager mgr = new ModuleManager(installer, ev); |
1214 |
mgr.mutexPrivileged().enterWriteAccess(); |
1215 |
try { |
1216 |
File jar = new File(getWorkDir(), "copy-of-simple-module.jar"); |
1217 |
copy(new File(jars, "simple-module.jar"), jar); |
1218 |
Module m = mgr.create(jar, null, false, false, false); |
1219 |
mgr.enable(m); |
1220 |
Class c = m.getClassLoader().loadClass("org.foo.Something"); |
1221 |
URL u = m.getClassLoader().getResource("org/foo/Something.class"); |
1222 |
URLConnection uc = u.openConnection(); |
1223 |
assertTrue("using JarURLConnection", uc instanceof JarURLConnection); |
1224 |
uc.connect(); |
1225 |
mgr.disable(m); |
1226 |
mgr.delete(m); |
1227 |
assertTrue("could delete JAR file", jar.delete()); |
1228 |
c = null; |
1229 |
u = null; |
1230 |
uc = null; |
1231 |
System.gc(); |
1232 |
System.runFinalization(); |
1198 |
} finally { |
1233 |
} finally { |
1199 |
mgr.mutexPrivileged().exitWriteAccess(); |
1234 |
mgr.mutexPrivileged().exitWriteAccess(); |
1200 |
} |
1235 |
} |