6

I am writing unit test for controller.

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(classes = MyControllerWebConfig.class)
    @WebAppConfiguration
    public class MyControllerTest{
       @Autowired
        private WebApplicationContext webApplicationContext;
        ....
        @Test  
        public void testSomeThing()
        {
         // wanna do something like below:
         mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
                   .addFilter(new someFilter())
                   .addInterceptors(new MyInterceptor())
                   .build();
          ....
        }
    }

I know that addInterceptors works only with statndaloneSetup(). How can we make it work with webAppContextSetup()

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
Nish
  • 137
  • 1
  • 10

0 Answers0