Package org.springframework.mock.web.test

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


    }
  }

  @Test
  public void testContextLoaderWithInvalidContext() throws Exception {
    MockServletContext sc = new MockServletContext("");
    sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM,
        "org.springframework.web.context.support.InvalidWebApplicationContext");
    ServletContextListener listener = new ContextLoaderListener();
    ServletContextEvent event = new ServletContextEvent(sc);
    try {
      listener.contextInitialized(event);
View Full Code Here


    }
  }

  @Test
  public void testContextLoaderWithDefaultLocation() throws Exception {
    MockServletContext sc = new MockServletContext("");
    ServletContextListener listener = new ContextLoaderListener();
    ServletContextEvent event = new ServletContextEvent(sc);
    try {
      listener.contextInitialized(event);
      fail("Should have thrown BeanDefinitionStoreException");
View Full Code Here

  @Test
  public void testFrameworkServletWithDefaultLocation() throws Exception {
    DispatcherServlet servlet = new DispatcherServlet();
    servlet.setContextClass(XmlWebApplicationContext.class);
    try {
      servlet.init(new MockServletConfig(new MockServletContext(""), "test"));
      fail("Should have thrown BeanDefinitionStoreException");
    }
    catch (BeanDefinitionStoreException ex) {
      // expected
      assertTrue(ex.getCause() instanceof IOException);
View Full Code Here

  @Test
  public void testFrameworkServletWithCustomLocation() throws Exception {
    DispatcherServlet servlet = new DispatcherServlet();
    servlet.setContextConfigLocation("/org/springframework/web/context/WEB-INF/testNamespace.xml "
        + "/org/springframework/web/context/WEB-INF/context-addition.xml");
    servlet.init(new MockServletConfig(new MockServletContext(""), "test"));
    assertTrue(servlet.getWebApplicationContext().containsBean("kerry"));
    assertTrue(servlet.getWebApplicationContext().containsBean("kerryX"));
  }
View Full Code Here

    rb.setBasename(PROPS_FILE);
    rb.setCache(getCache());
    rb.setDefaultParentView("testParent");

    wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    wac.refresh();

    // This will be propagated to views, so we need it.
    rb.setApplicationContext(wac);
  }
View Full Code Here

  private static final String NAME = "scoped";


  private ConfigurablePortletApplicationContext initApplicationContext(String scope) {
    MockServletContext sc = new MockServletContext();
    GenericWebApplicationContext rac = new GenericWebApplicationContext(sc);
    rac.refresh();
    PortletContext pc = new ServletWrappingPortletContext(sc);
    StaticPortletApplicationContext ac = new StaticPortletApplicationContext();
    ac.setParent(rac);
View Full Code Here

  }

  @Test
  public void testConfigureExporterParametersWithEncodingFromPropertiesFile() throws Exception {
    GenericWebApplicationContext ac = new GenericWebApplicationContext();
    ac.setServletContext(new MockServletContext());
    BeanDefinitionReader reader = new PropertiesBeanDefinitionReader(ac);
    reader.loadBeanDefinitions(new ClassPathResource("view.properties", getClass()));
    ac.refresh();

    AbstractJasperReportsView view = (AbstractJasperReportsView) ac.getBean("report");
View Full Code Here

  private ServletContext servletContext;

  @Before
  public void setup() {
    this.webAppContext = mock(WebApplicationContext.class);
    this.servletContext = new MockServletContext();
    this.servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.webAppContext);
  }
View Full Code Here

  private MockHttpServletRequest request;

  @Before
  public void createViewResolver() {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    wac.refresh();
    viewResolver = new ContentNegotiatingViewResolver();
    viewResolver.setApplicationContext(wac);
    request = new MockHttpServletRequest("GET", "/test");
    RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
View Full Code Here

  public void resolveViewNameRedirectView() throws Exception {
    request.addHeader("Accept", "application/json");
    request.setRequestURI("/test");

    StaticWebApplicationContext webAppContext = new StaticWebApplicationContext();
    webAppContext.setServletContext(new MockServletContext());
    webAppContext.refresh();

    UrlBasedViewResolver urlViewResolver = new InternalResourceViewResolver();
    urlViewResolver.setApplicationContext(webAppContext);
    ViewResolver xmlViewResolver = mock(ViewResolver.class);
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.