List of usage examples for org.springframework.mock.web MockHttpServletRequest getAttribute
@Override
public Object getAttribute(String name)
From source file:capital.scalable.restdocs.OperationAttributeHelper.java
public static void setAuthorization(MockHttpServletRequest request, String authorization) { ((Map) request.getAttribute(ATTRIBUTE_NAME_CONFIGURATION)).put(AuthorizationSnippet.class.getName(), authorization);// ww w .ja va 2s.c om }
From source file:capital.scalable.restdocs.OperationAttributeHelper.java
public static void initRequestPattern(MockHttpServletRequest request) { String requestPattern = (String) request.getAttribute(BEST_MATCHING_PATTERN_ATTRIBUTE); ((Map) request.getAttribute(ATTRIBUTE_NAME_CONFIGURATION)).put(REQUEST_PATTERN, requestPattern); }
From source file:capital.scalable.restdocs.OperationAttributeHelper.java
public static void setObjectMapper(MockHttpServletRequest request, ObjectMapper objectMapper) { ((Map) request.getAttribute(ATTRIBUTE_NAME_CONFIGURATION)).put(ObjectMapper.class.getName(), objectMapper); }
From source file:capital.scalable.restdocs.OperationAttributeHelper.java
public static void setHandlerMethod(MockHttpServletRequest request, HandlerMethod handlerMethod) { ((Map) request.getAttribute(ATTRIBUTE_NAME_CONFIGURATION)).put(HandlerMethod.class.getName(), handlerMethod);/*from w w w .j a v a 2 s . c o m*/ }
From source file:capital.scalable.restdocs.OperationAttributeHelper.java
public static void setJavadocReader(MockHttpServletRequest request, JavadocReader javadocReader) { ((Map) request.getAttribute(ATTRIBUTE_NAME_CONFIGURATION)).put(JavadocReader.class.getName(), javadocReader);/* w w w . j a v a 2 s .c om*/ }
From source file:capital.scalable.restdocs.OperationAttributeHelper.java
public static void setConstraintReader(MockHttpServletRequest request, ConstraintReader constraintReader) { ((Map) request.getAttribute(ATTRIBUTE_NAME_CONFIGURATION)).put(ConstraintReader.class.getName(), constraintReader);//from w ww . j a va2s.co m }
From source file:com.springsource.greenhouse.signin.AccountExposingHandlerInterceptorTest.java
@Test public void preHandle() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); interceptor.preHandle(request, null, null); assertSame(account, request.getAttribute("account")); }
From source file:fi.okm.mpass.idp.authn.impl.SocialUserAuthServletTest.java
@Test public void testUnmapped() throws Exception { MockHttpServletRequest httpRequest = initHttpRequest(); httpRequest.setRequestURI("/notMapped"); servlet.service(httpRequest, new MockHttpServletResponse()); Assert.assertEquals(httpRequest.getAttribute(ExternalAuthentication.AUTHENTICATION_ERROR_KEY), SocialUserErrorIds.EXCEPTION); }
From source file:com.healthcit.cacure.web.controller.LoginControllerTest.java
@SuppressWarnings("unchecked") @Test//w w w . ja va 2 s.c o m public void testOnSubmitForWithtValidationErrors() { Map inputMap = new HashMap(); inputMap.put(ContentElementEditController.FORM_ID_NAME, 2l); UserCredentials userCredentials = new UserCredentials(); userCredentials.setUserName("Testing"); //userCredentials.setPassword("TestPassword"); BindingResult bindingResult = new BeanPropertyBindingResult(userCredentials, "userCredentials"); MockHttpServletRequest req = new MockHttpServletRequest(); String actual = loginController.onSubmit(userCredentials, bindingResult, req, new MockHttpServletResponse()); Assert.assertNotNull(actual); Assert.assertEquals(bindingResult.getErrorCount(), 1); Assert.assertEquals(req.getAttribute(ATTR_VALIDATION_ERR), Boolean.TRUE); }
From source file:eionet.webq.web.interceptor.CdrAuthorizationInterceptorTest.java
@Test public void whenQueryForUrlThroughInterceptor_IfAllowsToProceedByFailedAttemptsCount_SetRequestAttributeAndResetCounter() throws Exception { when(session.getAttribute(AUTHORIZATION_TRY_COUNT)).thenReturn(ALLOWED_AUTHORIZATION_FAILURES_COUNT); restClientWillThrowException();//from w w w. jav a 2s. c o m MockHttpServletRequest request = requestWithNonEmptyAuthHeader(); assertTrue(interceptor.preHandle(request, new MockHttpServletResponse(), null)); assertNotNull(request.getAttribute(AUTHORIZATION_FAILED_ATTRIBUTE)); verify(session).removeAttribute(AUTHORIZATION_TRY_COUNT); }