List of usage examples for org.springframework.mock.web MockHttpServletRequest MockHttpServletRequest
public MockHttpServletRequest()
From source file:org.araneaframework.tests.framework.container.StandardWidgetContainerWidgetTests.java
public void setUp() throws Exception { child = new MockEventfulStandardWidget(); parent = new StandardWidgetContainerWidget(); parent.setChildWidget(child);/*w w w .j a va2s . c o m*/ MockLifeCycle.begin(parent); req = new MockHttpServletRequest(); res = new MockHttpServletResponse(); input = new StandardServletInputData(req); output = new StandardServletOutputData(req, res); path = MockUtil.getPath(); }
From source file:org.openmrs.module.kenyaemr.EmrExternalUrlInterceptorTest.java
@Before public void setup() { interceptor = new EmrExternalUrlInterceptor(); interceptor.adminService = adminService; interceptor.kenyaUi = kenyaui;/*from w w w . j a v a 2 s .c o m*/ request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); }
From source file:com.baidu.rigel.test.strut2.AbstractStruts2SpringContextTests.java
/** * Execute before test method./*from w w w.j av a 2 s .c o m*/ */ public void executeBeforeTestMethod() { response = new MockHttpServletResponse(); request = new MockHttpServletRequest(); pageContext = new MockPageContext(); servletContext = new MockServletContext(); ActionContext context = new ActionContext(new HashMap<String, Object>()); ServletActionContext.setContext(context); ServletActionContext.setRequest(request); ServletActionContext.setResponse(response); }
From source file:org.jmesa.limit.state.SessionStateTest.java
@Test public void retrieveLimitFromRequest() { MockHttpServletRequest request = new MockHttpServletRequest(); WebContext webContext = new HttpServletRequestWebContext(request); webContext.setSessionAttribute(ID + "_LIMIT", new Limit(ID)); SessionState state = new SessionState(); state.setId(ID);//w w w . j a v a2s .com state.setStateAttr("restore"); state.setWebContext(webContext); Limit limit = state.retrieveLimit(); assertNull("The limit is not null.", limit); // should be null until pass parameter request.setAttribute("restore", "true"); limit = state.retrieveLimit(); assertNotNull("The limit is null.", limit); // should now not be null }
From source file:org.opensaml.ws.security.provider.HTTPRuleTest.java
/** * Builds a mock {@link HttpServletRequest}. * /*w w w.jav a 2s. c o m*/ * @return the mock request */ protected MockHttpServletRequest buildServletRequest() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setContentType(contentType); request.setMethod(method); request.setSecure(requireSecured); return request; }
From source file:com.google.api.server.spi.handlers.ExplorerHandlerTest.java
private void testHandle(String scheme, int port, String expectedLocation) throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.setScheme(scheme);/*from w w w. jav a 2s. c om*/ request.setServerName("localhost"); request.setServerPort(port); request.setRequestURI("/_ah/api/explorer/"); MockHttpServletResponse response = new MockHttpServletResponse(); ExplorerHandler handler = new ExplorerHandler(); EndpointsContext context = new EndpointsContext("GET", "explorer", request, response); handler.handle(context); assertThat(response.getStatus()).isEqualTo(HttpServletResponse.SC_FOUND); assertThat(response.getHeader("Location")).isEqualTo(expectedLocation); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.PersonNameControllerTest.java
@Before public void before() throws Exception { this.service = Context.getPersonService(); this.controller = new PersonNameController(); this.request = new MockHttpServletRequest(); this.response = new MockHttpServletResponse(); }
From source file:org.jtalks.common.web.util.SuccessfulAuthenticationHandlerTest.java
@Test public void testOnAuthenticationSuccess() throws Exception { User user = new User("username", "email", "password"); Authentication auth = mock(Authentication.class); when(auth.getPrincipal()).thenReturn(user); handler.onAuthenticationSuccess(new MockHttpServletRequest(), new MockHttpServletResponse(), auth); verify(userService).updateLastLoginTime(user); }
From source file:com.cognicap.site.web.controllers.ReservationControllerTest.java
@Test public void testSubmitForm() { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); request.setMethod("GET"); ModelAndView mav = null;/* w ww . j ava2 s. c om*/ try { mav = controller.onSubmit(request, response, registration, null); } catch (Exception e) { e.printStackTrace(); } LOGGER.debug(mav.getViewName()); assertEquals("confirmationReception", mav.getViewName()); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.EncounterTypeControllerTest.java
@Before public void before() { this.service = Context.getEncounterService(); this.controller = new EncounterTypeController(); this.request = new MockHttpServletRequest(); this.response = new MockHttpServletResponse(); }