Example usage for org.springframework.mock.web MockHttpServletRequest addParameter

List of usage examples for org.springframework.mock.web MockHttpServletRequest addParameter

Introduction

In this page you can find the example usage for org.springframework.mock.web MockHttpServletRequest addParameter.

Prototype

public void addParameter(String name, String... values) 

Source Link

Document

Add an array of values for the specified HTTP parameter.

Usage

From source file:org.tonguetied.web.RequestUtilsTest.java

/**
 * Test method for {@link RequestUtils#getBooleanParameter(javax.servlet.http.HttpServletRequest, String)}.
 *///from  w  w  w.ja  v a  2 s .co m
@Test
public final void testGetBooleanParameterWithEmptyValue() {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("test", "");
    final Boolean value = RequestUtils.getBooleanParameter(request, "test");
    assertNull(value);
}

From source file:org.tonguetied.web.RequestUtilsTest.java

/**
 * Test method for {@link RequestUtils#getBooleanParameter(javax.servlet.http.HttpServletRequest, String)}.
 *//*from   w  w w.j a  v a  2  s .co  m*/
@Test
public final void testGetBooleanParameterWithUnknownKey() {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("test", "false");
    final Boolean value = RequestUtils.getBooleanParameter(request, "different");
    assertNull(value);
}

From source file:org.tonguetied.web.RequestUtilsTest.java

/**
 * Test method for {@link RequestUtils#getBooleanParameter(javax.servlet.http.HttpServletRequest, String)}.
 *///from  www . j  a va 2 s .co  m
@Test
public final void testGetBooleanParameterWithInvalidValue() {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("test", "adsf");
    final Boolean value = RequestUtils.getBooleanParameter(request, "test");
    assertEquals(Boolean.FALSE, value);
}

From source file:org.tonguetied.web.RequestUtilsTest.java

/**
 * Test method for {@link org.tonguetied.web.RequestUtils#getLongParameter(javax.servlet.http.HttpServletRequest, String)}.
 *//*from  www .  j ava  2  s.  c  o  m*/
@Test
public final void testGetIntegerParameter() {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("test", "1");
    final Integer value = RequestUtils.getIntegerParameter(request, "test");
    assertArrayEquals(new Integer[] { 1 }, new Integer[] { value });
}

From source file:org.tonguetied.web.RequestUtilsTest.java

/**
 * Test method for {@link org.tonguetied.web.RequestUtils#getIntegerParameter(javax.servlet.http.HttpServletRequest, String)}.
 *//*w w w .jav a 2 s  . co  m*/
@Test
public final void testGetIntegerParameterWithEmptyValue() {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("test", "");
    final Integer value = RequestUtils.getIntegerParameter(request, "test");
    assertNull(value);
}

From source file:org.tonguetied.web.RequestUtilsTest.java

/**
 * Test method for {@link org.tonguetied.web.RequestUtils#getIntegerParameter(javax.servlet.http.HttpServletRequest, String)}.
 *///from w  w  w. j a va2 s. c o m
@Test
public final void testGetIntegerParameterWithUnknownKey() {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("test", "5");
    final Integer value = RequestUtils.getIntegerParameter(request, "different");
    assertNull(value);
}

From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.ConceptSourceController1_8Test.java

@Test
public void shouldPurgeAConceptSource() throws Exception {
    Assert.assertNotNull(service.getConceptSourceByUuid(getUuid()));
    MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid());
    req.addParameter("purge", "");
    handle(req);/*from  w ww .  ja v  a 2  s  .co  m*/
    Assert.assertNull(service.getConceptSourceByUuid(getUuid()));
}

From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.ModuleController1_8Test.java

@Test
public void shouldIncludeAuthorToFullRepresentation() throws Exception {
    MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid());
    req.addParameter("v", "full");
    SimpleObject result = deserialize(handle(req));

    Assert.assertNotNull(PropertyUtils.getProperty(result, "author"));
}

From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.ConceptSourceController1_8Test.java

@Test
public void shouldRetireAConceptSource() throws Exception {
    Assert.assertEquals(false, service.getConceptSourceByUuid(getUuid()).isRetired());
    MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid());
    req.addParameter("!purge", "");
    final String reason = "none";
    req.addParameter("reason", reason);
    handle(req);//from  w w w .j a  v  a  2 s.co m
    Assert.assertEquals(true, service.getConceptSourceByUuid(getUuid()).isRetired());
    Assert.assertEquals(reason, service.getConceptSourceByUuid(getUuid()).getRetireReason());
}

From source file:org.jasig.cas.web.ServiceValidateControllerTests.java

@Test
public void testValidServiceTicket() throws Exception {
    final String tId = getCentralAuthenticationService()
            .createTicketGrantingTicket(TestUtils.getCredentialsWithSameUsernameAndPassword());
    final String sId = getCentralAuthenticationService().grantServiceTicket(tId, TestUtils.getService());

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", TestUtils.getService().getId());
    request.addParameter("ticket", sId);

    assertEquals(CONST_SUCCESS_VIEW, this.serviceValidateController
            .handleRequestInternal(request, new MockHttpServletResponse()).getViewName());
}