Skip to content

Commit 67934a2

Browse files
committed
Add further regression tests for @TestPropertySource
This commit introduces further regression tests to ensure proper parsing of inlined properties configured via @TestPropertySource. Specifically, these additional tests ensure that we do not introduce a bug like the one raised in Spring Boot issue #1110 [0]. [0] spring-projects/spring-boot#1110 Issue: SPR-12710
1 parent ef75bd8 commit 67934a2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

spring-test/src/test/java/org/springframework/test/context/env/InlinedPropertiesTestPropertySourceTests.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,7 +37,9 @@
3737
*/
3838
@RunWith(SpringJUnit4ClassRunner.class)
3939
@ContextConfiguration
40-
@TestPropertySource(properties = { "foo = bar", "enigma: 42" })
40+
@TestPropertySource(properties = { "foo = bar", "baz quux", "enigma: 42",
41+
"x.y.z = a=b=c", "server.url = http://example.com", "key.value.1: key=value",
42+
"key.value.2 key=value", "key.value.3 key:value" })
4143
public class InlinedPropertiesTestPropertySourceTests {
4244

4345
@Autowired
@@ -47,7 +49,13 @@ public class InlinedPropertiesTestPropertySourceTests {
4749
@Test
4850
public void verifyPropertiesAreAvailableInEnvironment() {
4951
assertEquals("bar", env.getProperty("foo"));
52+
assertEquals("quux", env.getProperty("baz"));
5053
assertEquals(42, env.getProperty("enigma", Integer.class).intValue());
54+
assertEquals("a=b=c", env.getProperty("x.y.z"));
55+
assertEquals("http://example.com", env.getProperty("server.url"));
56+
assertEquals("key=value", env.getProperty("key.value.1"));
57+
assertEquals("key=value", env.getProperty("key.value.2"));
58+
assertEquals("key:value", env.getProperty("key.value.3"));
5159
}
5260

5361

0 commit comments

Comments
 (0)