use of java.util.prefs.AbstractPreferences in project jdk8u_jdk by JetBrains.
the class RemoveNullKeyCheck method checkAbstractPreferencesRemove.
public static void checkAbstractPreferencesRemove() {
Preferences abstrPrefs = new AbstractPreferences(null, "") {
@Override
protected void putSpi(String key, String value) {
}
@Override
protected String getSpi(String key) {
return null;
}
@Override
protected void removeSpi(String key) {
}
@Override
protected void removeNodeSpi() throws BackingStoreException {
}
@Override
protected String[] keysSpi() throws BackingStoreException {
return new String[0];
}
@Override
protected String[] childrenNamesSpi() throws BackingStoreException {
return new String[0];
}
@Override
protected AbstractPreferences childSpi(String name) {
return null;
}
@Override
protected void syncSpi() throws BackingStoreException {
}
@Override
protected void flushSpi() throws BackingStoreException {
}
};
try {
abstrPrefs.remove(null);
failed = true;
} catch (NullPointerException npe) {
}
}
use of java.util.prefs.AbstractPreferences in project robovm by robovm.
the class OldAbstractPreferencesTest method testChildrenNames.
public void testChildrenNames() throws BackingStoreException {
AbstractPreferences first = (AbstractPreferences) pref.node("First node");
AbstractPreferences second = (AbstractPreferences) pref.node("Second node");
assertEquals(2, pref.childrenNames().length);
assertEquals(0, first.childrenNames().length);
assertEquals(0, second.childrenNames().length);
second.removeNode();
try {
second.childrenNames();
fail("IllegalStateException expected");
} catch (IllegalStateException e) {
//expected
}
pref.removeNode();
try {
first.childrenNames();
fail("IllegalStateException expected");
} catch (IllegalStateException e) {
//expected
}
}
use of java.util.prefs.AbstractPreferences in project robovm by robovm.
the class OldAbstractPreferencesTest method testParent.
public void testParent() throws BackingStoreException {
AbstractPreferences node = (AbstractPreferences) pref.node("First node/sub node");
assertTrue(node.parent().name().compareTo("First node") == 0);
pref.removeNode();
try {
node.parent();
fail("IllegalStateException expected");
} catch (IllegalStateException e) {
//expected
}
}
use of java.util.prefs.AbstractPreferences in project robovm by robovm.
the class OldAbstractPreferencesTest method testNode.
public void testNode() throws BackingStoreException {
AbstractPreferences first = (AbstractPreferences) pref.node("First node");
AbstractPreferences second = (AbstractPreferences) pref.node("Second node");
try {
first.node("blabla/");
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
first.node("///invalid");
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < Preferences.MAX_NAME_LENGTH; i++) {
sb.append('c');
}
first.node(new String(sb));
sb.append('c');
try {
first.node(new String(sb));
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
second.removeNode();
try {
second.node("");
fail("IllegalStateException expected");
} catch (IllegalStateException e) {
//expected
}
pref.removeNode();
try {
first.node("");
fail("IllegalStateException expected");
} catch (IllegalStateException e) {
//expected
}
}
use of java.util.prefs.AbstractPreferences in project robovm by robovm.
the class OldAbstractPreferencesTest method testName.
public void testName() {
AbstractPreferences first = (AbstractPreferences) pref.node("First node");
AbstractPreferences second = (AbstractPreferences) pref.node("Second node/sub node");
assertTrue(first.name().compareTo("First node") == 0);
assertFalse(first.name().compareTo("Second node") == 0);
assertTrue(second.name().compareTo("sub node") == 0);
}
Aggregations