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.openmrs1_8.RoleController1_8Test.java
/** * @see RoleController#search(String, javax.servlet.http.HttpServletRequest, HttpServletResponse) * @verifies return no results if there are no matching Roles *///from w w w . j a va 2 s . c o m @Test public void findRoles_shouldReturnNoResultsIfThereAreNoMatchingRoles() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); req.addParameter("q", "Missing Name"); SimpleObject result = deserialize(handle(req)); List<Object> hits = (List<Object>) result.get("results"); Assert.assertEquals(0, hits.size()); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.CohortController1_8Test.java
@Test public void voidCohort_shouldVoidACohort() throws Exception { Cohort cohort = service.getCohort(1); Assert.assertFalse(cohort.isVoided()); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("reason", "unit test"); handle(req);//from w ww. j a v a 2 s . c om cohort = service.getCohort(1); Assert.assertTrue(cohort.isVoided()); Assert.assertEquals("unit test", cohort.getVoidReason()); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.PatientController1_8Test.java
/** * @verifies return delegating resource description * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCustomRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.CustomRepresentation) *///from w w w .ja va 2 s .co m @Test public void getCustomRepresentationDescription_shouldReturnDelegatingResourceDescription() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); req.addParameter("q", "Horatio"); req.addParameter("v", "custom:(uuid,identifiers:(uuid,identifierType:(uuid)),attributes:(uuid,attributeType:(uuid)))"); SimpleObject result = deserialize(handle(req)); assertEquals(1, Util.getResultsSize(result)); assertEquals(getUuid(), PropertyUtils.getProperty(Util.getResultsList(result).get(0), "uuid")); assertNotNull(PropertyUtils.getProperty(Util.getResultsList(result).get(0), "identifiers")); assertNotNull(PropertyUtils.getProperty(Util.getResultsList(result).get(0), "attributes")); }
From source file:fr.paris.lutece.portal.web.system.PluginJspBeanTest.java
public void testGetConfirmUninstallPlugin() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("plugin_name", PLUGIN_NAME); instance.getConfirmUninstallPlugin(request); AdminMessage message = AdminMessageService.getMessage(request); assertNotNull(message);/*from w ww . j av a2s. c om*/ assertTrue(message.getRequestParameters().containsKey(SecurityTokenService.PARAMETER_TOKEN)); }
From source file:fr.paris.lutece.portal.web.system.PluginJspBeanTest.java
public void testDoInstallPlugin() throws AccessDeniedException { assertFalse(PluginService.isPluginEnable(PLUGIN_NAME)); MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("plugin_name", PLUGIN_NAME); request.addParameter(SecurityTokenService.PARAMETER_TOKEN, SecurityTokenService.getInstance().getToken(request, "admin/system/manage_plugins.html")); instance.doInstallPlugin(request, request.getServletContext()); assertTrue(PluginService.isPluginEnable(PLUGIN_NAME)); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.RoleController1_8Test.java
/** * @see RoleController#search(String, javax.servlet.http.HttpServletRequest, HttpServletResponse) * @verifies find matching Roles/*from ww w .j a v a2 s . c o m*/ */ @Test @Ignore("Roles do not support searching yet.") public void findRoles_shouldFindMatchingRoles() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); req.addParameter("q", "Provider"); SimpleObject result = deserialize(handle(req)); List<Object> hits = (List<Object>) result.get("results"); Assert.assertEquals(1, hits.size()); Assert.assertEquals(service.getRoleByUuid("3480cb6d-c291-46c8-8d3a-96dc33d199fb"), PropertyUtils.getProperty(hits.get(0), "uuid")); }
From source file:fr.paris.lutece.portal.web.system.PluginJspBeanTest.java
public void testDoModifyPluginPool() throws AccessDeniedException { assertNull(PluginService.getPlugin(PLUGIN_NAME).getDbPoolName()); MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("plugin_name", PLUGIN_NAME); request.addParameter(PARAM_DB_POOL_NAME, "junit"); request.addParameter(SecurityTokenService.PARAMETER_TOKEN, SecurityTokenService.getInstance().getToken(request, "admin/system/manage_plugins.html")); instance.doModifyPluginPool(request); assertEquals("junit", PluginService.getPlugin(PLUGIN_NAME).getDbPoolName()); }
From source file:fr.paris.lutece.portal.web.system.PluginJspBeanTest.java
public void testDoUninstallPlugin() throws AccessDeniedException { PluginService.getPlugin(PLUGIN_NAME).install(); assertTrue(PluginService.isPluginEnable(PLUGIN_NAME)); MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("plugin_name", PLUGIN_NAME); request.addParameter(SecurityTokenService.PARAMETER_TOKEN, SecurityTokenService.getInstance().getToken(request, "jsp/admin/system/DoUninstallPlugin.jsp")); instance.doUninstallPlugin(request, request.getServletContext()); assertFalse(PluginService.isPluginEnable(PLUGIN_NAME)); }
From source file:fr.paris.lutece.portal.web.system.PluginJspBeanTest.java
public void testDoInstallPluginNoToken() throws AccessDeniedException { assertFalse(PluginService.isPluginEnable(PLUGIN_NAME)); MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("plugin_name", PLUGIN_NAME); try {/*from w w w .j av a 2 s. c o m*/ instance.doInstallPlugin(request, request.getServletContext()); fail("Should have thrown"); } catch (AccessDeniedException e) { assertFalse(PluginService.isPluginEnable(PLUGIN_NAME)); } }
From source file:fr.paris.lutece.portal.web.system.PluginJspBeanTest.java
public void testDoInstallPluginInvalidToken() throws AccessDeniedException { assertFalse(PluginService.isPluginEnable(PLUGIN_NAME)); MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("plugin_name", PLUGIN_NAME); request.addParameter(SecurityTokenService.PARAMETER_TOKEN, SecurityTokenService.getInstance().getToken(request, "admin/system/manage_plugins.html") + "b"); try {/*from w w w.jav a 2s . co m*/ instance.doInstallPlugin(request, request.getServletContext()); fail("Should have thrown"); } catch (AccessDeniedException e) { assertFalse(PluginService.isPluginEnable(PLUGIN_NAME)); } }