Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
corewars-library
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
st-praktikum16-g1
corewars-library
Commits
3cbd4bb2
Commit
3cbd4bb2
authored
Sep 30, 2016
by
matthias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work on new tests load/save config
parent
e915ab16
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
10 deletions
+13
-10
src/main/java/gone/lib/config/SaveConfigFile.java
src/main/java/gone/lib/config/SaveConfigFile.java
+4
-8
src/test/java/gone/lib/network/config/ClientConfigTest.java
src/test/java/gone/lib/network/config/ClientConfigTest.java
+8
-0
src/test/java/gone/lib/network/config/ServerConfigTest.java
src/test/java/gone/lib/network/config/ServerConfigTest.java
+1
-2
No files found.
src/main/java/gone/lib/config/SaveConfigFile.java
View file @
3cbd4bb2
...
...
@@ -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
());
...
...
src/test/java/gone/lib/network/config/ClientConfigTest.java
View file @
3cbd4bb2
...
...
@@ -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
src/test/java/gone/lib/network/config/ServerConfigTest.java
View file @
3cbd4bb2
...
...
@@ -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
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment