List of usage examples for org.springframework.mock.web MockHttpServletResponse MockHttpServletResponse
MockHttpServletResponse
From source file:com.xemantic.tadedon.gwt.rpc.mock.RemoteServiceMethodInterceptor.java
/** {@inheritDoc} */ @Override/*from www . ja v a 2 s .c o m*/ public Object invoke(MethodInvocation invocation) throws Throwable { MethodInvokingFilterChain chain = new MethodInvokingFilterChain(invocation); MockHttpServletRequest request = servletContainer.newRequest("POST", "/gwt.rpc"); guiceFilter.doFilter(request, new MockHttpServletResponse(), chain); Throwable throwable = chain.getThrowable(); if (throwable != null) { throw throwable; } return chain.getResult(); }
From source file:org.openmrs.contrib.metadatarepository.webapp.controller.UserFormControllerTest.java
@Test public void testAdd() throws Exception { log.debug("testing add new user..."); request = newGet("/userform.html"); request.addParameter("method", "Add"); request.addUserRole(Constants.ADMIN_ROLE); user = c.showForm(request, new MockHttpServletResponse()); assertNull(user.getUsername());/* w w w . ja va2s . co m*/ }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.ConceptClassControllerTest.java
@Before public void before() { this.service = Context.getConceptService(); this.controller = new ConceptClassController(); this.request = new MockHttpServletRequest(); this.response = new MockHttpServletResponse(); }
From source file:org.raxa.module.raxacore.web.v1_0.controller.RaxaAlertControllerTest.java
@Before public void before() throws Exception { executeDataSet(MODULE_TEST_DATA_XML); this.request = new MockHttpServletRequest(); this.response = new MockHttpServletResponse(); this.controller = new RaxaAlertController(); this.service = Context.getService(RaxaAlertService.class); }
From source file:org.cloudfoundry.identity.api.web.ApiControllerTests.java
@Test public void testWithUser() throws Exception { controller.setInfo(new ClassPathResource("info.tmpl")); HashMap<String, Object> model = new HashMap<String, Object>(); View view = controller.info(model, new UsernamePasswordAuthenticationToken("marissa", "<NONE>")); MockHttpServletResponse response = new MockHttpServletResponse(); view.render(model, new MockHttpServletRequest(), response); String content = response.getContentAsString(); assertTrue("Wrong content: " + content, content.contains("\n \"user\": \"marissa\"")); }
From source file:org.araneaframework.tests.framework.container.StandardServiceContainerServiceTests.java
public void setUp() throws Exception { child = new MockEventfulStandardService(); parent = new StandardServiceContainerService(); parent.setChildService(child);// w ww.j a va 2 s .com 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.hdiv.filter.ValidatorErrorHandlerTest.java
public void testValidatorErrorHandler() { HttpServletRequest request = HDIVUtil.getHttpServletRequest(); MockHttpSession session = (MockHttpSession) request.getSession(); session.setNew(false); // mark as not new sesssion MockHttpServletResponse response = new MockHttpServletResponse(); this.validatorErrorHandler.handleValidatorError(request, response, HDIVErrorCodes.REQUIRED_PARAMETERS); String redirectUrl = response.getRedirectedUrl(); assertEquals(getConfig().getErrorPage(), redirectUrl); }
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:fr.xebia.servlet.filter.SecuredRemoteAddressFilterTest.java
private void testRemoteAddr(String remoteAddr, boolean expected) throws ServletException, IOException { SecuredRemoteAddressFilter filter = new SecuredRemoteAddressFilter(); MockFilterConfig filterConfig = new MockFilterConfig(); filter.init(filterConfig);//from w w w . ja v a 2 s .c om final AtomicBoolean secured = new AtomicBoolean(); MockFilterChain filterChain = new MockFilterChain() { @Override public void doFilter(ServletRequest request, ServletResponse response) { secured.set(request.isSecure()); } }; MockHttpServletRequest request = new MockHttpServletRequest(); request.setRemoteAddr(remoteAddr); filter.doFilter(request, new MockHttpServletResponse(), filterChain); assertEquals(expected, secured.get()); }
From source file:com.hp.autonomy.frontend.find.idol.view.IdolViewControllerTest.java
@Override @Before/*from ww w .java 2s. c o m*/ public void setUp() { viewServerService = idolViewServerService; viewController = new IdolViewController(viewServerService, configService, controllerUtils); response = new MockHttpServletResponse(); super.setUp(); }