1 19 20 package org.netbeans.modules.j2ee.metadata; 21 22 import org.netbeans.junit.NbTestCase; 23 import org.openide.util.Lookup; 24 import org.openide.util.lookup.Lookups; 25 import org.openide.util.lookup.ProxyLookup; 26 27 31 public class TestBase extends NbTestCase { 32 33 static { 34 System.setProperty("org.openide.util.Lookup", Lkp.class.getName()); 35 assertEquals("Unable to set the default lookup!", Lkp.class, Lookup.getDefault().getClass()); 36 } 37 38 public TestBase(String name) { 39 super(name); 40 } 41 42 public static void setLookups(Object [] instances) { 43 ((Lkp)Lookup.getDefault()).setLookups(instances); 44 } 45 46 public static final class Lkp extends ProxyLookup { 47 public Lkp() { 48 setLookups(new Object [0]); 49 } 50 51 void setLookups(Object [] instances) { 52 ClassLoader l = TestBase.class.getClassLoader(); 53 setLookups(new Lookup[] { 54 Lookups.fixed(instances), 55 Lookups.metaInfServices(l), 56 Lookups.singleton(l) 57 }); 58 } 59 } 60 } 61 | Popular Tags |