List of usage examples for org.springframework.mock.web MockHttpServletRequest getSession
@Override
@Nullable
public HttpSession getSession()
From source file:org.openmrs.contrib.metadatarepository.webapp.filter.LocaleFilterTest.java
public void testSetInvalidLocale() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("locale", "foo"); MockHttpServletResponse response = new MockHttpServletResponse(); request.setSession(new MockHttpSession(null)); filter.doFilter(request, response, new MockFilterChain()); // a locale will get set regardless - there's no such thing as an invalid one assertNotNull(request.getSession().getAttribute(Constants.PREFERRED_LOCALE_KEY)); }
From source file:ejportal.webapp.action.InstitutionActionTest.java
/** * Test remove.//from ww w. j a v a 2s. c o m * * @throws Exception * the exception */ public void testRemove() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(); ServletActionContext.setRequest(request); this.action.setDelete(""); final Institution institution = new Institution(); institution.setId(2L); // action.setInstitution(institution); this.action.setId(2L); Assert.assertEquals("success", this.action.delete()); Assert.assertNotNull(request.getSession().getAttribute("messages")); }
From source file:ejportal.webapp.action.ExemplarActionTest.java
/** * Test remove.//w w w . j ava2 s .c o m * * @throws Exception * the exception */ public void testRemove() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(); ServletActionContext.setRequest(request); this.action.setDelete(""); final Exemplar exemplar = new Exemplar(); exemplar.setExemplarId(2L); // action.setExemplar(exemplar); this.action.setExemplarId(2L); Assert.assertEquals("success", this.action.delete()); Assert.assertNotNull(request.getSession().getAttribute("messages")); }
From source file:ejportal.webapp.action.RechnungActionTest.java
/** * Test remove./* ww w.j av a 2 s . c o m*/ * * @throws Exception * the exception */ public void testRemove() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(); ServletActionContext.setRequest(request); this.action.setDelete(""); final Rechnung rechnung = new Rechnung(); rechnung.setRechnungId(2L); // action.setRechnung(rechnung); this.action.setRechnungId(2L); Assert.assertEquals("success", this.action.delete()); Assert.assertNotNull(request.getSession().getAttribute("messages")); }
From source file:fi.okm.mpass.idp.authn.impl.SocialUserOpenIdConnectStartServletTest.java
/** * Run servlet without {@link AuthenticationContext}. * @throws Exception//from www . j a v a2 s. c om */ @Test public void testNoAuthenticationContext() throws Exception { final MockHttpServletRequest httpRequest = new MockHttpServletRequest(); httpRequest.setParameter(ExternalAuthentication.CONVERSATION_KEY, conversationKey); final ProfileRequestContext<?, ?> ctx = new ProfileRequestContext<>(); httpRequest.setAttribute(ProfileRequestContext.BINDING_KEY, ctx); httpRequest.getSession().setAttribute(ExternalAuthentication.CONVERSATION_KEY + conversationKey, new MockExternalAuthentication()); Assert.assertTrue(runService(servlet, httpRequest, new MockHttpServletResponse())); }
From source file:ejportal.webapp.action.InteresseActionTest.java
/** * Test remove.//from w w w . ja va 2s . c o m * * @throws Exception * the exception */ public void testRemove() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(); ServletActionContext.setRequest(request); this.action.setDelete(""); final Interesse interesse = new Interesse(); interesse.setInteresseId(2L); // action.setInteresse(interesse); this.action.setInteresseId(2L); Assert.assertEquals("success", this.action.delete()); Assert.assertNotNull(request.getSession().getAttribute("messages")); }
From source file:ejportal.webapp.action.BestellerActionTest.java
/** * Test remove.//from w w w. ja va2 s . c om * * @throws Exception * the exception */ public void testRemove() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(); ServletActionContext.setRequest(request); this.action.setDelete(""); final Besteller besteller = new Besteller(); besteller.setBestellerId(2L); // action.setBesteller(besteller); this.action.setBestellerId(2L); Assert.assertEquals("success", this.action.delete()); Assert.assertNotNull(request.getSession().getAttribute("messages")); }
From source file:ejportal.webapp.action.KonsortiumActionTest.java
/** * Test remove.//from www . j a v a2 s . c om * * @throws Exception * the exception */ public void testRemove() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(); ServletActionContext.setRequest(request); this.action.setDelete(""); final Konsortium Konsortium = new Konsortium(); Konsortium.setKonsortiumId(2L); // action.setKonsortium(Konsortium); this.action.setKonsortiumId(2L); Assert.assertEquals("success", this.action.delete()); Assert.assertNotNull(request.getSession().getAttribute("messages")); }
From source file:org.openmrs.contrib.metadatarepository.webapp.controller.PasswordHintControllerTest.java
@Test public void testExecute() throws Exception { MockHttpServletRequest request = newGet("/passwordHint.html"); request.addParameter("username", "user"); // start SMTP Server Wiser wiser = new Wiser(); wiser.setPort(getSmtpPort());/*from ww w . jav a 2s .c o m*/ wiser.start(); c.handleRequest(request); // verify an account information e-mail was sent wiser.stop(); assertTrue(wiser.getMessages().size() == 1); // verify that success messages are in the session assertNotNull(request.getSession().getAttribute(BaseFormController.MESSAGES_KEY)); }
From source file:alpha.portal.webapp.filter.LocaleFilterTest.java
/** * Test locale and country./*from w ww .ja va2s .c o m*/ * * @throws Exception * the exception */ public void testLocaleAndCountry() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(); request.setSession(new MockHttpSession()); request.addParameter("locale", "zh_TW"); final MockHttpServletResponse response = new MockHttpServletResponse(); this.filter.doFilter(request, response, new MockFilterChain()); // session not null, should result in not null final Locale locale = (Locale) request.getSession().getAttribute(Constants.PREFERRED_LOCALE_KEY); Assert.assertNotNull(locale); Assert.assertEquals(new Locale("zh", "TW"), locale); }