Add test for Spring integration tests

This commit is contained in:
Dave Syer 2013-06-20 13:55:34 +01:00
parent 56bfa30b2c
commit f3cb6d46ce
2 changed files with 65 additions and 0 deletions

View File

@ -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 {
}
}

View File

@ -0,0 +1 @@
foo: bucket