/*
 * Copyright 2002-2014 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.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.test.context.env;

import org.junit.Test;
import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import static org.junit.Assert.*;

/**
 * Integration tests for {@link TestPropertySource @TestPropertySource}
 * support with an inlined properties.
 *
 * @author Sam Brannen
 * @since 4.1
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@TestPropertySource(properties = { "foo = bar", "enigma: 42" })
public class InlinedPropertiesTestPropertySourceTests {

	@Autowired
	protected Environment env;


	@Test
	public void verifyPropertiesAreAvailableInEnvironment() {
		assertEquals("bar", env.getProperty("foo"));
		assertEquals(42, env.getProperty("enigma", Integer.class).intValue());
	}


	// -------------------------------------------------------------------

	@Configuration
	static class Config {
		/* no user beans required for these tests */
	}

}

@@ -17,17 +17,17 @@
 2002-201
-4
+5
  the ori
@@ -1396,18 +1396,160 @@
 %22, %22
-enigma: 42
+baz quux%22, %22enigma: 42%22,%0A%09%22x.y.z = a=b=c%22, %22server.url = http://example.com%22, %22key.value.1: key=value%22,%0A%09%22key.value.2 key=value%22, %22key.value.3 key:value
 %22 %7D)
@@ -1761,16 +1761,64 @@
 foo%22));%0A
+%09%09assertEquals(%22quux%22, env.getProperty(%22baz%22));%0A
 %09%09assert
@@ -1882,16 +1882,319 @@
 lue());%0A
+%09%09assertEquals(%22a=b=c%22, env.getProperty(%22x.y.z%22));%0A%09%09assertEquals(%22http://example.com%22, env.getProperty(%22server.url%22));%0A%09%09assertEquals(%22key=value%22, env.getProperty(%22key.value.1%22));%0A%09%09assertEquals(%22key=value%22, env.getProperty(%22key.value.2%22));%0A%09%09assertEquals(%22key:value%22, env.getProperty(%22key.value.3%22));%0A
 %09%7D%0A%0A%0A%09//

Add further regression tests for @TestPropertySource