Add @SpringApplicationConfiguration (for integration testing)

Example:

    @RunWith(SpringJUnit4ClassRunner.class)
    @SpringApplicationConfiguration(classes = SampleDataJpaApplication.class)
    public class CityRepositoryIntegrationTests {

    	@Autowired
    	CityRepository repository;

Fixes gh-66.
This commit is contained in:
Dave Syer
2013-11-28 14:35:36 +00:00
parent 3e5e058b02
commit 3e6c1b435f
6 changed files with 91 additions and 20 deletions

View File

@@ -0,0 +1,76 @@
/*
* 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.boot.test;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.ContextConfiguration;
/**
* @author Dave Syer
*/
@ContextConfiguration(loader = SpringApplicationContextLoader.class)
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SpringApplicationConfiguration {
/**
* @see ContextConfiguration#value()
*/
String[] value() default {};
/**
* @see ContextConfiguration#locations()
*/
String[] locations() default {};
/**
* @see ContextConfiguration#classes()
*/
Class<?>[] classes() default {};
/**
* @see ContextConfiguration#initializers()
*/
Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers() default {};
/**
* @see ContextConfiguration#inheritLocations()
*/
boolean inheritLocations() default true;
/**
* @see ContextConfiguration#inheritInitializers()
*/
boolean inheritInitializers() default true;
/**
* @see ContextConfiguration#name()
*/
String name() default "";
}