use of java.util.prefs.Preferences in project robovm by robovm.
the class OldPreferencesTest method testAbsolutePath.
public void testAbsolutePath() {
Preferences p = Preferences.userNodeForPackage(Preferences.class);
assertEquals("/java/util/prefs", p.absolutePath());
}
use of java.util.prefs.Preferences in project robovm by robovm.
the class OldPreferencesTest method testNodeExists.
public void testNodeExists() throws BackingStoreException {
Preferences parent = Preferences.userNodeForPackage(Preferences.class);
Preferences pref = parent.node("mock");
try {
pref.nodeExists(null);
fail();
} catch (NullPointerException expected) {
}
try {
pref.nodeExists("/java/util/prefs/");
fail();
} catch (IllegalArgumentException expected) {
}
try {
pref.nodeExists("/java//util/prefs");
fail();
} catch (IllegalArgumentException expected) {
}
assertTrue(pref.nodeExists("/"));
assertTrue(pref.nodeExists("/java/util/prefs"));
assertTrue(pref.nodeExists(""));
assertFalse(pref.nodeExists("child"));
Preferences grandchild = pref.node("child/grandchild");
assertTrue(pref.nodeExists("child"));
assertTrue(pref.nodeExists("child/grandchild"));
grandchild.removeNode();
assertTrue(pref.nodeExists("child"));
assertFalse(pref.nodeExists("child/grandchild"));
assertFalse(grandchild.nodeExists(""));
assertFalse(pref.nodeExists("child2/grandchild"));
pref.node("child2/grandchild");
assertTrue(pref.nodeExists("child2/grandchild"));
}
use of java.util.prefs.Preferences in project robovm by robovm.
the class OldPreferencesTest method testRemove.
public void testRemove() throws BackingStoreException {
Preferences pref = Preferences.userNodeForPackage(Preferences.class);
pref.remove("key");
pref.put("key", "value");
assertEquals("value", pref.get("key", null));
pref.remove("key");
assertNull(pref.get("key", null));
pref.remove("key");
try {
pref.remove(null);
fail();
} catch (NullPointerException expected) {
}
pref.removeNode();
try {
pref.remove("key");
fail();
} catch (IllegalStateException expected) {
}
}
use of java.util.prefs.Preferences in project robovm by robovm.
the class OldPreferencesTest method testGet.
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) {
}
}
use of java.util.prefs.Preferences in project robovm by robovm.
the class OldPreferencesTest method testAbstractMethods.
public void testAbstractMethods() throws IOException, BackingStoreException {
Preferences p = new MockPreferences();
p.absolutePath();
p.childrenNames();
p.clear();
p.exportNode(null);
p.exportSubtree(null);
p.flush();
p.get(null, null);
p.getBoolean(null, false);
p.getByteArray(null, null);
p.getFloat(null, 0.1f);
p.getDouble(null, 0.1);
p.getInt(null, 1);
p.getLong(null, 1l);
p.isUserNode();
p.keys();
p.name();
p.node(null);
p.nodeExists(null);
p.parent();
p.put(null, null);
p.putBoolean(null, false);
p.putByteArray(null, null);
p.putDouble(null, 1);
p.putFloat(null, 1f);
p.putInt(null, 1);
p.putLong(null, 1l);
p.remove(null);
p.removeNode();
p.addNodeChangeListener(null);
p.addPreferenceChangeListener(null);
p.removeNodeChangeListener(null);
p.removePreferenceChangeListener(null);
p.sync();
p.toString();
}
Aggregations