Search in sources :

Example 31 with Preferences

use of java.util.prefs.Preferences in project robovm by robovm.

the class OldPreferencesTest method testIsUserNode.

public void testIsUserNode() {
    Preferences pref1 = Preferences.userNodeForPackage(Preferences.class);
    assertTrue(pref1.isUserNode());
    Preferences pref2 = Preferences.systemNodeForPackage(Preferences.class);
    assertFalse(pref2.isUserNode());
}
Also used : Preferences(java.util.prefs.Preferences)

Example 32 with Preferences

use of java.util.prefs.Preferences in project robovm by robovm.

the class OldPreferencesTest method testPutInt.

public void testPutInt() {
    Preferences pref = Preferences.userNodeForPackage(Preferences.class);
    try {
        pref.putInt(null, 3);
        fail();
    } catch (NullPointerException expected) {
    }
    pref.putInt(longKey, 3);
    try {
        pref.putInt(longKey + "a", 3);
        fail();
    } catch (IllegalArgumentException expected) {
    }
    pref.putInt("testPutIntKey", 3);
    assertEquals("3", pref.get("testPutIntKey", null));
    assertEquals(3, pref.getInt("testPutIntKey", 0));
}
Also used : Preferences(java.util.prefs.Preferences)

Example 33 with Preferences

use of java.util.prefs.Preferences in project robovm by robovm.

the class OldPreferencesTest method testGetByteArray.

public void testGetByteArray() {
    Preferences pref = Preferences.userNodeForPackage(Preferences.class);
    try {
        pref.getByteArray(null, new byte[0]);
        fail();
    } catch (NullPointerException expected) {
    }
    // BASE64
    byte[] b64Array = new byte[] { 0x59, 0x57, 0x4a, 0x6a };
    pref.put("testGetByteArrayKey", "abc=");
    pref.put("testGetByteArrayKey2", new String(b64Array));
    pref.put("invalidKey", "<>?");
    assertTrue(Arrays.equals(new byte[] { 105, -73 }, pref.getByteArray("testGetByteArrayKey", new byte[0])));
    assertTrue(Arrays.equals(new byte[] { 'a', 'b', 'c' }, pref.getByteArray("testGetByteArrayKey2", new byte[0])));
    assertTrue(Arrays.equals(new byte[0], pref.getByteArray("invalidKey", new byte[0])));
    pref.putByteArray("testGetByteArrayKey3", b64Array);
    pref.putByteArray("testGetByteArrayKey4", "abc".getBytes());
    assertTrue(Arrays.equals(b64Array, pref.getByteArray("testGetByteArrayKey3", new byte[0])));
    assertTrue(Arrays.equals("abc".getBytes(), pref.getByteArray("testGetByteArrayKey4", new byte[0])));
}
Also used : Preferences(java.util.prefs.Preferences)

Example 34 with Preferences

use of java.util.prefs.Preferences in project robovm by robovm.

the class OldPreferencesTest method testPutDouble.

public void testPutDouble() {
    Preferences pref = Preferences.userNodeForPackage(Preferences.class);
    try {
        pref.putDouble(null, 3);
        fail();
    } catch (NullPointerException expected) {
    }
    pref.putDouble(longKey, 3);
    try {
        pref.putDouble(longKey + "a", 3);
        fail();
    } catch (IllegalArgumentException expected) {
    }
    pref.putDouble("testPutDoubleKey", 3);
    assertEquals("3.0", pref.get("testPutDoubleKey", null));
    assertEquals(3, pref.getDouble("testPutDoubleKey", 0), 0);
}
Also used : Preferences(java.util.prefs.Preferences)

Example 35 with Preferences

use of java.util.prefs.Preferences in project robovm by robovm.

the class OldPreferencesTest method testPut.

public void testPut() throws BackingStoreException {
    Preferences pref = Preferences.userNodeForPackage(Preferences.class);
    pref.put("", "emptyvalue");
    assertEquals("emptyvalue", pref.get("", null));
    pref.put("testPutkey", "value1");
    assertEquals("value1", pref.get("testPutkey", null));
    pref.put("testPutkey", "value2");
    assertEquals("value2", pref.get("testPutkey", null));
    pref.put("", "emptyvalue");
    assertEquals("emptyvalue", pref.get("", null));
    try {
        pref.put(null, "value");
        fail();
    } catch (NullPointerException expected) {
    }
    try {
        pref.put("key", null);
        fail();
    } catch (NullPointerException expected) {
    }
    pref.put(longKey, longValue);
    try {
        pref.put(longKey + 1, longValue);
        fail();
    } catch (IllegalArgumentException expected) {
    }
    try {
        pref.put(longKey, longValue + 1);
        fail();
    } catch (IllegalArgumentException expected) {
    }
    pref.removeNode();
    try {
        pref.put(longKey, longValue + 1);
        fail();
    } catch (IllegalArgumentException expected) {
    }
    try {
        pref.put(longKey, longValue);
        fail();
    } catch (IllegalStateException expected) {
    }
}
Also used : Preferences(java.util.prefs.Preferences)

Aggregations

Preferences (java.util.prefs.Preferences)291 BackingStoreException (java.util.prefs.BackingStoreException)49 File (java.io.File)45 ResourceBundle (java.util.ResourceBundle)24 FileChooser (javafx.stage.FileChooser)21 ArrayList (java.util.ArrayList)17 FXML (javafx.fxml.FXML)16 IOException (java.io.IOException)14 JFileChooser (javax.swing.JFileChooser)12 List (java.util.List)8 SwingWorker (javax.swing.SwingWorker)8 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)7 Engine (jgnash.engine.Engine)7 AutoCompletePreferences (org.jabref.logic.autocompleter.AutoCompletePreferences)6 FieldContentParserPreferences (org.jabref.logic.bibtex.FieldContentParserPreferences)6 LatexFieldFormatterPreferences (org.jabref.logic.bibtex.LatexFieldFormatterPreferences)6 BibtexKeyPatternPreferences (org.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences)6 CleanupPreferences (org.jabref.logic.cleanup.CleanupPreferences)6 ImportFormatPreferences (org.jabref.logic.importer.ImportFormatPreferences)6 JournalAbbreviationPreferences (org.jabref.logic.journals.JournalAbbreviationPreferences)6