|
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-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.core.modules; import java.io.File; import java.util.*; import org.netbeans.junit.*; import junit.textui.TestRunner; import org.netbeans.core.NbTopManager; import org.openide.filesystems.Repository; /** Test the NetBeans module installer implementation. * Broken into pieces to ensure each runs in its own VM. * @author Jesse Glick */ public class NbInstallerTest4 extends SetupHid { public NbInstallerTest4(String name) { super(name); } public static void main(String[] args) { // Turn on verbose logging while developing tests: System.setProperty("org.netbeans.core.modules", "0"); System.setProperty("org.netbeans.core.projects", "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(NbInstallerTest4.class)); } protected void setUp() throws Exception { super.setUp(); clearWorkDir(); System.setProperty("system.dir", getWorkDir().getAbsolutePath()); } /** Test #21173/#23609: overriding layers by module dependencies. * Version 1: all modules loaded together. */ public void testDependencyLayerOverrides1() throws Exception { NbTopManager.get(); // init module system final FakeEvents ev = new FakeEvents(); NbInstaller installer = new NbInstaller(ev); ModuleManager mgr = new ModuleManager(installer, ev); installer.registerManager(mgr); mgr.mutexPrivileged().enterWriteAccess(); try { addOpenide(mgr); Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false); Module m2 = mgr.create(new File(jars, "override-layer-mod.jar"), null, false, false, false); assertEquals(Collections.EMPTY_SET, m2.getProblems()); assertEquals(null, slurp("foo/file1.txt")); assertEquals(null, slurp("foo/file3.txt")); assertEquals(null, slurp("foo/file4.txt")); Set m1m2 = new HashSet(Arrays.asList(new Module[] {m1, m2})); mgr.enable(m1m2); assertEquals("base contents", slurp("foo/file1.txt")); assertEquals("customized contents", slurp("foo/file3.txt")); assertEquals(null, slurp("foo/file4.txt")); assertEquals("someotherval", Repository.getDefault().getDefaultFileSystem().findResource("foo/file5.txt").getAttribute("myattr")); mgr.disable(m1m2); assertEquals(null, slurp("foo/file1.txt")); mgr.delete(m2); mgr.delete(m1); } finally { mgr.mutexPrivileged().exitWriteAccess(); } } } |
... 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.