Example usage for org.springframework.mock.web MockServletContext MockServletContext

List of usage examples for org.springframework.mock.web MockServletContext MockServletContext

Introduction

In this page you can find the example usage for org.springframework.mock.web MockServletContext MockServletContext.

Prototype

public MockServletContext() 

Source Link

Document

Create a new MockServletContext , using no base path and a DefaultResourceLoader (i.e.

Usage

From source file:org.sventon.web.ctrl.template.AbstractTemplateControllerTest.java

@Test
public void testSetAuthenticationActionUrlWithBaseUrl() throws IOException, CacheException {
    BASE_URL = "http://browser.sventon.org/svn";
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("/svn/list");
    final Map<String, Object> model = new HashMap<String, Object>();

    final AbstractTemplateController ctrl = new TestController();
    ConfigDirectory configDir = new TestConfigDirectory();
    configDir.setServletContext(new MockServletContext());
    ctrl.setApplication(new TestApplication(configDir));
    ModelAndView modelAndView = ctrl.prepareAuthenticationRequiredView(request, model);

    assertEquals("http://browser.sventon.org/svn/list", modelAndView.getModel().get("action"));
}

From source file:org.sventon.web.ctrl.template.AbstractTemplateControllerTest.java

@Test
public void testSetAuthenticationActionUrlWithoutBaseUrl() throws IOException, CacheException {
    BASE_URL = null;/* w  ww. ja v a 2s .  com*/
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("/svn/list");
    final Map<String, Object> model = new HashMap<String, Object>();

    final AbstractTemplateController ctrl = new TestController();
    ConfigDirectory configDir = new TestConfigDirectory();
    configDir.setServletContext(new MockServletContext());
    ctrl.setApplication(new TestApplication(configDir));
    ModelAndView modelAndView = ctrl.prepareAuthenticationRequiredView(request, model);

    assertEquals("http://localhost:80/svn/list", modelAndView.getModel().get("action"));
}