本文整理汇总了Java中org.springframework.mock.web.MockHttpServletResponse.setStatus方法的典型用法代码示例。如果您正苦于以下问题:Java MockHttpServletResponse.setStatus方法的具体用法?Java MockHttpServletResponse.setStatus怎么用?Java MockHttpServletResponse.setStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.mock.web.MockHttpServletResponse
的用法示例。
在下文中一共展示了MockHttpServletResponse.setStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loginUnsuccessfully
import org.springframework.mock.web.MockHttpServletResponse; //导入方法依赖的package包/类
@Override
protected MockHttpServletResponse loginUnsuccessfully(final String username, final String fromAddress) throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockHttpServletResponse response = new MockHttpServletResponse();
request.setMethod("POST");
request.setParameter("username", username);
request.setRemoteAddr(fromAddress);
final MockRequestContext context = new MockRequestContext();
context.setCurrentEvent(new Event(StringUtils.EMPTY, "error"));
request.setAttribute("flowRequestContext", context);
ClientInfoHolder.setClientInfo(new ClientInfo(request));
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
throttle.preHandle(request, response, null);
try {
authenticationManager.authenticate(AuthenticationTransaction.wrap(CoreAuthenticationTestUtils.getService(), badCredentials(username)));
} catch (final AuthenticationException e) {
throttle.postHandle(request, response, null, null);
return response;
}
fail("Expected AbstractAuthenticationException");
return null;
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:25,代码来源:InspektrThrottledSubmissionByIpAddressAndUsernameHandlerInterceptorAdapterTests.java
示例2: loginUnsuccessfully
import org.springframework.mock.web.MockHttpServletResponse; //导入方法依赖的package包/类
@Override
protected MockHttpServletResponse loginUnsuccessfully(final String username, final String fromAddress) throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockHttpServletResponse response = new MockHttpServletResponse();
request.setMethod("POST");
request.setParameter("username", username);
request.setRemoteAddr(fromAddress);
final MockRequestContext context = new MockRequestContext();
context.setCurrentEvent(new Event(StringUtils.EMPTY, "error"));
request.setAttribute("flowRequestContext", context);
response.setStatus(HttpStatus.UNAUTHORIZED.value());
throttle.preHandle(request, response, null);
throttle.postHandle(request, response, null, null);
return response;
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:16,代码来源:AbstractInMemoryThrottledSubmissionHandlerInterceptorAdapterTests.java
示例3: redirectsAreShunted
import org.springframework.mock.web.MockHttpServletResponse; //导入方法依赖的package包/类
@Test
public void redirectsAreShunted() {
MockHttpServletResponse response = new MockHttpServletResponse();
response.setStatus(302);
assertThat(ServletTags.uri(null, response).getValue()).isEqualTo("REDIRECTION");
}
示例4: notFoundsAreShunted
import org.springframework.mock.web.MockHttpServletResponse; //导入方法依赖的package包/类
@Test
public void notFoundsAreShunted() {
MockHttpServletResponse response = new MockHttpServletResponse();
response.setStatus(404);
assertThat(ServletTags.uri(null, response).getValue()).isEqualTo("NOT_FOUND");
}