File tree 3 files changed +67
-3
lines changed
main/java/com/superzanti/serversync/config
java/com/superzanti/serversync/config
3 files changed +67
-3
lines changed Original file line number Diff line number Diff line change @@ -114,8 +114,13 @@ public static void forServer(Path json) throws IOException {
114
114
hasMissingEntries = true ;
115
115
}
116
116
117
- String [] localeParts = getString (misc , PROP_LOCALE , "en_US" ).split ("_" );
118
- config .LOCALE = new Locale (localeParts [0 ], localeParts [1 ]);
117
+ String locale = getString (misc , PROP_LOCALE , "en_US" );
118
+ if (locale .contains ("_" )) {
119
+ String [] localeParts = getString (misc , PROP_LOCALE , "en_US" ).split ("_" );
120
+ config .LOCALE = new Locale (localeParts [0 ], localeParts [1 ]);
121
+ } else {
122
+ config .LOCALE = new Locale (locale );
123
+ }
119
124
120
125
if (hasMissingEntries ) {
121
126
// Generate a new config if we failed to read parts of it
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ void beforeEach() {
19
19
}
20
20
21
21
@ ParameterizedTest
22
- @ DisplayName ("Parsing " )
22
+ @ DisplayName ("Should parse " )
23
23
@ ValueSource (strings = {"src/test/resources/server-config.json" })
24
24
void parseServerConfig (Path file ) {
25
25
ServerSync .MODE = EServerMode .SERVER ;
@@ -36,4 +36,18 @@ void parseServerConfig(Path file) {
36
36
e .printStackTrace ();
37
37
}
38
38
}
39
+
40
+ @ ParameterizedTest
41
+ @ DisplayName ("Should parse single part locales" )
42
+ @ ValueSource (strings = {"src/test/resources/server-single-part-locale-config.json" })
43
+ void parseSinglePartLocale (Path file ) {
44
+ ServerSync .MODE = EServerMode .SERVER ;
45
+ try {
46
+ JsonConfig .forServer (file );
47
+ SyncConfig config = SyncConfig .getConfig ();
48
+ assertNotNull (config .LOCALE );
49
+ } catch (IOException e ) {
50
+ e .printStackTrace ();
51
+ }
52
+ }
39
53
}
Original file line number Diff line number Diff line change
1
+ {
2
+ "general" : {
3
+ "push_client_mods" : false ,
4
+ "sync_mode" : 2
5
+ },
6
+ "connection" : {
7
+ "port" : 38067 ,
8
+ "buffer" : 65536
9
+ },
10
+ "rules" : {
11
+ "directories" : [
12
+ {
13
+ "path" : " test-mirror" ,
14
+ "mode" : " mirror"
15
+ },
16
+ {
17
+ "path" : " test-push" ,
18
+ "mode" : " push"
19
+ },
20
+ " test-default"
21
+ ],
22
+ "files" : {
23
+ "include" : [],
24
+ "ignore" : [
25
+ {
26
+ "description" : " No jar files allowed" ,
27
+ "pattern" : " **/*.jar"
28
+ },
29
+ {
30
+ "pattern" : " **/other.bing"
31
+ },
32
+ " **/basic.thing"
33
+ ],
34
+ "redirect" : [
35
+ {
36
+ "pattern" : " **/*.jar" ,
37
+ "redirectTo" : " redirected-files"
38
+ }
39
+ ]
40
+ }
41
+ },
42
+ "misc" : {
43
+ "locale" : " en"
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments