Code example for XmlWebApplicationContext

Methods: getBean, refresh, setConfigLocation, setServletContext

0
        "JwIDAQAB\n" + 
        "-----END PUBLIC KEY-----"; 
 
    @Before 
    public void setUp() throws Exception { 
        webApplicationContext = new XmlWebApplicationContext(); 
        webApplicationContext.setServletContext(new MockServletContext()); 
        new YamlServletProfileInitializer().initialize(webApplicationContext); 
        webApplicationContext.setConfigLocation("file:./src/main/webapp/WEB-INF/spring-servlet.xml"); 
        webApplicationContext.refresh(); 
        FilterChainProxy springSecurityFilterChain = webApplicationContext.getBean(FilterChainProxy.class); 
 
        mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).addFilter(springSecurityFilterChain) 
            .build(); 
        testClient = new TestClient(mockMvc); 
 
        SignerProvider provider = webApplicationContext.getBean(SignerProvider.class); 
        provider.setSigningKey(signKey); 
        provider.setVerifierKey(verifyKey); 
        provider.afterPropertiesSet(); 
 
        testClient = new TestClient(mockMvc);