36
36
* @since 3.1
37
37
*/
38
38
public class PropertySourcesPropertyResolverTests {
39
+
39
40
private Properties testProperties ;
41
+
40
42
private MutablePropertySources propertySources ;
43
+
41
44
private ConfigurablePropertyResolver propertyResolver ;
42
45
46
+
43
47
@ Before
44
48
public void setUp () {
45
49
propertySources = new MutablePropertySources ();
@@ -48,6 +52,7 @@ public void setUp() {
48
52
propertySources .addFirst (new PropertiesPropertySource ("testProperties" , testProperties ));
49
53
}
50
54
55
+
51
56
@ Test
52
57
public void containsProperty () {
53
58
assertThat (propertyResolver .containsProperty ("foo" ), is (false ));
@@ -103,7 +108,6 @@ public void getProperty_withStringArrayConversion() {
103
108
assertThat (propertyResolver .getProperty ("foo" , String [].class ), equalTo (new String [] { "bar" , "baz" }));
104
109
}
105
110
106
-
107
111
@ Test
108
112
public void getProperty_withNonConvertibleTargetType () {
109
113
testProperties .put ("foo" , "bar" );
@@ -113,7 +117,8 @@ class TestType { }
113
117
try {
114
118
propertyResolver .getProperty ("foo" , TestType .class );
115
119
fail ("Expected IllegalArgumentException due to non-convertible types" );
116
- } catch (IllegalArgumentException ex ) {
120
+ }
121
+ catch (IllegalArgumentException ex ) {
117
122
// expected
118
123
}
119
124
}
@@ -172,7 +177,8 @@ public void getRequiredProperty() {
172
177
try {
173
178
propertyResolver .getRequiredProperty ("bogus" );
174
179
fail ("expected IllegalStateException" );
175
- } catch (IllegalStateException ex ) {
180
+ }
181
+ catch (IllegalStateException ex ) {
176
182
// expected
177
183
}
178
184
}
@@ -185,7 +191,8 @@ public void getRequiredProperty_withStringArrayConversion() {
185
191
try {
186
192
propertyResolver .getRequiredProperty ("bogus" , String [].class );
187
193
fail ("expected IllegalStateException" );
188
- } catch (IllegalStateException ex ) {
194
+ }
195
+ catch (IllegalStateException ex ) {
189
196
// expected
190
197
}
191
198
}
@@ -327,7 +334,8 @@ public void setRequiredProperties_andValidateRequiredProperties() {
327
334
try {
328
335
propertyResolver .validateRequiredProperties ();
329
336
fail ("expected validation exception" );
330
- } catch (MissingRequiredPropertiesException ex ) {
337
+ }
338
+ catch (MissingRequiredPropertiesException ex ) {
331
339
assertThat (ex .getMessage (), equalTo (
332
340
"The following properties were declared as required " +
333
341
"but could not be resolved: [foo, bar]" ));
@@ -338,7 +346,8 @@ public void setRequiredProperties_andValidateRequiredProperties() {
338
346
try {
339
347
propertyResolver .validateRequiredProperties ();
340
348
fail ("expected validation exception" );
341
- } catch (MissingRequiredPropertiesException ex ) {
349
+ }
350
+ catch (MissingRequiredPropertiesException ex ) {
342
351
assertThat (ex .getMessage (), equalTo (
343
352
"The following properties were declared as required " +
344
353
"but could not be resolved: [bar]" ));
@@ -369,14 +378,16 @@ public void resolveNestedPropertyPlaceholders() {
369
378
assertThat (pr .getProperty ("p4" ), equalTo ("v1:v2" ));
370
379
try {
371
380
pr .getProperty ("p5" );
372
- } catch (IllegalArgumentException ex ) {
381
+ }
382
+ catch (IllegalArgumentException ex ) {
373
383
assertThat (ex .getMessage (), containsString (
374
- "Could not resolve placeholder 'bogus' in string value [ ${p1}:${p2}:${bogus}] " ));
384
+ "Could not resolve placeholder 'bogus' in string value \" ${p1}:${p2}:${bogus}\" " ));
375
385
}
376
386
assertThat (pr .getProperty ("p6" ), equalTo ("v1:v2:def" ));
377
387
try {
378
388
pr .getProperty ("pL" );
379
- } catch (StackOverflowError ex ) {
389
+ }
390
+ catch (StackOverflowError ex ) {
380
391
// no explicit handling for cyclic references for now
381
392
}
382
393
}
@@ -399,9 +410,10 @@ public void ignoreUnresolvableNestedPlaceholdersIsConfigurable() {
399
410
// exception by default
400
411
try {
401
412
pr .getProperty ("p4" );
402
- } catch (IllegalArgumentException ex ) {
413
+ }
414
+ catch (IllegalArgumentException ex ) {
403
415
assertThat (ex .getMessage (), containsString (
404
- "Could not resolve placeholder 'bogus' in string value [ ${p1}:${p2}:${bogus}] " ));
416
+ "Could not resolve placeholder 'bogus' in string value \" ${p1}:${p2}:${bogus}\" " ));
405
417
}
406
418
407
419
// relax the treatment of unresolvable nested placeholders
@@ -414,13 +426,18 @@ public void ignoreUnresolvableNestedPlaceholdersIsConfigurable() {
414
426
assertThat (pr .resolvePlaceholders ("${p1}:${p2}:${bogus}" ), equalTo ("v1:v2:${bogus}" ));
415
427
try {
416
428
pr .resolveRequiredPlaceholders ("${p1}:${p2}:${bogus}" );
417
- } catch (IllegalArgumentException ex ) {
429
+ }
430
+ catch (IllegalArgumentException ex ) {
418
431
assertThat (ex .getMessage (), containsString (
419
- "Could not resolve placeholder 'bogus' in string value [ ${p1}:${p2}:${bogus}] " ));
432
+ "Could not resolve placeholder 'bogus' in string value \" ${p1}:${p2}:${bogus}\" " ));
420
433
}
421
434
}
422
435
423
436
424
- static interface SomeType { }
425
- static class SpecificType implements SomeType { }
437
+ interface SomeType {
438
+ }
439
+
440
+ static class SpecificType implements SomeType {
441
+ }
442
+
426
443
}
0 commit comments