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

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

Introduction

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

Prototype

public void setRequestURI(@Nullable String requestURI) 

Source Link

Usage

From source file:org.openmrs.module.clinicalsummary.web.service.PatientSummaryControllerTest.java

/**
 * @verifies return summary data for patient and summary
 * @see org.openmrs.module.clinicalsummary.web.controller.service.PatientSummaryController#searchSummary(String, String, String, Integer, javax.servlet.http.HttpServletResponse)
 *//*from  w w  w  . j  av  a 2  s . c o  m*/
@Test
public void searchSummary_shouldReturnSummaryDataForPatientAndSummary() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setMethod("GET");
    request.setRequestURI("/module/clinicalsummary/service/patient/summary");
    request.setParameter("username", "admin");
    request.setParameter("password", "test");
    request.setParameter("patientId", "7");
    request.setParameter("summaryId", "3");

    MockHttpServletResponse response = new MockHttpServletResponse();
    HandlerAdapter handlerAdapter = new AnnotationMethodHandlerAdapter();
    handlerAdapter.handle(request, response, controller);

    Assert.assertFalse(StringUtils.isNotEmpty(response.getContentAsString()));
}

From source file:org.openmrs.module.clinicalsummary.web.service.PatientSummaryControllerTest.java

/**
 * @verifies return empty data when no index found for the patient and summary
 * @see org.openmrs.module.clinicalsummary.web.controller.service.PatientSummaryController#searchSummary(String, String, String, Integer, javax.servlet.http.HttpServletResponse)
 *//*w ww.  j a va  2s . c  om*/
@Test
public void searchSummary_shouldReturnEmptyDataWhenNoIndexFoundForThePatientAndSummary() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setMethod("GET");
    request.setRequestURI("/module/clinicalsummary/service/patient/summary");
    request.setParameter("username", "admin");
    request.setParameter("password", "test");
    request.setParameter("patientId", "7");
    request.setParameter("summaryId", "4");

    MockHttpServletResponse response = new MockHttpServletResponse();
    HandlerAdapter handlerAdapter = new AnnotationMethodHandlerAdapter();
    handlerAdapter.handle(request, response, controller);

    Assert.assertFalse(StringUtils.isNotEmpty(response.getContentAsString()));
}

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)
 *//* w  w w  . j a  v  a 2  s.c om*/
@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.web.FlowExecutionExceptionResolverTests.java

@Test
public void testNoSuchFlowExecutionException() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("test");
    ModelAndView model = this.resolver.resolveException(request, new MockHttpServletResponse(), null,
            new NoSuchFlowExecutionException(new FlowExecutionKey() {

                private static final long serialVersionUID = 1443616250214416520L;

                @Override/* w w  w  .  j a  v a  2s. c o  m*/
                public String toString() {
                    return "test";
                }

                @Override
                public boolean equals(final Object o) {
                    return true;
                }

                @Override
                public int hashCode() {
                    return 0;
                }
            }, new RuntimeException()));

    assertEquals(request.getRequestURI(), ((RedirectView) model.getView()).getUrl());
}

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

@Test
public void testNoSuchFlowExecutionExeptionWithQueryString() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("test");
    request.setQueryString("test=test");
    ModelAndView model = this.resolver.resolveException(request, new MockHttpServletResponse(), null,
            new NoSuchFlowExecutionException(new FlowExecutionKey() {

                private static final long serialVersionUID = -4750073902540974152L;

                @Override//ww  w. j  a va2 s .c o m
                public String toString() {
                    return "test";
                }

                @Override
                public boolean equals(final Object o) {
                    return true;
                }

                @Override
                public int hashCode() {
                    return 0;
                }
            }, new RuntimeException()));

    assertEquals(request.getRequestURI() + "?" + request.getQueryString(),
            ((RedirectView) model.getView()).getUrl());
}

From source file:org.openmrs.module.clinicalsummary.web.service.PatientSearchControllerTest.java

/**
 * @verifies should return empty list when no patient match search term
 * @see org.openmrs.module.clinicalsummary.web.controller.service.PatientSearchController#searchPatient(String, String, String, javax.servlet.http.HttpServletResponse)
 *///from   ww  w  . j  ava 2 s  .  c o  m
@Test
public void searchPatient_shouldReturnEmptyListWhenNoPatientMatchSearchTerm() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setMethod("GET");
    request.setRequestURI("/module/clinicalsummary/service/patient/search");
    request.setParameter("term", "999-3");
    request.setParameter("username", "admin");
    request.setParameter("password", "test");

    MockHttpServletResponse response = new MockHttpServletResponse();
    HandlerAdapter handlerAdapter = new AnnotationMethodHandlerAdapter();
    handlerAdapter.handle(request, response, controller);

    Assert.assertTrue(StringUtils.isNotEmpty(response.getContentAsString()));
    Assert.assertFalse(StringUtils.contains(response.getContentAsString(), "999-3"));
}

From source file:org.openmrs.module.clinicalsummary.web.service.PatientSearchControllerTest.java

/**
 * @verifies should return patients with name search term
 * @see org.openmrs.module.clinicalsummary.web.controller.service.PatientSearchController#searchPatient(String, String, String, javax.servlet.http.HttpServletResponse)
 *//*from   ww w .j  a  va  2s .co  m*/
@Test
public void searchPatient_shouldReturnPatientsWithNameSearchTerm() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setMethod("GET");
    request.setRequestURI("/module/clinicalsummary/service/patient/search");
    request.setParameter("term", "Collet");
    request.setParameter("username", "admin");
    request.setParameter("password", "test");

    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.openmrs.module.clinicalsummary.web.service.PatientSearchControllerTest.java

/**
 * @verifies should return patients with identifier search term
 * @see org.openmrs.module.clinicalsummary.web.controller.service.PatientSearchController#searchPatient(String, String, String, javax.servlet.http.HttpServletResponse)
 *///from   w  w  w. j  a v a  2 s .c  om
@Test
public void searchPatient_shouldReturnPatientsWithIdentifierSearchTerm() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setMethod("GET");
    request.setRequestURI("/module/clinicalsummary/service/patient/search");
    request.setParameter("term", "6TS-4");
    request.setParameter("username", "admin");
    request.setParameter("password", "test");

    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:nl.ctrlaltdev.harbinger.whitelist.WhiteListParserTest.java

@Test
public void shouldParseUrl() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("/pindakaas");
    Evidence ev = new Evidence(request);

    assertTrue(parser.parse("url:/pindakaas").isWhitelisted(ev));
    assertFalse(parser.parse("url:/wodkasju").isWhitelisted(ev));
}

From source file:fi.okm.mpass.idp.authn.impl.YleIdentityTest.java

/**
 * Runs getRedirectUrl with empty {@link HttpServletRequest}.
 * @throws Exception/*w ww.j a v a2s .  c  om*/
 */
@Test
public void testRedirectNoAuthzEndpoint() throws Exception {
    final YleIdentity yleId = initYleIdentity();
    final MockHttpServletRequest httpRequest = new MockHttpServletRequest();
    httpRequest.setRequestURI("/mock/");
    Assert.assertNull(yleId.getRedirectUrl(httpRequest));
}