@@ -83,15 +83,15 @@ public void init() {
83
83
@ Disabled // FIXME: configdata
84
84
public void templateReplacement () throws Exception {
85
85
this .environmentRepository .setSearchLocations ("classpath:/test" );
86
- String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "template.json" , true );
86
+ String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "template.json" , true , "UTF-8" );
87
87
assertThat (replaceNewLines (resource )).matches ("\\ {\\ s*\" foo\" : \" dev_bar\" \\ s*\\ }" )
88
88
.as ("Wrong content: " + resource );
89
89
}
90
90
91
91
@ Test
92
92
public void templateReplacementNotForResolvePlaceholdersFalse () throws Exception {
93
93
this .environmentRepository .setSearchLocations ("classpath:/test" );
94
- String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "template.json" , false );
94
+ String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "template.json" , false , "UTF-8" );
95
95
assertThat (replaceNewLines (resource )).matches ("\\ {\\ s*\" foo\" : \" \\ $\\ {foo\\ }\" \\ s*\\ }" )
96
96
.as ("Wrong content: " + resource );
97
97
}
@@ -107,50 +107,64 @@ public void templateReplacementNotForBinary() throws Exception {
107
107
@ Test
108
108
public void escapedPlaceholder () throws Exception {
109
109
this .environmentRepository .setSearchLocations ("classpath:/test" );
110
- String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "placeholder.txt" , true );
110
+ String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "placeholder.txt" , true , "UTF-8" );
111
111
assertThat (resource ).isEqualToIgnoringNewLines ("foo: ${foo}" );
112
112
}
113
113
114
+ @ Test
115
+ public void charsetWrongEncoding () throws Exception {
116
+ this .environmentRepository .setSearchLocations ("classpath:/test" );
117
+ String resource = this .controller .retrieve ("foo_enc" , "bar" , "dev" , "foo_enc" , true , "ISO-8859-1" );
118
+ assertThat (resource ).isEqualToIgnoringNewLines ("foo: üäö" );
119
+ }
120
+
121
+ @ Test
122
+ public void charsetRightEncoding () throws Exception {
123
+ this .environmentRepository .setSearchLocations ("classpath:/test" );
124
+ String resource = this .controller .retrieve ("foo_enc" , "bar" , "dev" , "foo_enc" , true , "UTF-8" );
125
+ assertThat (resource ).isEqualToIgnoringNewLines ("foo: üäö" );
126
+ }
127
+
114
128
@ Test
115
129
public void applicationAndLabelPlaceholdersWithoutSlash () throws Exception {
116
130
this .environmentRepository .setSearchLocations ("classpath:/test/{application}/{label}" );
117
- String resource = this .controller .retrieve ("dev" , "bar" , "spam" , "foo.txt" , true );
131
+ String resource = this .controller .retrieve ("dev" , "bar" , "spam" , "foo.txt" , true , "UTF-8" );
118
132
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar/spam" );
119
133
}
120
134
121
135
@ Test
122
136
public void applicationPlaceholderWithSlash () throws Exception {
123
137
this .environmentRepository .setSearchLocations ("classpath:/test/{application}" );
124
- String resource = this .controller .retrieve ("dev(_)spam" , "bar" , "" , "foo.txt" , true );
138
+ String resource = this .controller .retrieve ("dev(_)spam" , "bar" , "" , "foo.txt" , true , "UTF-8" );
125
139
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar/spam" );
126
140
}
127
141
128
142
@ Test
129
143
public void applicationPlaceholderWithSlashNullLabel () throws Exception {
130
144
this .environmentRepository .setSearchLocations ("classpath:/test/{application}" );
131
- String resource = this .controller .retrieve ("dev(_)spam" , "bar" , null , "foo.txt" , true );
145
+ String resource = this .controller .retrieve ("dev(_)spam" , "bar" , null , "foo.txt" , true , "UTF-8" );
132
146
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar/spam" );
133
147
}
134
148
135
149
@ Test
136
150
public void labelPlaceholderWithSlash () throws Exception {
137
151
this .environmentRepository .setSearchLocations ("classpath:/test/{label}" );
138
- String resource = this .controller .retrieve ("dev" , "bar" , "dev(_)spam" , "foo.txt" , true );
152
+ String resource = this .controller .retrieve ("dev" , "bar" , "dev(_)spam" , "foo.txt" , true , "UTF-8" );
139
153
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar/spam" );
140
154
}
141
155
142
156
@ Test
143
157
public void profilePlaceholderNullLabel () throws Exception {
144
158
this .environmentRepository .setSearchLocations ("classpath:/test/{profile}" );
145
- String resource = this .controller .retrieve ("bar" , "dev" , null , "spam/foo.txt" , true );
159
+ String resource = this .controller .retrieve ("bar" , "dev" , null , "spam/foo.txt" , true , "UTF-8" );
146
160
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar/spam" );
147
161
}
148
162
149
163
@ Test
150
164
public void nullNameAndLabel () throws Exception {
151
165
this .environmentRepository .setSearchLocations ("classpath:/test" );
152
166
try {
153
- this .controller .retrieve (null , "foo" , "bar" , "spam/foo.txt" , true );
167
+ this .controller .retrieve (null , "foo" , "bar" , "spam/foo.txt" , true , "UTF-8" );
154
168
}
155
169
catch (Exception e ) {
156
170
assertThat (e ).isNotNull ();
@@ -160,21 +174,21 @@ public void nullNameAndLabel() throws Exception {
160
174
@ Test
161
175
public void labelWithSlash () throws Exception {
162
176
this .environmentRepository .setSearchLocations ("classpath:/test" );
163
- String resource = this .controller .retrieve ("foo" , "bar" , "dev(_)spam" , "foo.txt" , true );
177
+ String resource = this .controller .retrieve ("foo" , "bar" , "dev(_)spam" , "foo.txt" , true , "UTF-8" );
164
178
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar/spam" );
165
179
}
166
180
167
181
@ Test
168
182
public void resourceWithoutFileExtension () throws Exception {
169
183
this .environmentRepository .setSearchLocations ("classpath:/test" );
170
- String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "foo" , true );
184
+ String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "foo" , true , "UTF-8" );
171
185
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar" );
172
186
}
173
187
174
188
@ Test
175
189
public void resourceWithSlash () throws Exception {
176
190
this .environmentRepository .setSearchLocations ("classpath:/test" );
177
- String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "spam/foo.txt" , true );
191
+ String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "spam/foo.txt" , true , "UTF-8" );
178
192
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar/spam" );
179
193
}
180
194
@@ -184,7 +198,7 @@ public void resourceWithSlashRequest() throws Exception {
184
198
MockHttpServletRequest request = new MockHttpServletRequest ();
185
199
ServletWebRequest webRequest = new ServletWebRequest (request , new MockHttpServletResponse ());
186
200
request .setRequestURI ("/foo/bar/dev/" + "spam/foo.txt" );
187
- String resource = this .controller .retrieve ("foo" , "bar" , "dev" , webRequest , true );
201
+ String resource = this .controller .retrieve ("foo" , "bar" , "dev" , webRequest , true , "UTF-8" );
188
202
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar/spam" );
189
203
}
190
204
@@ -195,21 +209,21 @@ public void resourceWithSlashRequestAndServletPath() throws Exception {
195
209
ServletWebRequest webRequest = new ServletWebRequest (request , new MockHttpServletResponse ());
196
210
request .setServletPath ("/spring" );
197
211
request .setRequestURI ("/foo/bar/dev/" + "spam/foo.txt" );
198
- String resource = this .controller .retrieve ("foo" , "bar" , "dev" , webRequest , true );
212
+ String resource = this .controller .retrieve ("foo" , "bar" , "dev" , webRequest , true , "UTF-8" );
199
213
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar/spam" );
200
214
}
201
215
202
216
@ Test
203
217
public void labelWithSlashForResolvePlaceholdersFalse () throws Exception {
204
218
this .environmentRepository .setSearchLocations ("classpath:/test" );
205
- String resource = this .controller .retrieve ("foo" , "bar" , "dev(_)spam" , "foo.txt" , false );
219
+ String resource = this .controller .retrieve ("foo" , "bar" , "dev(_)spam" , "foo.txt" , false , "UTF-8" );
206
220
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar/spam" );
207
221
}
208
222
209
223
@ Test
210
224
public void resourceWithSlashForResolvePlaceholdersFalse () throws Exception {
211
225
this .environmentRepository .setSearchLocations ("classpath:/test" );
212
- String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "spam/foo.txt" , false );
226
+ String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "spam/foo.txt" , false , "UTF-8" );
213
227
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar/spam" );
214
228
}
215
229
@@ -219,7 +233,7 @@ public void resourceWithSlashForResolvePlaceholdersFalseRequest() throws Excepti
219
233
MockHttpServletRequest request = new MockHttpServletRequest ();
220
234
ServletWebRequest webRequest = new ServletWebRequest (request , new MockHttpServletResponse ());
221
235
request .setRequestURI ("/foo/bar/dev/" + "spam/foo.txt" );
222
- String resource = this .controller .retrieve ("foo" , "bar" , "dev" , webRequest , false );
236
+ String resource = this .controller .retrieve ("foo" , "bar" , "dev" , webRequest , false , "UTF-8" );
223
237
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar/spam" );
224
238
}
225
239
@@ -320,7 +334,7 @@ public void whenSupportedResourceWithDecrpyt_thenSuccess() throws Exception {
320
334
this .controller .setPlainTextEncryptEnabled (true );
321
335
322
336
// when
323
- String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "template.json" , false );
337
+ String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "template.json" , false , "UTF-8" );
324
338
325
339
// then
326
340
assertThat (resource ).isEqualTo (decryptedStr );
@@ -339,7 +353,7 @@ public void whenUnkownResourceWithDecrpyt_thenNothingChanged() throws Exception
339
353
this .controller .setPlainTextEncryptEnabled (true );
340
354
341
355
// when
342
- String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "spam/foo.txt" , false );
356
+ String resource = this .controller .retrieve ("foo" , "bar" , "dev" , "spam/foo.txt" , false , "UTF-8" );
343
357
344
358
// then
345
359
assertThat (resource ).isEqualToIgnoringNewLines ("foo: dev_bar/spam" );
0 commit comments