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:test.com.tsc9526.monalisa.service.actions.PutActionTest.java

public void testPutDbTableByMultiKeys() throws Exception {
    Assert.assertNotEquals(selectByPrimaryKey(2).get("name"), "ppyyzz002");

    MockHttpServletRequest req = createRequest("/db1/test_record_v2/record_id=2");

    req.addParameter("name", "ppyyzz002");
    Response resp = getRespone(req);
    Assert.assertEquals(resp.getStatus(), 200, resp.getMessage());
    Assert.assertEquals(selectByPrimaryKey(2).get("name"), "ppyyzz002");
}

From source file:org.jasig.cas.web.support.CookieRetrievingCookieGeneratorTests.java

public void testCookieAddWithRememberMe() {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter(RememberMeCredentials.REQUEST_PARAMETER_REMEMBER_ME, "true");
    final MockHttpServletResponse response = new MockHttpServletResponse();

    this.g.addCookie(request, response, "test");

    final Cookie c = response.getCookie("test");
    assertEquals(100, c.getMaxAge());//from  w  w  w  . j av a 2s . c om
    assertEquals("test", c.getValue());
}

From source file:org.araneaframework.tests.FormElementTest.java

/**
 * Tests that {@link TextControl} return <code>null</code> on empty request.
 * @throws Exception/* w w w  .  ja  va2s.  co  m*/
 */
public void testDataCycling() throws Exception {
    MockHttpServletRequest emptyRequest = new MockHttpServletRequest();
    emptyRequest.addParameter("myTextBox", "");

    FormElement sfe = new FormElement();

    sfe._getComponent().init(new MockEnviroment());

    TextControl tb = new TextControl();
    tb.setMandatory(true);

    sfe.setControl(tb);
    sfe.setData(new LongData());
    sfe.setConverter(new StringToLongConverter());

    sfe._getWidget().update(new StandardServletInputData(emptyRequest));
    sfe.convertAndValidate();

    sfe.getData().setValue(new Long(110));

    sfe._getWidget().process();

    assertEquals("The textbox must have the data item value!",
            ((StringArrayRequestControl.ViewModel) sfe.getControl()._getViewable().getViewModel())
                    .getSimpleValue(),
            "110");

    sfe._getComponent().destroy();
}

From source file:org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_9.PatientByIdentifierSearchHandlerTest1_9.java

@Test
public void getSearchConfig_shouldReturnPatientByIdentifier_matchStart() throws Exception {
    MockHttpServletRequest req = request(RequestMethod.GET, getURI());
    req.addParameter("identifier", "7T");
    req.addParameter("searchType", "start");

    SimpleObject result = deserialize(handle(req));
    List<Object> hits = (List<Object>) result.get("results");
    Assert.assertEquals(1, hits.size());
}

From source file:org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_9.PatientByIdentifierSearchHandlerTest1_9.java

/**
 * @verifies return location by tag uuid
 * @see LocationSearchHandler#getSearchConfig()
 *///from  w  ww .  ja  v  a  2s  .  c  o  m
@Test
public void getSearchConfig_shouldReturnPatientByIdentifier() throws Exception {
    MockHttpServletRequest req = request(RequestMethod.GET, getURI());
    req.addParameter("identifier", "7TU-8");

    SimpleObject result = deserialize(handle(req));
    List<Object> hits = (List<Object>) result.get("results");
    Assert.assertEquals(Context.getPatientService().getPatient(8).getUuid(),
            PropertyUtils.getProperty(hits.get(0), "uuid"));
}

From source file:org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_9.PatientByIdentifierSearchHandlerTest1_9.java

@Test
public void getSearchConfig_shouldReturnPatientByIdentifier_matchExact() throws Exception {
    MockHttpServletRequest req = request(RequestMethod.GET, getURI());
    req.addParameter("identifier", "7TU-8");
    req.addParameter("searchType", "exact");

    SimpleObject result = deserialize(handle(req));
    List<Object> hits = (List<Object>) result.get("results");
    Assert.assertEquals(Context.getPatientService().getPatient(8).getUuid(),
            PropertyUtils.getProperty(hits.get(0), "uuid"));
}

From source file:com.nominanuda.springsoy.SoySourceTest.java

@Test
public void testJavaView() throws Exception {
    MockHttpServletRequest req = new MockHttpServletRequest("GET", "/");
    req.addParameter("lang", "en");
    MockHttpServletResponse resp = new MockHttpServletResponse();

    SoyViewResolver viewResolver = new SoyViewResolver();
    viewResolver.setSoySource(soySource);

    LocaleResolver localeResolver = new QueryParamLocaleResolver();
    Locale loc = localeResolver.resolveLocale(req);
    View view = viewResolver.resolveViewName("examples.simple.helloWorld2", loc);
    Map<String, ?> m = Collections.emptyMap();
    view.render(m, req, resp);/*w ww .  j  a v a 2s  . c  o m*/
    Assert.assertEquals("Hello world!", resp.getContentAsString());
}

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

@Test
public void testLogoutForServiceWithFollowRedirects() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", "TestService");
    this.logoutController.setFollowServiceRedirects(true);
    assertTrue(this.logoutController.handleRequestInternal(request, new MockHttpServletResponse())
            .getView() instanceof RedirectView);
}

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

@Test
public void testLogoutForServiceWithNoFollowRedirects() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", "TestService");
    this.logoutController.setFollowServiceRedirects(false);
    assertTrue(!(this.logoutController.handleRequestInternal(request, new MockHttpServletResponse())
            .getView() instanceof RedirectView));
}

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

@Test
public void testNonExistentPGT() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("pgt", "TestService");
    request.addParameter("targetService", "testDefault");

    assertTrue(this.proxyController.handleRequestInternal(request, new MockHttpServletResponse()).getModel()
            .containsKey("code"));
}