Package org.springframework.web.context.support

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


    }
  }

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

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

    BeanPropertyController bpc = (BeanPropertyController) wac.getBean(BeanPropertyController.class.getName());
    assertSame(wac.getBean("testBean"), 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


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

  public void testUnsatisfiedBeanPropertyDependencyWithAutowireByName() 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_NAME);
    hm.register(BeanPropertyController.class, new PathMap(path));
    try {
View Full Code Here

    }
  }

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

    HashUrlMapHandlerMapping hm = new HashUrlMapHandlerMapping();
    hm.setAutowireModeName("AUTOWIRE_BY_NAME");
    hm.setDependencyCheck(false);
    hm.register(BeanPropertyController.class, new PathMap(path));
    hm.setApplicationContext(wac);

    BeanPropertyController bpc = (BeanPropertyController) wac.getBean(BeanPropertyController.class.getName());
    assertNull("Not autowired but no dependency check", 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"));
View Full Code Here

  }

  public void testMultiplePaths() throws Exception {
    String path1 = "/Constructor.htm";
    String path2 = "path2.cgi";
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("test", TestBean.class, new MutablePropertyValues());

    HashUrlMapHandlerMapping hm = new HashUrlMapHandlerMapping();
    hm.register(ConstructorController.class, new PathMap[] { new PathMap(path1), new PathMap(path2) });
    hm.setApplicationContext(wac);
    ConstructorController cc = (ConstructorController) wac.getBean(ConstructorController.class.getName());
    assertSame(wac.getBean("test"), cc.testBean);
    HandlerExecutionChain chain = hm.getHandler(new MockHttpServletRequest("GET", path1));
    assertNotNull(chain);
    assertEquals("Path is mapped correctly based on attribute 1", cc, chain.getHandler());
    chain = hm.getHandler(new MockHttpServletRequest(null, "GET", "/" + path2));
    assertEquals("Path is mapped correctly based on attribute 2", cc, chain.getHandler());
View Full Code Here

    }
    requestControl.replay();
    contextControl.replay();
    dispatcherControl.replay();

    StaticWebApplicationContext sac = new StaticWebApplicationContext();
    sac.setServletContext(context);
    sfc.setApplicationContext(sac);
    assertNull(sfc.handleRequest(request, response));

    requestControl.verify();
    contextControl.verify();
View Full Code Here

  }

  public void testVelocityToolboxView() throws Exception {
    final String templateName = "test.vm";

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    final Template expectedTemplate = new Template();
    VelocityConfig vc = new VelocityConfig() {
      public VelocityEngine getVelocityEngine() {
        return new TestVelocityEngine(templateName, expectedTemplate);
      }
    };
    wac.getDefaultListableBeanFactory().registerSingleton("velocityConfigurer", vc);

    final HttpServletRequest expectedRequest = new MockHttpServletRequest();
    final HttpServletResponse expectedResponse = new MockHttpServletResponse();

    VelocityToolboxView vv = new VelocityToolboxView() {
View Full Code Here

  private FreeMarkerConfigurer fc;


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

    //final Template expectedTemplate = new Template();
    fc = new FreeMarkerConfigurer();
    fc.setPreferFileSystemAccess(false);
View Full Code Here

      public VelocityEngine getVelocityEngine() {
        return new TestVelocityEngine("prefix_test_suffix", new Template());
      }
    };

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.getBeanFactory().registerSingleton("configurer", vc);

    VelocityViewResolver vr = new VelocityViewResolver();
    vr.setPrefix("prefix_");
    vr.setSuffix("_suffix");
    vr.setApplicationContext(wac);
View Full Code Here

      public VelocityEngine getVelocityEngine() {
        return new TestVelocityEngine("prefix_test_suffix", new Template());
      }
    };

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.getBeanFactory().registerSingleton("configurer", vc);

    String toolbox = "org/springframework/web/servlet/view/velocity/toolbox.xml";

    VelocityViewResolver vr = new VelocityViewResolver();
    vr.setPrefix("prefix_");
View Full Code Here

        ve.addTemplate(VelocityLayoutView.DEFAULT_LAYOUT_URL, new Template());
        return ve;
      }
    };

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.getBeanFactory().registerSingleton("configurer", vc);

    String toolbox = "org/springframework/web/servlet/view/velocity/toolbox.xml";

    VelocityViewResolver vr = new VelocityViewResolver();
    vr.setViewClass(VelocityLayoutView.class);
View Full Code Here

TOP

Related Classes of org.springframework.web.context.support.StaticWebApplicationContext

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.