Code example for Preferences

Methods: getputputFloat

0
    } 
 
    public void testGet() throws BackingStoreException { 
        Preferences root = Preferences.userNodeForPackage(Preferences.class);
        Preferences pref = root.node("mock");
        assertNull(pref.get("", null));
        assertEquals("default", pref.get("key", "default"));
        assertNull(pref.get("key", null));
        pref.put("testGetkey", "value");
        assertNull(pref.get("testGetKey", null));
        assertEquals("value", pref.get("testGetkey", null));
 
        try { 
            pref.get(null, "abc");
            fail();
        } catch (NullPointerException expected) {
        } 
        pref.get("", "abc");
        pref.get("key", null);
        pref.get("key", "");
        pref.putFloat("floatKey", 1.0f);
        assertEquals("1.0", pref.get("floatKey", null));
 
        pref.removeNode();
        try { 
            pref.get("key", "abc");
            fail();
        } catch (IllegalStateException expected) {
        } 
        try { 
            pref.get(null, "abc");
            fail();
        } catch (NullPointerException expected) {
        } 
    } 
 
Experience pair programming with AI  Get Codota for Java