Package org.springframework.web.servlet

Examples of org.springframework.web.servlet.DispatcherServlet.service()


    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myApp/myHandle");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("myView", response.getContentAsString());

    request = new MockHttpServletRequest("GET", "/myApp/myOther");
    response = new MockHttpServletResponse();
    servlet.service(request, response);
View Full Code Here


    servlet.service(request, response);
    assertEquals("myView", response.getContentAsString());

    request = new MockHttpServletRequest("GET", "/myApp/myOther");
    response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("myOtherView", response.getContentAsString());

    request = new MockHttpServletRequest("GET", "/myApp/myLang");
    response = new MockHttpServletResponse();
    servlet.service(request, response);
View Full Code Here

    servlet.service(request, response);
    assertEquals("myOtherView", response.getContentAsString());

    request = new MockHttpServletRequest("GET", "/myApp/myLang");
    response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("myLangView", response.getContentAsString());

    request = new MockHttpServletRequest("GET", "/myApp/surprise.do");
    response = new MockHttpServletResponse();
    servlet.service(request, response);
View Full Code Here

    servlet.service(request, response);
    assertEquals("myLangView", response.getContentAsString());

    request = new MockHttpServletRequest("GET", "/myApp/surprise.do");
    response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("mySurpriseView", response.getContentAsString());
  }

  public void testNullCommandController() throws Exception {
    @SuppressWarnings("serial")
View Full Code Here

    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPath");
    request.setUserPrincipal(new OtherPrincipal());
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("myView", response.getContentAsString());
  }

  public void testEquivalentMappingsWithSameMethodName() throws Exception {
    @SuppressWarnings("serial")
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/child/test");
    request.addParameter("childId", "100");
    MockHttpServletResponse response = new MockHttpServletResponse();
    try {
      servlet.service(request, response);
    }
    catch (NestedServletException ex) {
      assertTrue(ex.getCause() instanceof IllegalStateException);
      assertTrue(ex.getCause().getMessage().contains("doGet"));
    }
View Full Code Here

    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPath.do");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("test", response.getContentAsString());
  }

  @Test
  public void emptyParameterListHandleMethod() throws Exception {
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/emptyParameterListHandler");
    MockHttpServletResponse response = new MockHttpServletResponse();

    EmptyParameterListHandlerMethodController.called = false;
    servlet.service(request, response);
    assertTrue(EmptyParameterListHandlerMethodController.called);
    assertEquals("", response.getContentAsString());
  }

  @Test
View Full Code Here

    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPage");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("page1", request.getAttribute("viewName"));
    HttpSession session = request.getSession();
    assertTrue(session.getAttribute("object1") != null);
    assertTrue(session.getAttribute("object2") != null);
    assertTrue(((Map) session.getAttribute("model")).containsKey("object1"));
View Full Code Here

    assertTrue(((Map) session.getAttribute("model")).containsKey("object2"));

    request = new MockHttpServletRequest("POST", "/myPage");
    request.setSession(session);
    response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("page2", request.getAttribute("viewName"));
    assertTrue(session.getAttribute("object1") != null);
    assertTrue(session.getAttribute("object2") != null);
    assertTrue(((Map) session.getAttribute("model")).containsKey("object1"));
    assertTrue(((Map) session.getAttribute("model")).containsKey("object2"));
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.