Package org.springframework.mock.web.test

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


  /**
   * Test attribute passing, NOT CSV parsing.
   */
  public void testRenderWithStaticAttributesNoCollision() throws Exception {
    WebApplicationContext wac = mock(WebApplicationContext.class);
    given(wac.getServletContext()).willReturn(new MockServletContext());

    HttpServletRequest request = new MockHttpServletRequest();
    HttpServletResponse response = new MockHttpServletResponse();
    TestView tv = new TestView(wac);

View Full Code Here


    assertTrue(tv.inited);
  }

  public void testPathVarsOverrideStaticAttributes() throws Exception {
    WebApplicationContext wac = mock(WebApplicationContext.class);
    given(wac.getServletContext()).willReturn(new MockServletContext());

    HttpServletRequest request = new MockHttpServletRequest();
    HttpServletResponse response = new MockHttpServletResponse();

    TestView tv = new TestView(wac);
View Full Code Here

    assertTrue(tv.inited);
  }

  public void testDynamicModelOverridesStaticAttributesIfCollision() throws Exception {
    WebApplicationContext wac = mock(WebApplicationContext.class);
    given(wac.getServletContext()).willReturn(new MockServletContext());

    HttpServletRequest request = new MockHttpServletRequest();
    HttpServletResponse response = new MockHttpServletResponse();
    TestView tv = new TestView(wac);
View Full Code Here

    assertTrue(tv.inited);
  }

  public void testDynamicModelOverridesPathVariables() throws Exception {
    WebApplicationContext wac = mock(WebApplicationContext.class);
    given(wac.getServletContext()).willReturn(new MockServletContext());

    TestView tv = new TestView(wac);
    tv.setApplicationContext(wac);

    MockHttpServletRequest request = new MockHttpServletRequest();
View Full Code Here

    assertNotNull(hec);
    assertSame(controller, hec.getHandler());
  }

  private void checkMappings(String beanName) throws Exception {
    MockServletContext sc = new MockServletContext("");
    XmlWebApplicationContext wac = new XmlWebApplicationContext();
    wac.setServletContext(sc);
    wac.setConfigLocations(new String[] {"/org/springframework/web/servlet/handler/map2.xml"});
    wac.refresh();
    Object bean = wac.getBean("mainController");
View Full Code Here


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

    final Template expectedTemplate = new Template();
    VelocityConfig vc = new VelocityConfig() {
      @Override
      public VelocityEngine getVelocityEngine() {
View Full Code Here

  }

  private void setViewProperties(AbstractJasperReportsView view) {
    view.setUrl("/org/springframework/ui/jasperreports/DataSourceReport.jasper");
    StaticWebApplicationContext ac = new StaticWebApplicationContext();
    ac.setServletContext(new MockServletContext());
    ac.addMessage("page", Locale.GERMAN, "MeineSeite");
    ac.refresh();
    request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, ac);
    view.setApplicationContext(ac);
  }
View Full Code Here

    assertTrue("Correctly applied", !testTag.isHtmlEscape());
  }

  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

    assertTrue("Correctly disabled", !tag.getRequestContext().isDefaultHtmlEscape());
  }

  public void testHtmlEscapeTagWithContextParamFalse() throws JspException {
    PageContext pc = createPageContext();
    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

  @Test
  public void updateTargetUrl() throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("requestDataValueProcessor", RequestDataValueProcessorWrapper.class);
    wac.setServletContext(new MockServletContext());
    wac.refresh();

    RequestDataValueProcessor mockProcessor = mock(RequestDataValueProcessor.class);
    wac.getBean(RequestDataValueProcessorWrapper.class).setRequestDataValueProcessor(mockProcessor);
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.