List of usage examples for org.springframework.mock.web MockHttpServletRequest addParameter
public void addParameter(String name, String... values)
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.ConceptClassControllerTest.java
@Test public void shouldIncludeTheAuditInfoForTheFullRepresentation() throws Exception { MockHttpServletRequest httpReq = new MockHttpServletRequest(); httpReq.addParameter(RestConstants.REQUEST_PROPERTY_FOR_REPRESENTATION, RestConstants.REPRESENTATION_FULL); Object result = controller.retrieve("97097dd9-b092-4b68-a2dc-e5e5be961d42", httpReq); Assert.assertNotNull(result);//from w w w . ja v a 2s . com Assert.assertNotNull(PropertyUtils.getProperty(result, "auditInfo")); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9.ProviderAttributeTypeController1_9Test.java
/** * @see ProviderAttributeTypeController#findProviderAttributeTypes(String,WebRequest,HttpServletResponse) * @verifies return no results if there are no matching provider(s) *//*from w w w .j a va 2s.co m*/ @Test public void findProviderAttributeTypes_shouldReturnNoResultsIfThereAreNoMatchingProviders() throws Exception { MockHttpServletRequest request = newGetRequest(getURI()); request.addParameter("q", "zzzznotype"); SimpleObject result = deserialize(handle(request)); Assert.assertEquals(0, Util.getResultsSize(result)); }
From source file:com.gisgraphy.test.GisgraphyTestHelper.java
public static MockHttpServletRequest createMockHttpServletRequestForGeoloc() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter(GisgraphyServlet.FROM_PARAMETER, "3"); request.addParameter(GisgraphyServlet.TO_PARAMETER, GeolocQuery.DEFAULT_MAX_RESULTS + 20 + ""); request.addParameter(GisgraphyServlet.FORMAT_PARAMETER, "XML"); request.addParameter(GeolocQuery.PLACETYPE_PARAMETER, "city"); request.addParameter(GeolocQuery.LAT_PARAMETER, "1.0"); request.addParameter(GeolocQuery.LONG_PARAMETER, "2.0"); request.addParameter(GeolocQuery.LONG_PARAMETER, "3.0"); return request; }
From source file:com.gisgraphy.test.GisgraphyTestHelper.java
public static MockHttpServletRequest createMockHttpServletRequestForStreetGeoloc() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter(GisgraphyServlet.FROM_PARAMETER, "3"); request.addParameter(GisgraphyServlet.TO_PARAMETER, StreetSearchQuery.DEFAULT_MAX_RESULTS + 10 + ""); request.addParameter(GisgraphyServlet.FORMAT_PARAMETER, "XML"); request.addParameter(GeolocQuery.PLACETYPE_PARAMETER, "city"); request.addParameter(GeolocQuery.LAT_PARAMETER, "1.0"); request.addParameter(GeolocQuery.LONG_PARAMETER, "2.0"); request.addParameter(GeolocQuery.LONG_PARAMETER, "3.0"); return request; }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.PersonAttributeTypeControllerTest.java
/** * @see PersonAttributeTypeController#getPersonAttributeType(String,WebRequest) * @verifies get a full representation of a person attribute type *///from w w w . ja v a2s.c o m @Test public void getPersonAttributeType_shouldGetAFullRepresentationOfAPersonAttributeType() throws Exception { MockHttpServletRequest req = new MockHttpServletRequest(); req.addParameter(RestConstants.REQUEST_PROPERTY_FOR_REPRESENTATION, RestConstants.REPRESENTATION_FULL); Object result = new PersonAttributeTypeController().retrieve("b3b6d540-a32e-44c7-91b3-292d97667518", req); Util.log("Person fetched (full)", result); Assert.assertNotNull(result); Assert.assertEquals("b3b6d540-a32e-44c7-91b3-292d97667518", PropertyUtils.getProperty(result, "uuid")); Assert.assertNotNull(PropertyUtils.getProperty(result, "auditInfo")); }
From source file:com.gisgraphy.test.GisgraphyTestHelper.java
public static MockHttpServletRequest createMockHttpServletRequestForFullText() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter(FulltextQuery.COUNTRY_PARAMETER, "FR"); request.addParameter(FulltextServlet.FROM_PARAMETER, "3"); request.addParameter(FulltextServlet.TO_PARAMETER, FulltextQuery.DEFAULT_MAX_RESULTS + 20 + ""); request.addParameter(FulltextServlet.FORMAT_PARAMETER, "XML"); request.addParameter(FulltextQuery.STYLE_PARAMETER, "FULL"); request.addParameter(FulltextQuery.LANG_PARAMETER, "fr"); request.addParameter(GisgraphyServlet.INDENT_PARAMETER, "XML"); request.addParameter(FulltextQuery.PLACETYPE_PARAMETER, "city"); request.addParameter(FulltextQuery.QUERY_PARAMETER, "query"); request.addParameter(FulltextQuery.SPELLCHECKING_PARAMETER, "true"); return request; }
From source file:org.jasig.cas.web.view.Saml10FailureResponseViewTests.java
public void testResponse() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(); final MockHttpServletResponse response = new MockHttpServletResponse(); request.addParameter("TARGET", "service"); final String description = "Validation failed"; this.view.renderMergedOutputModel(Collections.<String, Object>singletonMap("description", description), request, response);/*w w w. j ava2s.c o m*/ final String responseText = response.getContentAsString(); assertTrue(responseText.contains("Status")); assertTrue(responseText.contains(description)); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.EncounterTypeControllerTest.java
@Test public void shouldReturnTheAuditInfoForTheFullRepresentation() throws Exception { MockHttpServletRequest httpReq = new MockHttpServletRequest(); httpReq.addParameter(RestConstants.REQUEST_PROPERTY_FOR_REPRESENTATION, RestConstants.REPRESENTATION_FULL); Object result = controller.retrieve("61ae96f4-6afe-4351-b6f8-cd4fc383cce1", httpReq); Assert.assertNotNull(result);//from w ww .j a va 2s . com Assert.assertNotNull(PropertyUtils.getProperty(result, "auditInfo")); }
From source file:org.openmrs.module.formfilter.web.controller.AddFormFilterPropertyControllerTest.java
/** * @see {@link AddFormFilterPropertyController#onSubmit(FormFilterProperty, org.springframework.validation.BindingResult, org.springframework.web.bind.support.SessionStatus, javax.servlet.http.HttpServletRequest) } *//*from ww w . java 2 s .c o m*/ @Test @Verifies(value = "should update FormFilterProperty", method = "onSubmit(FormFilterProperty, org.springframework.validation.BindingResult, org.springframework.web.bind.support.SessionStatus, javax.servlet.http.HttpServletRequest)") public void onSubmit_shouldUpdateFormFilterProperty() { AddFormFilterPropertyController controller = new AddFormFilterPropertyController(); FormFilterService formFilterService = Context.getService(FormFilterService.class); MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("formFilterId", "1"); request.addParameter("propertyType", "AgeProperty"); request.addParameter("minimumAge", "10"); request.addParameter("maximumAge", "30"); FormFilterProperty formFilterProperty = formFilterService.getFormFilterProperty(2); controller.onSubmit(formFilterProperty, null, null, request); Assert.assertEquals("org.openmrs.module.formfilter.impl.AgeFormFilter", formFilterService.getFormFilterProperty(2).getClassName()); }
From source file:test.com.tsc9526.monalisa.service.actions.PostActionTest.java
public void testPostDbTableByPk() throws Exception { Assert.assertNotEquals(selectByPrimaryKey(1).get("name"), "xxyyzz001"); MockHttpServletRequest req = createRequest("/db1/test_record_v2/1"); req.addParameter("name", "xxyyzz001"); Response resp = getRespone(req); Assert.assertEquals(resp.getStatus(), 200, resp.getMessage()); Assert.assertEquals(selectByPrimaryKey(1).get("name"), "xxyyzz001"); }