List of usage examples for org.springframework.mock.web MockHttpServletRequest MockHttpServletRequest
public MockHttpServletRequest()
From source file:org.openmrs.module.clinicalsummary.web.service.PatientIndexControllerTest.java
/** * @verifies return indexes for the patient * @see org.openmrs.module.clinicalsummary.web.controller.service.PatientIndexController#searchIndex(String, String, Integer, javax.servlet.http.HttpServletResponse) *//*from w w w . j av a2 s.c o m*/ @Test public void searchIndex_shouldReturnIndexesForThePatient() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.setMethod("GET"); request.setRequestURI("/module/clinicalsummary/service/patient/index"); request.setParameter("username", "admin"); request.setParameter("password", "test"); request.setParameter("patientId", String.valueOf(7)); MockHttpServletResponse response = new MockHttpServletResponse(); HandlerAdapter handlerAdapter = new AnnotationMethodHandlerAdapter(); handlerAdapter.handle(request, response, controller); Assert.assertTrue(StringUtils.isNotEmpty(response.getContentAsString())); Assert.assertTrue(StringUtils.contains(response.getContentAsString(), "Collet Test Chebaskwony")); Assert.assertTrue(StringUtils.contains(response.getContentAsString(), "6TS-4")); }
From source file:org.jasig.cas.adaptors.cas.LegacyCasCredentialsBinderTests.java
public void testBindMethod() { HttpServletRequest request = new MockHttpServletRequest(); LegacyCasCredentials credentials = new LegacyCasCredentials(); this.credentialsBinder.bind(request, credentials); assertEquals(request, credentials.getServletRequest()); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.PatientIdentifierTypeControllerTest.java
@Before public void before() { this.service = Context.getPatientService(); this.controller = new PatientIdentifierTypeController(); this.request = new MockHttpServletRequest(); this.response = new MockHttpServletResponse(); }
From source file:com.geodan.ngr.serviceintegration.TestCSWTransformer.java
private void test() { try {/*ww w .j a va2 s . c o m*/ MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); request.setParameter("startPosition", "1"); request.setParameter("maxRecords", "3"); //request.setParameter("ElementSetName", "full"); //request.setParameter("ElementSetName", "minimal"); //request.setParameter("searchterms-1", "niEuWe"); //request.setParameter("field-1", "AnyText"); //request.setParameter("searchterms-2", "heeeeee"); //request.setParameter("field-2", "title"); //request.setParameter("searchterms-3", "OGC:WMS"); //request.setParameter("searchterms-3", "OGC:WMS-1.1.1-http-get-capabilities"); //request.setParameter("searchterms-3", "OGC:WMS-1.1.1-http-get-capabilities"); //request.setParameter("field-3", "OnlineResourceType"); //request.setParameter("url","http://nationaalgeoregister.nl:80/geonetwork/srv/en/csw"); request.setParameter("url", "http://nationaalgeoregister.nl/geonetwork/srv/en/csw"); //request.setParameter("callback", "callbackfunction"); go(request, response); } catch (Throwable x) { System.out.println(x.getMessage()); x.printStackTrace(); } }
From source file:org.openmrs.web.attribute.handler.RegexValidatedTextDatatypeHandlerTest.java
/** * @see org.openmrs.web.attribute.handler.FieldGenDatatypeHandler#getValue(CustomDatatype, * HttpServletRequest, String)//from w ww . j ava 2 s . co m * @verifies return attribute value from request for given field name if the attribute value is * valid according to datataype */ @Test public void getValue_shouldReturnAttributeValueFromRequestForGivenFieldNameIfTheAttributeValueIsValidAccordingToDatatype() { // given String fieldName = "regexfield"; String validFieldValue = "1"; MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter(fieldName, validFieldValue); RegexValidatedTextDatatype datatype = new RegexValidatedTextDatatype(); datatype.setConfiguration("^[012]$"); assertThat(handler.getValue(datatype, request, fieldName), is(validFieldValue)); }
From source file:org.slc.sli.dashboard.web.unit.interceptor.SessionCheckInterceptorTest.java
@Test public void testPreHandle() throws Exception { SessionCheckInterceptor scInterceptor = new SessionCheckInterceptor(); PowerMockito.mockStatic(SecurityUtil.class); PowerMockito.when(SecurityUtil.getToken()).thenReturn("sravan"); MockHttpServletRequest request = new MockHttpServletRequest() { public HttpSession getSession() { return new MockHttpSession(); }//from w w w . j a va 2 s .c o m public Cookie[] getCookies() { Cookie c = new Cookie(SLIAuthenticationEntryPoint.DASHBOARD_COOKIE, "fake"); return new Cookie[] { c }; } public String getRequestURI() { return "fake_uri"; } }; MockHttpServletResponse response = new MockHttpServletResponse() { public void sendRedirect(String url) { assertEquals(url, "fake_uri"); } }; RESTClient restClient = new RESTClient() { public JsonObject sessionCheck(String token) { JsonObject json = new JsonObject(); json.addProperty("authenticated", false); return json; } }; scInterceptor.setRestClient(restClient); assertEquals(scInterceptor.preHandle(request, response, null), false); }
From source file:org.jasig.cas.authentication.principal.SamlServiceTests.java
public void testResponseWithNoTicket() { final MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter("TARGET", "service"); final SamlService impl = SamlService.createServiceFrom(request, null); final Response response = impl.getResponse(null); assertNotNull(response);/*from w w w . ja v a 2s. co m*/ assertEquals(ResponseType.REDIRECT, response.getResponseType()); assertFalse(response.getUrl().contains("SAMLart=")); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.ConceptNameControllerTest.java
@Before public void before() throws Exception { this.service = Context.getConceptService(); this.controller = new ConceptNameController(); this.request = new MockHttpServletRequest(); this.response = new MockHttpServletResponse(); }
From source file:org.raxa.module.raxacore.web.v1_0.controller.DrugPurchaseOrderControllerTest.java
@Before public void before() throws Exception { executeDataSet(MODULE_TEST_DATA_XML); this.request = new MockHttpServletRequest(); this.response = new MockHttpServletResponse(); this.controller = new DrugPurchaseOrderController(); this.service = Context.getService(DrugPurchaseOrderService.class); }
From source file:org.raxa.module.raxacore.web.v1_0.controller.DrugInventoryControllerTest.java
@Before public void before() throws Exception { executeDataSet(MODULE_TEST_DATA_XML); this.request = new MockHttpServletRequest(); this.response = new MockHttpServletResponse(); this.controller = new DrugInventoryController(); this.service = Context.getService(DrugInventoryService.class); }