How to use same beans in Test Configuration but with different attributes?

By : Glide
Source: Stackoverflow.com
Question!

I have separate configuration classes that creates different beans per Spring Profile. I want my tests to simulate production code as much as possible so I want to use the same beans created under the Spring

By : Glide


Answers

Try something like this:

@Import(ProdConfig.class)
public class TestConfig {

    @Autowired
    private SimpleRabbitListenerContainerFactory containerFactory;

    @Bean
    RetryOperationsInterceptor interceptor() {
        ...

        this.containerFactory.setAdviceChain(interceptor);

        return interceptor;
    }

}


This video can help you solving your question :)
By: admin