Package org.springframework.mock.web.test

Examples of org.springframework.mock.web.test.MockServletContext


    final Set<String> paths = new HashSet<String>();
    paths.add("C:/webroot/WEB-INF/context1.xml");
    paths.add("C:/webroot/WEB-INF/context2.xml");
    paths.add("C:/webroot/someOtherDirThatDoesntContainPath");

    MockServletContext sc = new MockServletContext("classpath:org/springframework/web/context") {
      @Override
      public Set<String> getResourcePaths(String path) {
        if ("/WEB-INF/".equals(path)) {
          return paths;
        }
View Full Code Here


public class ViewResolverTests {

  @Test
  public void testBeanNameViewResolver() throws ServletException {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    MutablePropertyValues pvs1 = new MutablePropertyValues();
    pvs1.addPropertyValue(new PropertyValue("url", "/example1.jsp"));
    wac.registerSingleton("example1", InternalResourceView.class, pvs1);
    MutablePropertyValues pvs2 = new MutablePropertyValues();
    pvs2.addPropertyValue(new PropertyValue("url", "/example2.jsp"));
View Full Code Here

    doTestUrlBasedViewResolverWithPrefixes(new InternalResourceViewResolver());
  }

  private void doTestUrlBasedViewResolverWithoutPrefixes(UrlBasedViewResolver vr) throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    wac.refresh();
    vr.setApplicationContext(wac);
    vr.setContentType("myContentType");
    vr.setRequestContextAttribute("rc");
View Full Code Here

    assertEquals("Correct URL", "myUrl", ((InternalResourceView) view).getUrl());
  }

  private void doTestUrlBasedViewResolverWithPrefixes(UrlBasedViewResolver vr) throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    wac.refresh();
    vr.setPrefix("/WEB-INF/");
    vr.setSuffix(".jsp");
    vr.setApplicationContext(wac);
View Full Code Here

  private ConfigurableWebApplicationContext wac;

  @Before
  public void setUp() throws Exception {
    MockServletContext sc = new MockServletContext("");
    wac = new XmlWebApplicationContext();
    wac.setServletContext(sc);
    wac.setConfigLocations(new String[] {CONF});
    wac.refresh();
    hm = (HandlerMapping) wac.getBean("urlMapping");
View Full Code Here

    assertEquals("Correct URL", "myUrl", ((InternalResourceView) view).getUrl());
  }

  @Test
  public void testInternalResourceViewResolverWithAttributes() throws Exception {
    MockServletContext sc = new MockServletContext();
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    wac.refresh();
    InternalResourceViewResolver vr = new InternalResourceViewResolver();
    Properties props = new Properties();
View Full Code Here

    assertEquals(new Integer(2), request.getAttribute("key2"));
  }

  @Test
  public void testInternalResourceViewResolverWithContextBeans() throws Exception {
    MockServletContext sc = new MockServletContext();
    final StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("myBean", TestBean.class);
    wac.registerSingleton("myBean2", TestBean.class);
    wac.setServletContext(sc);
    wac.refresh();
View Full Code Here

    view.render(new HashMap(), request, response);
  }

  @Test
  public void testInternalResourceViewResolverWithSpecificContextBeans() throws Exception {
    MockServletContext sc = new MockServletContext();
    final StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("myBean", TestBean.class);
    wac.registerSingleton("myBean2", TestBean.class);
    wac.setServletContext(sc);
    wac.refresh();
View Full Code Here

  @Test
  public void testInternalResourceViewResolverWithJstl() throws Exception {
    Locale locale = !Locale.GERMAN.equals(Locale.getDefault()) ? Locale.GERMAN : Locale.FRENCH;

    MockServletContext sc = new MockServletContext();
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    wac.addMessage("code1", locale, "messageX");
    wac.refresh();
    InternalResourceViewResolver vr = new InternalResourceViewResolver();
View Full Code Here

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

TOP

Related Classes of org.springframework.mock.web.test.MockServletContext

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.