extended settingstest to check new setting-attributes

This commit is contained in:
infeo
2018-02-03 22:18:28 +01:00
parent 8a359704ca
commit a2f6a85334
4 changed files with 37 additions and 30 deletions
@@ -2,7 +2,7 @@
* Copyright (c) 2014, 2017 Sebastian Stenzel
* All rights reserved.
* This program and the accompanying materials are made available under the terms of the accompanying LICENSE file.
*
*
* Contributors:
* Sebastian Stenzel - initial API and implementation
******************************************************************************/
@@ -31,7 +31,7 @@ public class Settings {
public static final String DEFAULT_GVFS_SCHEME = "dav";
public static final boolean DEFAULT_DEBUG_MODE = false;
public static final String DEFAULT_DEFAULT_MOUNT_DIR = System.getProperty("user.home");
public static final String DEFAULT_NIO_ADAPTER = "WEBDAV";
public static final String DEFAULT_NIO_ADAPTER = "webdav";
private final ObservableList<VaultSettings> directories = FXCollections.observableArrayList(VaultSettings::observables);
private final BooleanProperty checkForUpdates = new SimpleBooleanProperty(DEFAULT_CHECK_FOR_UDPATES);
@@ -27,6 +27,7 @@ class VaultSettingsJsonAdapter {
out.name("unlockAfterStartup").value(value.unlockAfterStartup().get());
out.name("mountAfterUnlock").value(value.mountAfterUnlock().get());
out.name("revealAfterMount").value(value.revealAfterMount().get());
out.name("mountPath").value(value.mountPath().get());
out.endObject();
}
@@ -44,32 +45,33 @@ class VaultSettingsJsonAdapter {
while (in.hasNext()) {
String name = in.nextName();
switch (name) {
case "id":
id = in.nextString();
break;
case "path":
path = in.nextString();
break;
case "mountName":
mountName = in.nextString();
break;
case "winDriveLetter":
winDriveLetter = in.nextString();
break;
case "unlockAfterStartup":
unlockAfterStartup = in.nextBoolean();
break;
case "mountAfterUnlock":
mountAfterUnlock = in.nextBoolean();
break;
case "revealAfterMount":
revealAfterMount = in.nextBoolean();
break;
case "mountPath":
mountPath = in.nextString();
default:
LOG.warn("Unsupported vault setting found in JSON: " + name);
in.skipValue();
case "id":
id = in.nextString();
break;
case "path":
path = in.nextString();
break;
case "mountName":
mountName = in.nextString();
break;
case "winDriveLetter":
winDriveLetter = in.nextString();
break;
case "unlockAfterStartup":
unlockAfterStartup = in.nextBoolean();
break;
case "mountAfterUnlock":
mountAfterUnlock = in.nextBoolean();
break;
case "revealAfterMount":
revealAfterMount = in.nextBoolean();
break;
case "mountPath":
mountPath = in.nextString();
break;
default:
LOG.warn("Unsupported vault setting found in JSON: " + name);
in.skipValue();
}
}
in.endObject();
@@ -22,7 +22,9 @@ public class SettingsJsonAdapterTest {
+ "\"checkForUpdatesEnabled\": true,"//
+ "\"port\": 8080,"//
+ "\"useIpv6\": true,"//
+ "\"numTrayNotifications\": 42}";
+ "\"numTrayNotifications\": 42,"//
+ "\"nioAdapterImpl\": \"webdav\","//
+ "\"defaultMountDir\": \"/home/test/crypto\"}";
Settings settings = adapter.fromJson(json);
@@ -32,6 +34,8 @@ public class SettingsJsonAdapterTest {
// Assert.assertTrue(settings.useIpv6().get()); temporarily ignored
Assert.assertEquals(42, settings.numTrayNotifications().get());
Assert.assertEquals("dav", settings.preferredGvfsScheme().get());
Assert.assertEquals("webdav", settings.usedNioAdapterImpl().get());
Assert.assertEquals("/home/test/crypto", settings.defaultMountDir().get());
}
}
@@ -20,7 +20,7 @@ public class VaultSettingsJsonAdapterTest {
@Test
public void testDeserialize() throws IOException {
String json = "{\"id\": \"foo\", \"path\": \"/foo/bar\", \"mountName\": \"test\", \"winDriveLetter\": \"X\", \"shouldBeIgnored\": true}";
String json = "{\"id\": \"foo\", \"path\": \"/foo/bar\", \"mountName\": \"test\", \"winDriveLetter\": \"X\", \"shouldBeIgnored\": true, \"mountPath\": \"/home/test/crypto\"}";
JsonReader jsonReader = new JsonReader(new StringReader(json));
VaultSettings vaultSettings = adapter.read(jsonReader);
@@ -28,6 +28,7 @@ public class VaultSettingsJsonAdapterTest {
Assert.assertEquals(Paths.get("/foo/bar"), vaultSettings.path().get());
Assert.assertEquals("test", vaultSettings.mountName().get());
Assert.assertEquals("X", vaultSettings.winDriveLetter().get());
Assert.assertEquals("/home/test/crypto", vaultSettings.mountPath().get());
}
}