Package org.springframework.mock.web.test

Examples of org.springframework.mock.web.test.MockHttpServletRequest.addParameter()


  @Test
  public void testLongParameter() throws ServletRequestBindingException {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("param1", "5");
    request.addParameter("param2", "e");
    request.addParameter("paramEmpty", "");

    assertEquals(ServletRequestUtils.getLongParameter(request, "param1"), new Long(5L));
    assertEquals(ServletRequestUtils.getLongParameter(request, "param1", 6L), 5L);
    assertEquals(ServletRequestUtils.getRequiredIntParameter(request, "param1"), 5L);
View Full Code Here


  public void testParameterMethodNameResolver() throws NoSuchRequestHandlingMethodException {
    ParameterMethodNameResolver mnr = new ParameterMethodNameResolver();

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo.html");
    request.addParameter("action", "bar");
    assertEquals("bar", mnr.getHandlerMethodName(request));

    request = new MockHttpServletRequest("GET", "/foo.html");
    try {
      mnr.getHandlerMethodName(request);
View Full Code Here

    }
    catch (NoSuchRequestHandlingMethodException expected) {
    }

    request = new MockHttpServletRequest("GET", "/foo.html");
    request.addParameter("action", "");
    try {
      mnr.getHandlerMethodName(request);
      fail("Should have thrown NoSuchRequestHandlingMethodException");
    }
    catch (NoSuchRequestHandlingMethodException expected) {
View Full Code Here

    }
    catch (NoSuchRequestHandlingMethodException expected) {
    }

    request = new MockHttpServletRequest("GET", "/foo.html");
    request.addParameter("action", "     ");
    try {
      mnr.getHandlerMethodName(request);
      fail("Should have thrown NoSuchRequestHandlingMethodException");
    }
    catch (NoSuchRequestHandlingMethodException expected) {
View Full Code Here

  public void testParameterMethodNameResolverWithCustomParamName() throws NoSuchRequestHandlingMethodException {
    ParameterMethodNameResolver mnr = new ParameterMethodNameResolver();
    mnr.setParamName("myparam");
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo.html");
    request.addParameter("myparam", "bar");
    assertEquals("bar", mnr.getHandlerMethodName(request));
  }

  public void testParameterMethodNameResolverWithParamNames() throws NoSuchRequestHandlingMethodException {
    ParameterMethodNameResolver resolver = new ParameterMethodNameResolver();
View Full Code Here

    logicalMappings.setProperty("nina", "colin");
    resolver.setLogicalMappings(logicalMappings);

    // verify default handler
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("this will not match anything", "whatever");
    assertEquals("default", resolver.getHandlerMethodName(request));

    // verify first resolution strategy (action=method)
    request = new MockHttpServletRequest();
    request.addParameter("action", "reset");
View Full Code Here

    request.addParameter("this will not match anything", "whatever");
    assertEquals("default", resolver.getHandlerMethodName(request));

    // verify first resolution strategy (action=method)
    request = new MockHttpServletRequest();
    request.addParameter("action", "reset");
    assertEquals("reset", resolver.getHandlerMethodName(request));
    // this one also tests logical mapping
    request = new MockHttpServletRequest();
    request.addParameter("action", "nina");
    assertEquals("colin", resolver.getHandlerMethodName(request));
View Full Code Here

    request = new MockHttpServletRequest();
    request.addParameter("action", "reset");
    assertEquals("reset", resolver.getHandlerMethodName(request));
    // this one also tests logical mapping
    request = new MockHttpServletRequest();
    request.addParameter("action", "nina");
    assertEquals("colin", resolver.getHandlerMethodName(request));

    // now validate second resolution strategy (parameter existence)
    // this also tests logical mapping
    request = new MockHttpServletRequest();
View Full Code Here

    assertEquals("colin", resolver.getHandlerMethodName(request));

    // now validate second resolution strategy (parameter existence)
    // this also tests logical mapping
    request = new MockHttpServletRequest();
    request.addParameter("hello", "whatever");
    assertEquals("goodbye", resolver.getHandlerMethodName(request));

    request = new MockHttpServletRequest();
    request.addParameter("spring", "whatever");
    assertEquals("spring", resolver.getHandlerMethodName(request));
View Full Code Here

    request = new MockHttpServletRequest();
    request.addParameter("hello", "whatever");
    assertEquals("goodbye", resolver.getHandlerMethodName(request));

    request = new MockHttpServletRequest();
    request.addParameter("spring", "whatever");
    assertEquals("spring", resolver.getHandlerMethodName(request));

    request = new MockHttpServletRequest();
    request.addParameter("hello", "whatever");
    request.addParameter("spring", "whatever");
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.