public void testGetNode() { IScopeContext context = new InstanceScope(); // null try { context.getNode(null); fail("1.0"); } catch (IllegalArgumentException e) { // expected } // valid single segment String qualifier = Long.toString(System.currentTimeMillis()); Preferences node = context.getNode(qualifier); assertNotNull("2.0", node); String expected = "/instance/" + qualifier; String actual = node.absolutePath(); assertEquals("2.1", expected, actual); // path qualifier = new Path(Long.toString(System.currentTimeMillis())).append("a").toString(); node = context.getNode(qualifier); assertNotNull("3.0", node); expected = "/instance/" + qualifier; actual = node.absolutePath(); assertEquals("3.1", expected, actual); }
public void testBadContext() { IScopeContext context = new BadTestScope(); IPreferencesService service = Platform.getPreferencesService(); try { context.getNode("qualifier"); fail("0.5"); // should throw an exception } catch (RuntimeException e) { // expected } assertNull("1.0", service.getString("qualifier", "foo", null, new IScopeContext[] {context})); }