Commit 3cbd4bb2 authored by matthias's avatar matthias

work on new tests load/save config

parent e915ab16
......@@ -42,16 +42,14 @@ public class SaveConfigFile {
private void saveClientConfig(ClientConfig params, String userFilePath, String nodeName)
throws IllegalArgumentException, IOException {
File input = new File(userFilePath);
if (!input.exists()) {
input.getParentFile().mkdirs();
}
if (userFilePath.isEmpty()) {
throw new IllegalArgumentException("user file path should not be empty!");
}
// TODO: same as load config, use relative path to ~/.config
File input = new File(userFilePath);
if (!input.exists()) {
input.getParentFile().mkdirs();
}
Preferences userPrefs = Preferences.userRoot().node(nodeName);
......@@ -92,8 +90,6 @@ public class SaveConfigFile {
input.getParentFile().mkdirs();
}
Preferences userPrefs = Preferences.userRoot().node(nodeName);
userPrefs.putInt("MAX_START_INSTRUCTIONS_COUNT", params.getMaxStartInstructions());
userPrefs.putInt("MAX_PLAYER_COUNT", params.getMaxPlayersCount());
......
......@@ -174,4 +174,12 @@ public class ClientConfigTest {
new ClientConfig(640, 400, "bernd", "", InetAddress.getByName("localhost"), 999999,
RcStandard.ICWS88, Language.de);
}
@Test
public void saveClientConfig_EmptyPath() throws IOException {
thrown.expect(IllegalArgumentException.class);
ClientConfig conf = new ClientConfig(640, 400, "bernd", System.getProperty("user.home"),
InetAddress.getByName("localhost"), 1000, RcStandard.ICWS88, Language.de);
new SaveConfigFile(conf, "", ConfigTypes.CLIENT_CONFIG);
}
}
\ No newline at end of file
......@@ -103,10 +103,9 @@ public class ServerConfigTest {
}
@Test
public void saveServerConfig() throws IOException {
public void saveServerConfig_EmptyPath() throws IOException {
thrown.expect(IllegalArgumentException.class);
ServerConfig params = new ServerConfig(3000, 1000, 1337, 2, 8000, 100);
new SaveConfigFile(params, "", ConfigTypes.SERVER_CONFIG);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment