Announcement Announcement Module
Collapse
No announcement yet.
Spring Test and ContextLoaderListener Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Test and ContextLoaderListener

    Hi, I have a Controller that invokes a class who is using ContextLoaderListener as follow:
    Code:
     
    private static WebApplicationContext context= ContextLoaderListener.getCurrentWebApplicationContext();
    And then with static context I injects a bean as follow (it's an abstract class):
    Code:
    context.getAutowireCapableBeanFactory().autowireBean(this);
    This is working fine but when I run my controller test, even using @WebAppConfiguration annotation, context is null. I have injected in my test case WebApplicationContext with succeed (it is not null).
    How can I use ContextLoaderListener in a test case or how can I replace it to get the current WebApplicationContext, even if I running a junit test?
    Is possible that the webAppConfiguration is not loading? how can I be sure of that?

    Thanks
Working...
X