@Before @Override public void setUp() { //This will cause ContextAction instances to invoke notifyAll() //when their enablement changes ContextAction.unitTest = true; MockServices.setServices(Provider.class); ContextGlobalProvider x = Lookup.getDefault().lookup(ContextGlobalProvider.class); assertNotNull(x); assertTrue(x instanceof Provider); Provider p = (Provider) x; content = p.content; lkp = p.lkp; //some sanity checks setContent("hello"); assertEquals("hello", lkp.lookupAll(String.class).iterator().next()); assertEquals("hello", Utilities.actionsGlobalContext().lookupAll(String.class).iterator().next()); clearContent(); assertEquals(null, lkp.lookup(String.class)); assertEquals(null, Utilities.actionsGlobalContext().lookup(String.class)); assertEquals(0, Utilities.actionsGlobalContext().lookupAll(Object.class).size()); }
public static void install() { MockLookup.setInstances(new ContextGlobalProvider() { public Lookup createGlobalContext() { return amLookup; } }); amResult = Utilities.actionsGlobalContext().lookupResult(ActionMap.class); Assert.assertEquals(Collections.singleton(EMPTY_MAP), new HashSet<ActionMap>(amResult.allInstances())); }
public static void install() { MockLookup.setInstances(new ContextGlobalProvider() { public Lookup createGlobalContext() { return nodeLookup; } }); nodeResult = Utilities.actionsGlobalContext().lookupResult(Node.class); Assert.assertEquals(Collections.emptySet(), new HashSet<Node>(nodeResult.allInstances())); }