Package org.springframework.web.context.support

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


* @since 09.04.2004
*/
public class StrutsSupportTests extends TestCase {

  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 testInternalResourceViewResolverWithJstlAndContextParam() throws Exception {
    Locale locale = !Locale.GERMAN.equals(Locale.getDefault()) ? Locale.GERMAN : Locale.FRENCH;

    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

    action.setServlet(null);
  }

  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

    assertEquals("message1", lc.getResourceBundle().getString("code1"));
    assertEquals("message2", lc.getResourceBundle().getString("code2"));
  }

  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 view1 = vr.resolveViewName("example1", Locale.getDefault());
View Full Code Here

    action.setServlet(null);
  }

  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

    assertTrue("Correct test1 attribute", "testvalue1".equals(request.getAttribute("test1")));
    assertTrue("Correct test2 attribute", "testvalue2".equals(request.getAttribute("test2")));
  }

  public void testXmlViewResolverDefaultLocation() {
    StaticWebApplicationContext wac = new StaticWebApplicationContext() {
      protected Resource getResourceByPath(String path) {
        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

      // expected
    }
  }

  public void testXmlViewResolverWithoutCache() throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext() {
      protected Resource getResourceByPath(String path) {
        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

      // expected
    }
  }

  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

    action.setServlet(null);
  }

  public void testDispatchActionSupportWithRootContext() 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

    action.setServlet(null);
  }

  public void testLookupDispatchActionSupportWithContextLoaderPlugIn() 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

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.