From 67934a22e2f77449dc1fd8e614028e3d42e20e81 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 12 Feb 2015 20:24:06 +0100 Subject: [PATCH] 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] https://github.com/spring-projects/spring-boot/issues/1110 Issue: SPR-12710 --- .../InlinedPropertiesTestPropertySourceTests.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spring-test/src/test/java/org/springframework/test/context/env/InlinedPropertiesTestPropertySourceTests.java b/spring-test/src/test/java/org/springframework/test/context/env/InlinedPropertiesTestPropertySourceTests.java index efe240e574..a1721e854a 100644 --- a/spring-test/src/test/java/org/springframework/test/context/env/InlinedPropertiesTestPropertySourceTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/env/InlinedPropertiesTestPropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,9 @@ import static org.junit.Assert.*; */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration -@TestPropertySource(properties = { "foo = bar", "enigma: 42" }) +@TestPropertySource(properties = { "foo = bar", "baz quux", "enigma: 42", + "x.y.z = a=b=c", "server.url = http://example.com", "key.value.1: key=value", + "key.value.2 key=value", "key.value.3 key:value" }) public class InlinedPropertiesTestPropertySourceTests { @Autowired @@ -47,7 +49,13 @@ public class InlinedPropertiesTestPropertySourceTests { @Test public void verifyPropertiesAreAvailableInEnvironment() { assertEquals("bar", env.getProperty("foo")); + assertEquals("quux", env.getProperty("baz")); assertEquals(42, env.getProperty("enigma", Integer.class).intValue()); + assertEquals("a=b=c", env.getProperty("x.y.z")); + assertEquals("http://example.com", env.getProperty("server.url")); + assertEquals("key=value", env.getProperty("key.value.1")); + assertEquals("key=value", env.getProperty("key.value.2")); + assertEquals("key:value", env.getProperty("key.value.3")); }