java - Defining a spring active profile within a test use case -


Using Spring 4, I've got the following test setup:

  @RunWith (SpringJUnit4ClassRunner.class) @ Contact Configuration (classes = JPA config class) @ Active Profile (Resolver = Test Resolver class) Public square is the simplest {}>  Public Class Test Resolver Enforce the ProfileProofile Reseller {@ Override Public Sting [] Resolution (class   

JpaConfig is annotated with the property resource

  @ property @ property source ("ClassPath: Property / App - $ {spring. Profiles.active:dev} .properties ") @EnableJpaRepositories (basePackages = {" com.my.namespace.repositories "}) public class JpaConfig {  

This address whenever I run SimpleTest Attempts to apply: Properties / Applications -dev.properties While I expect that property / application-test.properties to be.

What I'm trying to accomplish here is based on the following posts:

I believe that in fact, the problem you are facing and in it you have an explanation from Dave Sirr and a possible solution from another user. To follow Dave's advice, this would be a possible implementation of a ApplicationContextInitializer :

  Public class MyApplicationContextInitializer implements ApplicationContextInitializer   

}

and on your test class:

  @ContextConfiguration (class = JPA config.clus, initiator = MyApplicationContextInitializer. Class)   

But I would say that with suggested property files (loaded for different profiles) with different property files that the SEO post is a more elegant approach .

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -