Java Code Examples for org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#handleRequest()

The following examples show how to use org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#handleRequest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultServletHandlerConfigurerTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void enable() throws Exception {
	configurer.enable();
	SimpleUrlHandlerMapping getHandlerMapping = getHandlerMapping();
	SimpleUrlHandlerMapping handlerMapping = getHandlerMapping;
	DefaultServletHttpRequestHandler handler = (DefaultServletHttpRequestHandler) handlerMapping.getUrlMap().get("/**");

	assertNotNull(handler);
	assertEquals(Integer.MAX_VALUE, handlerMapping.getOrder());

	handler.handleRequest(new MockHttpServletRequest(), response);

	String expected = "default";
	assertEquals("The ServletContext was not called with the default servlet name", expected, servletContext.url);
	assertEquals("The request was not forwarded", expected, response.getForwardedUrl());
}
 
Example 2
Source File: DefaultServletHandlerConfigurerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void enable() throws Exception {
	configurer.enable();
	SimpleUrlHandlerMapping handlerMapping = configurer.buildHandlerMapping();
	DefaultServletHttpRequestHandler handler = (DefaultServletHttpRequestHandler) handlerMapping.getUrlMap().get("/**");

	assertNotNull(handler);
	assertEquals(Integer.MAX_VALUE, handlerMapping.getOrder());

	handler.handleRequest(new MockHttpServletRequest(), response);

	String expected = "default";
	assertEquals("The ServletContext was not called with the default servlet name", expected, servletContext.url);
	assertEquals("The request was not forwarded", expected, response.getForwardedUrl());
}
 
Example 3
Source File: DefaultServletHandlerConfigurerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void enableWithServletName() throws Exception {
	configurer.enable("defaultServlet");
	SimpleUrlHandlerMapping handlerMapping = configurer.buildHandlerMapping();
	DefaultServletHttpRequestHandler handler = (DefaultServletHttpRequestHandler) handlerMapping.getUrlMap().get("/**");

	assertNotNull(handler);
	assertEquals(Integer.MAX_VALUE, handlerMapping.getOrder());

	handler.handleRequest(new MockHttpServletRequest(), response);

	String expected = "defaultServlet";
	assertEquals("The ServletContext was not called with the default servlet name", expected, servletContext.url);
	assertEquals("The request was not forwarded", expected, response.getForwardedUrl());
}
 
Example 4
Source File: DefaultServletHandlerConfigurerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void enable() throws Exception {
	configurer.enable();
	SimpleUrlHandlerMapping handlerMapping = configurer.buildHandlerMapping();
	DefaultServletHttpRequestHandler handler = (DefaultServletHttpRequestHandler) handlerMapping.getUrlMap().get("/**");

	assertNotNull(handler);
	assertEquals(Integer.MAX_VALUE, handlerMapping.getOrder());

	handler.handleRequest(new MockHttpServletRequest(), response);

	String expected = "default";
	assertEquals("The ServletContext was not called with the default servlet name", expected, servletContext.url);
	assertEquals("The request was not forwarded", expected, response.getForwardedUrl());
}
 
Example 5
Source File: DefaultServletHandlerConfigurerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void enableWithServletName() throws Exception {
	configurer.enable("defaultServlet");
	SimpleUrlHandlerMapping handlerMapping = configurer.buildHandlerMapping();
	DefaultServletHttpRequestHandler handler = (DefaultServletHttpRequestHandler) handlerMapping.getUrlMap().get("/**");

	assertNotNull(handler);
	assertEquals(Integer.MAX_VALUE, handlerMapping.getOrder());

	handler.handleRequest(new MockHttpServletRequest(), response);

	String expected = "defaultServlet";
	assertEquals("The ServletContext was not called with the default servlet name", expected, servletContext.url);
	assertEquals("The request was not forwarded", expected, response.getForwardedUrl());
}
 
Example 6
Source File: DefaultServletHandlerConfigurerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void enableWithServletName() throws Exception {
	configurer.enable("defaultServlet");
	SimpleUrlHandlerMapping handlerMapping = getHandlerMapping();
	DefaultServletHttpRequestHandler handler = (DefaultServletHttpRequestHandler) handlerMapping.getUrlMap().get("/**");

	assertNotNull(handler);
	assertEquals(Integer.MAX_VALUE, handlerMapping.getOrder());

	handler.handleRequest(new MockHttpServletRequest(), response);

	String expected = "defaultServlet";
	assertEquals("The ServletContext was not called with the default servlet name", expected, servletContext.url);
	assertEquals("The request was not forwarded", expected, response.getForwardedUrl());
}