Code example for XmlWebApplicationContext

Methods: getBean, refresh, setConfigLocations, setServletContext

0
	private HandlerMapping hm4; 
 
	@Override 
	public void setUp() throws Exception { 
		MockServletContext sc = new MockServletContext(""); 
		this.wac = new XmlWebApplicationContext(); 
		this.wac.setServletContext(sc); 
		this.wac.setConfigLocations(new String[] {LOCATION}); 
		this.wac.refresh(); 
		this.hm = (HandlerMapping) this.wac.getBean("mapping"); 
		this.hm2 = (HandlerMapping) this.wac.getBean("mapping2"); 
		this.hm3 = (HandlerMapping) this.wac.getBean("mapping3"); 
		this.hm4 = (HandlerMapping) this.wac.getBean("mapping4"); 
	} 
 
	public void testIndexUri() throws Exception { 
		MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); 
		HandlerExecutionChain chain = this.hm.getHandler(request); 
		assertEquals(this.wac.getBean("index"), chain.getHandler()); 
	}