|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.core.modules; import java.io.*; import java.util.*; import org.netbeans.junit.*; import junit.textui.TestRunner; import org.netbeans.core.NbTopManager; import org.netbeans.core.Plain; import org.netbeans.core.projects.SessionManager; import org.openide.filesystems.FileSystem; /** Test the NetBeans module installer implementation. * Broken into pieces to ensure each runs in its own VM. * @author Jesse Glick */ public class NbInstallerTest7 extends SetupHid { public NbInstallerTest7(String name) { super(name); } public static void main(String[] args) { // Turn on verbose logging while developing tests: System.setProperty("org.netbeans.core.modules", "0"); // In case run standalone, need a work dir. if (System.getProperty("nbjunit.workdir") == null) { // Hope java.io.tmpdir is set... System.setProperty("nbjunit.workdir", System.getProperty("java.io.tmpdir")); } TestRunner.run(new NbTestSuite(NbInstallerTest7.class)); } private static File home, user, homeMod, userMod; protected void setUp() throws Exception { super.setUp(); System.setProperty("netbeans.suppress.sysprop.warning", "true"); System.setProperty("org.netbeans.core.modules.NbInstaller.noAutoDeps", "true"); // leave NO_COMPAT_AUTO_TRANSITIVE_DEPS=false } /** Test #27853 compat: old modules should be able to use packages * from transitive dependency modules, but new modules should not. */ public void testTransitiveDependencies() throws Exception { // Ought to load these modules: ModuleManager mgr = NbTopManager.get().getModuleSystem().getManager(); mgr.mutexPrivileged().enterWriteAccess(); try { String[] jarnames = new String[] { "api-mod-export-api.jar", "uses-and-exports-api.jar", "uses-api-directly.jar", "uses-api-transitively.jar", "uses-api-directly-old.jar", "uses-api-transitively-old.jar", }; for (int i = 0; i < jarnames.length; i++) { File moduleJar = new File(jars, jarnames[i]); mgr.create(moduleJar, new ModuleHistory(moduleJar.getAbsolutePath()), false, false, false); } Module apimodexportapi = mgr.get("org.netbeans.modules.foo"); assertNotNull(apimodexportapi); Module usesandexportsapi = mgr.get("usesandexportsapi"); assertNotNull(usesandexportsapi); Module usesapidirectly = mgr.get("usesapidirectly"); assertNotNull(usesapidirectly); assertEquals("uses-api-directly.jar can be enabled", Collections.EMPTY_SET, usesapidirectly.getProblems()); mgr.enable(new HashSet(Arrays.asList(new Module[] {apimodexportapi, usesandexportsapi, usesapidirectly}))); Module usesapitransitively = mgr.get("usesapitrans"); assertNotNull(usesapitransitively); assertEquals("uses-api-transitively.jar can be enabled", Collections.EMPTY_SET, usesapitransitively.getProblems()); mgr.enable(usesapitransitively); Module usesapidirectlyold = mgr.get("usesapidirectlyold"); assertNotNull(usesapidirectlyold); assertEquals("uses-api-directly-old.jar can be enabled", Collections.EMPTY_SET, usesapidirectlyold.getProblems()); mgr.enable(usesapidirectlyold); Module usesapitransitivelyold = mgr.get("usesapitransold"); assertNotNull(usesapitransitivelyold); assertEquals("uses-api-transitively-old.jar can be enabled", Collections.EMPTY_SET, usesapitransitivelyold.getProblems()); mgr.enable(usesapitransitivelyold); usesapidirectly.getClassLoader().loadClass("usesapitrans.UsesDirectAPI").newInstance(); usesapidirectly.getClassLoader().loadClass("usesapitrans.UsesIndirectAPI").newInstance(); usesapitransitively.getClassLoader().loadClass("usesapitrans.UsesDirectAPI").newInstance(); try { usesapitransitively.getClassLoader().loadClass("usesapitrans.UsesIndirectAPI").newInstance(); fail("Should not be able to use a transitive API class with no direct dependency"); } catch (NoClassDefFoundError e) {} usesapidirectlyold.getClassLoader().loadClass("usesapitrans.UsesDirectAPI").newInstance(); usesapidirectlyold.getClassLoader().loadClass("usesapitrans.UsesIndirectAPI").newInstance(); usesapitransitivelyold.getClassLoader().loadClass("usesapitrans.UsesDirectAPI").newInstance(); usesapitransitivelyold.getClassLoader().loadClass("usesapitrans.UsesIndirectAPI").newInstance(); } finally { mgr.mutexPrivileged().exitWriteAccess(); } } // XXX also test that lib/ext/ package dependencies are correctly handled: // For old modules, any package deps from parent modules should be available. // For new modules, only direct package deps are considered. } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.