Package org.springframework.web.context.support

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


    MockServletContext sc = new MockServletContext();
    final StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("myBean", TestBean.class);
    wac.registerSingleton("myBean2", TestBean.class);
    wac.setServletContext(sc);
    wac.refresh();
    InternalResourceViewResolver vr = new InternalResourceViewResolver();
    Properties props = new Properties();
    props.setProperty("key1", "value1");
    vr.setAttributes(props);
    Map map = new HashMap();
View Full Code Here


    MockServletContext sc = new MockServletContext();
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    wac.addMessage("code1", locale, "messageX");
    wac.refresh();
    InternalResourceViewResolver vr = new InternalResourceViewResolver();
    vr.setViewClass(JstlView.class);
    vr.setApplicationContext(wac);

    View view = vr.resolveViewName("example1", Locale.getDefault());
View Full Code Here

    MockServletContext sc = new MockServletContext();
    sc.addInitParameter(Config.FMT_LOCALIZATION_CONTEXT, "org/springframework/web/context/WEB-INF/context-messages");
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    wac.addMessage("code1", locale, "messageX");
    wac.refresh();
    InternalResourceViewResolver vr = new InternalResourceViewResolver();
    vr.setViewClass(JstlView.class);
    vr.setApplicationContext(wac);

    View view = vr.resolveViewName("example1", Locale.getDefault());
View Full Code Here

  public void testActionSupportWithContextLoaderPlugIn() throws ServletException {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.addMessage("test", Locale.getDefault(), "testmessage");
    final ServletContext servletContext = new MockServletContext();
    wac.setServletContext(servletContext);
    wac.refresh();
    servletContext.setAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX, wac);

    ActionServlet actionServlet = new ActionServlet() {
      public ServletContext getServletContext() {
        return servletContext;
View Full Code Here

  public void testActionSupportWithRootContext() throws ServletException {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.addMessage("test", Locale.getDefault(), "testmessage");
    final ServletContext servletContext = new MockServletContext();
    wac.setServletContext(servletContext);
    wac.refresh();
    servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);

    ActionServlet actionServlet = new ActionServlet() {
      public ServletContext getServletContext() {
        return servletContext;
View Full Code Here

  public void testXmlViewResolver() throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("testBean", TestBean.class);
    wac.setServletContext(new MockServletContext());
    wac.refresh();
    TestBean testBean = (TestBean) wac.getBean("testBean");
    XmlViewResolver vr = new XmlViewResolver();
    vr.setLocation(new ClassPathResource("org/springframework/web/servlet/view/views.xml"));
    vr.setApplicationContext(wac);
View Full Code Here

        assertTrue("Correct default location", XmlViewResolver.DEFAULT_LOCATION.equals(path));
        return super.getResourceByPath(path);
      }
    };
    wac.setServletContext(new MockServletContext());
    wac.refresh();
    XmlViewResolver vr = new XmlViewResolver();
    try {
      vr.setApplicationContext(wac);
      fail("Should have thrown BeanDefinitionStoreException");
    }
View Full Code Here

        assertTrue("Correct default location", XmlViewResolver.DEFAULT_LOCATION.equals(path));
        return super.getResourceByPath(path);
      }
    };
    wac.setServletContext(new MockServletContext());
    wac.refresh();
    XmlViewResolver vr = new XmlViewResolver();
    vr.setCache(false);
    try {
      vr.setApplicationContext(wac);
    }
View Full Code Here

  public void testDispatchActionSupportWithContextLoaderPlugIn() throws ServletException {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.addMessage("test", Locale.getDefault(), "testmessage");
    final ServletContext servletContext = new MockServletContext();
    wac.setServletContext(servletContext);
    wac.refresh();
    servletContext.setAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX, wac);

    ActionServlet actionServlet = new ActionServlet() {
      public ServletContext getServletContext() {
        return servletContext;
View Full Code Here

  }

  public void testCacheRemoval() throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    wac.refresh();
    InternalResourceViewResolver vr = new InternalResourceViewResolver();
    vr.setViewClass(JstlView.class);
    vr.setApplicationContext(wac);
 
    View view = vr.resolveViewName("example1", Locale.getDefault());   
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.