Code example for AbstractPreferences

Methods: flush, getFloat, put, putDouble, putFloat, putInt, removeNode

0
            //expected 
        } 
    } 
 
    public void testGetFloat() throws BackingStoreException { 
        pref.put("Value", "String");
        pref.putDouble("DoubleValue", new Double(9.10938188e-31));
        pref.putFloat("FloatValue", new Float(-0.123));
        pref.putInt("IntValue", 299792458);
        pref.flush();
 
        assertEquals(new Float(0.1), pref.getFloat("Value", new Float(0.1)));
        assertEquals(new Float(-0.123), pref.getFloat("FloatValue", new Float(0.2)));
        assertEquals(new Float(9.109382e-31), pref.getFloat("DoubleValue", new Float(2.14)));
        assertEquals(new Float(2.99792448e8), pref.getFloat("IntValue", new Float(5)));
 
        try { 
            pref.getFloat(null, new Float(0.1));
            fail("NullPointerException expected");
        } catch (NullPointerException e) {
            //expected 
        } 
 
        pref.removeNode();
 
        try { 
            pref.getFloat("FloatValue", new Float(0.1));
            fail("IllegalStateException expected");
        } catch (IllegalStateException e) {
            //expected 
        } 
    }