Package org.springframework.web.context.support

Examples of org.springframework.web.context.support.StaticWebApplicationContext.registerSingleton()


  public void testDelegatingFilterProxyWithFilterName() throws ServletException, IOException {
    ServletContext sc = new MockServletContext();

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    wac.registerSingleton("targetFilter", MockFilter.class);
    wac.refresh();
    sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);

    MockFilter targetFilter = (MockFilter) wac.getBean("targetFilter");
View Full Code Here


  }

  public void testWithServletContextAndFilter() throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    wac.registerSingleton("filterMultipartResolver", MockCommonsMultipartResolver.class, new MutablePropertyValues());
    wac.getServletContext().setAttribute(WebUtils.TEMP_DIR_CONTEXT_ATTRIBUTE, new File("mytemp"));
    wac.refresh();
    wac.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
    CommonsMultipartResolver resolver = new CommonsMultipartResolver(wac.getServletContext());
    assertTrue(resolver.getFileItemFactory().getRepository().getAbsolutePath().endsWith("mytemp"));
View Full Code Here

    DelegatingFilterProxy filterProxy = new DelegatingFilterProxy();
    filterProxy.init(proxyConfig);

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    wac.registerSingleton("targetFilter", MockFilter.class);
    wac.refresh();
    sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);

    MockFilter targetFilter = (MockFilter) wac.getBean("targetFilter");
View Full Code Here

  public void testWithServletContextAndFilterWithCustomBeanName() throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    wac.refresh();
    wac.registerSingleton("myMultipartResolver", MockCommonsMultipartResolver.class, new MutablePropertyValues());
    wac.getServletContext().setAttribute(WebUtils.TEMP_DIR_CONTEXT_ATTRIBUTE, new File("mytemp"));
    wac.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
    CommonsMultipartResolver resolver = new CommonsMultipartResolver(wac.getServletContext());
    assertTrue(resolver.getFileItemFactory().getRepository().getAbsolutePath().endsWith("mytemp"));
View Full Code Here

  public void testDelegatingFilterProxyWithTargetFilterLifecycle() throws ServletException, IOException {
    ServletContext sc = new MockServletContext();

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    wac.registerSingleton("targetFilter", MockFilter.class);
    wac.refresh();
    sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);

    MockFilter targetFilter = (MockFilter) wac.getBean("targetFilter");
View Full Code Here

  public void testDetectHandlerMappingFromParent() throws ServletException, IOException {
    // create a parent context that includes a mapping
    StaticWebApplicationContext parent = new StaticWebApplicationContext();
    parent.setServletContext(servletConfig.getServletContext());
    parent.registerSingleton("parentHandler", ControllerFromParent.class, new MutablePropertyValues());
   
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue(new PropertyValue("mappings", URL_KNOWN_ONLY_PARENT + "=parentHandler"));
   
    parent.registerSingleton("parentMapping", SimpleUrlHandlerMapping.class, pvs);
View Full Code Here

    parent.registerSingleton("parentHandler", ControllerFromParent.class, new MutablePropertyValues());
   
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue(new PropertyValue("mappings", URL_KNOWN_ONLY_PARENT + "=parentHandler"));
   
    parent.registerSingleton("parentMapping", SimpleUrlHandlerMapping.class, pvs);
    parent.refresh();

    DispatcherServlet complexDispatcherServlet = new DispatcherServlet();
    // will have parent
    complexDispatcherServlet.setContextClass(ComplexWebApplicationContext.class);
View Full Code Here

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

  }

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

  }

  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);
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.