diff --git a/spring-bootstrap/src/test/java/org/springframework/bootstrap/SpringJUnitTests.java b/spring-bootstrap/src/test/java/org/springframework/bootstrap/SpringJUnitTests.java new file mode 100644 index 0000000000..4614dd944f --- /dev/null +++ b/spring-bootstrap/src/test/java/org/springframework/bootstrap/SpringJUnitTests.java @@ -0,0 +1,64 @@ +/* + * Copyright 2012-2013 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.bootstrap; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.bootstrap.SpringJUnitTests.TestConfiguration; +import org.springframework.bootstrap.autoconfigure.PropertyPlaceholderAutoConfiguration; +import org.springframework.bootstrap.context.initializer.ConfigFileApplicationContextInitializer; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +/** + * @author Dave Syer + * + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = TestConfiguration.class, initializers = ConfigFileApplicationContextInitializer.class) +public class SpringJUnitTests { + + @Autowired + private ApplicationContext context; + + @Value("${foo:spam}") + private String foo = "bar"; + + @Test + public void testContextCreated() { + assertNotNull(this.context); + } + + @Test + public void testContextInitialized() { + assertEquals("bucket", this.foo); + } + + @Configuration + @Import({ PropertyPlaceholderAutoConfiguration.class }) + public static class TestConfiguration { + + } + +} diff --git a/spring-bootstrap/src/test/resources/application.properties b/spring-bootstrap/src/test/resources/application.properties new file mode 100644 index 0000000000..3fa3f5bae0 --- /dev/null +++ b/spring-bootstrap/src/test/resources/application.properties @@ -0,0 +1 @@ +foo: bucket \ No newline at end of file