Examples of StaticWebApplicationContext


Examples of org.springframework.web.context.support.StaticWebApplicationContext

    MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/main.do");
    MockHttpServletResponse response = new MockHttpServletResponse();

    request.setAttribute("test1", "value1");
    request.setAttribute("test2", "value2");
    WebApplicationContext wac = new StaticWebApplicationContext();
    request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);

    request.setAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE, "/form.do");
    simpleDispatcherServlet.service(request, response);
    assertTrue("forwarded to form", "form".equals(response.getIncludedUrl()));
View Full Code Here

Examples of org.springframework.web.context.support.StaticWebApplicationContext

    MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/main.do");
    MockHttpServletResponse response = new MockHttpServletResponse();

    request.setAttribute("test1", "value1");
    request.setAttribute("test2", "value2");
    WebApplicationContext wac = new StaticWebApplicationContext();
    request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
    TestBean command = new TestBean();
    request.setAttribute("command", command);

    request.setAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE, "/form.do");
View Full Code Here

Examples of org.springframework.web.context.support.StaticWebApplicationContext

    MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/main.do");
    MockHttpServletResponse response = new MockHttpServletResponse();

    request.setAttribute("test1", "value1");
    request.setAttribute("test2", "value2");
    WebApplicationContext wac = new StaticWebApplicationContext();
    request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
    TestBean command = new TestBean();
    request.setAttribute("command", command);

    request.setAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE, "/form.do");
View Full Code Here

Examples of org.springframework.web.context.support.StaticWebApplicationContext

    catch (IllegalStateException ex) {
      // expected
    }

    servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
        new StaticWebApplicationContext());
    try {
      RequestContextUtils.getWebApplicationContext(request, servletContext);
    }
    catch (IllegalStateException ex) {
      fail("Should not have thrown IllegalStateException: " + ex.getMessage());
View Full Code Here

Examples of org.springframework.web.context.support.StaticWebApplicationContext

*/
public class PathMapHandlerMappingTests extends TestCase {
 
  public void testSatisfiedConstructorDependency() throws Exception {
    String path = "/Constructor.htm";
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("test", TestBean.class, new MutablePropertyValues());

    HashUrlMapHandlerMapping hm = new HashUrlMapHandlerMapping();
    hm.register(ConstructorController.class, new PathMap(path));
    hm.setApplicationContext(wac);

    ConstructorController cc = (ConstructorController) wac.getBean(ConstructorController.class.getName());
    assertSame(wac.getBean("test"), cc.testBean);
    HandlerExecutionChain chain = hm.getHandler(new MockHttpServletRequest("GET", path));
    assertNotNull(chain);
    assertEquals("Path is mapped correctly based on attribute", cc, chain.getHandler());
    chain = hm.getHandler(new MockHttpServletRequest("GET", "completeRubbish.html"));
    assertNull("Don't know anything about this path", chain);
View Full Code Here

Examples of org.springframework.web.context.support.StaticWebApplicationContext

    assertNull("Don't know anything about this path", chain);
  }

  public void testUnsatisfiedConstructorDependency() throws Exception {
    String path = "/Constructor.htm";
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    // No registration of a TestBean
    //wac.registerSingleton("test", TestBean.class, new MutablePropertyValues());

    HashUrlMapHandlerMapping hm = new HashUrlMapHandlerMapping();
    hm.register(ConstructorController.class, new PathMap(path));
View Full Code Here

Examples of org.springframework.web.context.support.StaticWebApplicationContext

    }
  }

  public void testSatisfiedBeanPropertyDependency() throws Exception {
    String path = "/BeanProperty.htm";
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("test", TestBean.class, new MutablePropertyValues());

    HashUrlMapHandlerMapping hm = new HashUrlMapHandlerMapping();
    hm.register(BeanPropertyController.class, new PathMap(path));
    hm.setApplicationContext(wac);

    BeanPropertyController bpc = (BeanPropertyController) wac.getBean(BeanPropertyController.class.getName());
    assertSame(wac.getBean("test"), bpc.testBean);
    HandlerExecutionChain chain = hm.getHandler(new MockHttpServletRequest("GET", path));
    assertNotNull(chain);
    assertEquals("Path is mapped correctly based on attribute", bpc, chain.getHandler());
    chain = hm.getHandler(new MockHttpServletRequest("GET", "completeRubbish.html"));
    assertNull("Don't know anything about this path", chain);
View Full Code Here

Examples of org.springframework.web.context.support.StaticWebApplicationContext

    assertNull("Don't know anything about this path", chain);
  }

  public void testSatisfiedBeanPropertyDependencyWithAutowireByType() throws Exception {
    String path = "/BeanProperty.htm";
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("test", TestBean.class, new MutablePropertyValues());

    HashUrlMapHandlerMapping hm = new HashUrlMapHandlerMapping();
    hm.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE);
    hm.register(BeanPropertyController.class, new PathMap(path));
    hm.setApplicationContext(wac);

    BeanPropertyController bpc = (BeanPropertyController) wac.getBean(BeanPropertyController.class.getName());
    assertSame(wac.getBean("test"), bpc.testBean);
    HandlerExecutionChain chain = hm.getHandler(new MockHttpServletRequest("GET", path));
    assertNotNull(chain);
    assertEquals("Path is mapped correctly based on attribute", bpc, chain.getHandler());
    chain = hm.getHandler(new MockHttpServletRequest("GET", "completeRubbish.html"));
    assertNull("Don't know anything about this path", chain);
View Full Code Here

Examples of org.springframework.web.context.support.StaticWebApplicationContext

    }
    catch (IllegalStateException ex) {
      // expected
    }
    portletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
        new StaticWebApplicationContext());
    try {
      ac = PortletApplicationContextUtils.getRequiredWebApplicationContext(portletContext);
      assertNotNull(ac);
    }
    catch (IllegalStateException ex) {
View Full Code Here

Examples of org.springframework.web.context.support.StaticWebApplicationContext

    assertNull("Don't know anything about this path", chain);
  }

  public void testUnsatisfiedBeanPropertyDependencyWithAutowireByType() throws Exception {
    String path = "/BeanProperty.htm";
    StaticWebApplicationContext wac = new StaticWebApplicationContext();

    HashUrlMapHandlerMapping hm = new HashUrlMapHandlerMapping();
    hm.setAutowireModeName("AUTOWIRE_BY_TYPE");
    hm.register(BeanPropertyController.class, new PathMap(path));
    try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.