Package org.springframework.mock.web

Examples of org.springframework.mock.web.MockServletContext.addInitParameter()


    assertTrue("Correct WebApplicationContext exposed in ServletContext", wc instanceof SimpleWebApplicationContext);
  }

  public void testContextLoaderWithInvalidLocation() throws Exception {
    MockServletContext sc = new MockServletContext("");
    sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "/WEB-INF/myContext.xml");
    ServletContextListener listener = new ContextLoaderListener();
    ServletContextEvent event = new ServletContextEvent(sc);
    try {
      listener.contextInitialized(event);
      fail("Should have thrown BeanDefinitionStoreException");
View Full Code Here


    }
  }

  public void testContextLoaderWithInvalidContext() throws Exception {
    MockServletContext sc = new MockServletContext("");
    sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM,
        "org.springframework.web.context.support.InvalidWebApplicationContext");
    ServletContextListener listener = new ContextLoaderListener();
    ServletContextEvent event = new ServletContextEvent(sc);
    try {
      listener.contextInitialized(event);
View Full Code Here

    }
  }

  public void testServletContextParameterFactoryBean() {
    MockServletContext sc = new MockServletContext();
    sc.addInitParameter("myParam", "myValue");

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("initParamName", "myParam");
View Full Code Here

    assertSame(tb, sc.getAttribute("attr2"));
  }

  public void testServletContextPropertyPlaceholderConfigurer() {
    MockServletContext sc = new MockServletContext();
    sc.addInitParameter("key4", "mykey4");

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);

    MutablePropertyValues pvs = new MutablePropertyValues();
View Full Code Here

    assertEquals(tb2, tb1.getSpouse());
  }

  public void testServletContextPropertyPlaceholderConfigurerWithLocalOverriding() {
    MockServletContext sc = new MockServletContext();
    sc.addInitParameter("key4", "mykey4");

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);

    MutablePropertyValues pvs = new MutablePropertyValues();
View Full Code Here

    assertEquals(tb2, tb1.getSpouse());
  }

  public void testServletContextPropertyPlaceholderConfigurerWithContextOverride() {
    MockServletContext sc = new MockServletContext();
    sc.addInitParameter("key4", "mykey4");

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);

    MutablePropertyValues pvs = new MutablePropertyValues();
View Full Code Here

    assertEquals(tb2, tb1.getSpouse());
  }

  public void testServletContextPropertyPlaceholderConfigurerWithContextOverrideAndAttributes() {
    MockServletContext sc = new MockServletContext();
    sc.addInitParameter("key4", "mykey4");
    sc.setAttribute("key4", "attrkey4");

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
View Full Code Here

    assertEquals(tb2, tb1.getSpouse());
  }

  public void testServletContextPropertyPlaceholderConfigurerWithAttributes() {
    MockServletContext sc = new MockServletContext();
    sc.addInitParameter("key4", "mykey4");

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);

    MutablePropertyValues pvs = new MutablePropertyValues();
View Full Code Here

  }

  public void testHtmlEscapeTagWithContextParamTrue() throws JspException {
    PageContext pc = createPageContext();
    MockServletContext sc = (MockServletContext) pc.getServletContext();
    sc.addInitParameter(WebUtils.HTML_ESCAPE_CONTEXT_PARAM, "true");
    HtmlEscapeTag tag = new HtmlEscapeTag();
    tag.setDefaultHtmlEscape("false");
    tag.setPageContext(pc);
    tag.doStartTag();
View Full Code Here

    MockServletContext sc = (MockServletContext) pc.getServletContext();
    HtmlEscapeTag tag = new HtmlEscapeTag();
    tag.setPageContext(pc);
    tag.doStartTag();

    sc.addInitParameter(WebUtils.HTML_ESCAPE_CONTEXT_PARAM, "false");
    assertTrue("Correct default", !tag.getRequestContext().isDefaultHtmlEscape());
    tag.setDefaultHtmlEscape("true");
    assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
    assertTrue("Correctly enabled", tag.getRequestContext().isDefaultHtmlEscape());
    tag.setDefaultHtmlEscape("false");
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.