We have a great application written in Spring 3. I need to write JUnit validation behavior to validate some services. This is not a unit, but part of a system. There are several services and repositories that work together - these are a lot of injected beans inside. The application also uses aspects.
My question is. How to manage configuration and beans in this test case? I need to use beans defined in application configurations, and in tests redefine beans only using persistence to work with built-in db. Therefore, I need to use beans from src, because they are defined and override only some of the causing problems (persistance beans, beans using webservices, ...) In the test package, I defined the beans configuration class for persistance using datasource for hsql. But I do not know what next. I tried to annotate a test configuration class:
@Configuration
@EnableAspectJAutoProxy
@EnableTransactionManagement(mode = AdviceMode.ASPECTJ, proxyTargetClass = true)
@ComponentScan(basePackages = "com.example.our.app")
public class MyTestConfig implements TransactionManagementConfigurer {
to scan the entire application and use the beans configuration from the src folder. But it also accepts configurations from other tests causing problems. Is this a good strategy or not? What now is to use excludeFilters to remove other test configurations? Or is this strategy generally bad?
thank
source
share