Package org.springframework.mock.web.test

Examples of org.springframework.mock.web.test.MockServletContext


  }

  @Test
  public void nestedViewResolverIsNotSpringBean() throws Exception {
    StaticWebApplicationContext webAppContext = new StaticWebApplicationContext();
    webAppContext.setServletContext(new MockServletContext());
    webAppContext.refresh();

    InternalResourceViewResolver nestedResolver = new InternalResourceViewResolver();
    nestedResolver.setApplicationContext(webAppContext);
    nestedResolver.setViewClass(InternalResourceView.class);
View Full Code Here


  private ConfigurableWebApplicationContext wac;

  @Override
  public void setUp() throws Exception {
    MockServletContext sc = new MockServletContext("");
    wac = new XmlWebApplicationContext();
    wac.setServletContext(sc);
    wac.setConfigLocations(new String[] {CONF});
    wac.refresh();
  }
View Full Code Here

  private HandlerMapping hm;

  @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");
View Full Code Here

  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");
View Full Code Here

*/
public class SimpleUrlHandlerMappingTests {

  @Test
  public void handlerBeanNotFound() throws Exception {
    MockServletContext sc = new MockServletContext("");
    XmlWebApplicationContext root = new XmlWebApplicationContext();
    root.setServletContext(sc);
    root.setConfigLocations(new String[] {"/org/springframework/web/servlet/handler/map1.xml"});
    root.refresh();
    XmlWebApplicationContext wac = new XmlWebApplicationContext();
View Full Code Here


  @Before
  public void setUp() throws Exception {
    wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());

    // final Template expectedTemplate = new Template();
    fc = new FreeMarkerConfigurer();
    fc.setTemplateLoaderPaths(new String[] { "classpath:/", "file://" + System.getProperty("java.io.tmpdir") });
    fc.afterPropertiesSet();
View Full Code Here

    FreeMarkerView view = new FreeMarkerView();
    view.setBeanName("myView");
    view.setUrl("tmp.ftl");
    view.setExposeSpringMacroHelpers(false);
    view.setConfiguration(config);
    view.setServletContext(new MockServletContext());

    view.render(model, request, response);

    // tokenize output and ignore whitespace
    String output = response.getContentAsString();
View Full Code Here

  public void testNoFreeMarkerConfig() throws Exception {
    FreeMarkerView fv = new FreeMarkerView();

    WebApplicationContext wac = mock(WebApplicationContext.class);
    given(wac.getBeansOfType(FreeMarkerConfig.class, true, false)).willReturn(new HashMap<String, FreeMarkerConfig>());
    given(wac.getServletContext()).willReturn(new MockServletContext());

    fv.setUrl("anythingButNull");
    try {
      fv.setApplicationContext(wac);
      fv.afterPropertiesSet();
View Full Code Here

  @Test
  public void testValidTemplateName() throws Exception {
    FreeMarkerView fv = new FreeMarkerView();

    WebApplicationContext wac = mock(WebApplicationContext.class);
    MockServletContext sc = new MockServletContext();

    Map configs = new HashMap();
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    configurer.setConfiguration(new TestConfiguration());
    configs.put("configurer", configurer);
View Full Code Here

  @Test
  public void testKeepExistingContentType() throws Exception {
    FreeMarkerView fv = new FreeMarkerView();

    WebApplicationContext wac = mock(WebApplicationContext.class);
    MockServletContext sc = new MockServletContext();

    Map configs = new HashMap();
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    configurer.setConfiguration(new TestConfiguration());
    configs.put("configurer", configurer);
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.test.MockServletContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.