خرید بک لینک

Vote count: 0

I have an own custom BeanFactory:

class MyListableBeanFactory extends DefaultListableBeanFactory {...}

and an ApplicationContext:

public class MyAppContext extends AotationConfigApplicationContext {

    public MyApplicationContext () {
        super(new MyListableBeanFactory ());
    }
}

and this bootstrap code:

@SpringBootApplication
public class DemoApplication {

public static void main(String[] args) {
        SpringApplicationBuilder application = new SpringApplicationBuilder();
        application.sources(DemoApplication.class);
        application.contextClass(MyAppContext.class);
        ConfigurableApplicationContext context = application.build().run(args);
        //...
    }
}

So far, everything is fine.

Now, I have a Test class as well:

@RunWith(SpringJUnit4ClassRuer.class)
@SpringApplicationConfiguration(classes = {DemoApplication.class})
@IntegrationTest
public class MyTest {
    // ...
}

with some test methods which test some overridden behavior from my custom application context logic.

However, that configuration doesn't bootstrap the custom ApplicationContext configured in the main method via SpringApplicationBuilder

How can I "tell Spring" to mimic that bootstrap code for my tests as well? i.e. using the custom context for tests as well.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 3 خرداد 1395 ساعت: 0:16

صفحه بندی