本文整理汇总了Java中org.springframework.mock.web.MockHttpServletRequest.setCookies方法的典型用法代码示例。如果您正苦于以下问题:Java MockHttpServletRequest.setCookies方法的具体用法?Java MockHttpServletRequest.setCookies怎么用?Java MockHttpServletRequest.setCookies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.mock.web.MockHttpServletRequest
的用法示例。
在下文中一共展示了MockHttpServletRequest.setCookies方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyTgtToSetRemovingOldTgt
import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void verifyTgtToSetRemovingOldTgt() throws Exception {
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockHttpServletRequest request = new MockHttpServletRequest();
final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
when(tgt.getId()).thenReturn("test");
request.setCookies(new Cookie("TGT", "test5"));
WebUtils.putTicketGrantingTicketInScopes(this.context, tgt);
this.context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
assertEquals("success", this.action.execute(this.context).getId());
request.setCookies(response.getCookies());
assertEquals(tgt.getId(), this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:SendTicketGrantingTicketActionTests.java
示例2: verifySsoSessionCookieOnRenewAsParameter
import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void verifySsoSessionCookieOnRenewAsParameter() throws Exception {
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(CasProtocolConstants.PARAMETER_RENEW, "true");
final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
when(tgt.getId()).thenReturn("test");
request.setCookies(new Cookie("TGT", "test5"));
WebUtils.putTicketGrantingTicketInScopes(this.context, tgt);
this.context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
this.action.setCreateSsoSessionCookieOnRenewAuthentications(false);
assertEquals("success", this.action.execute(this.context).getId());
assertEquals(0, response.getCookies().length);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:SendTicketGrantingTicketActionTests.java
示例3: verifySsoSessionCookieOnServiceSsoDisallowed
import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void verifySsoSessionCookieOnServiceSsoDisallowed() throws Exception {
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockHttpServletRequest request = new MockHttpServletRequest();
final WebApplicationService svc = mock(WebApplicationService.class);
when(svc.getId()).thenReturn("TestSsoFalse");
final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
when(tgt.getId()).thenReturn("test");
request.setCookies(new Cookie("TGT", "test5"));
WebUtils.putTicketGrantingTicketInScopes(this.context, tgt);
this.context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
this.context.getFlowScope().put("service", svc);
this.action.setCreateSsoSessionCookieOnRenewAuthentications(false);
assertEquals("success", this.action.execute(this.context).getId());
assertEquals(0, response.getCookies().length);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:SendTicketGrantingTicketActionTests.java
示例4: verifyTgtToSet
import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void verifyTgtToSet() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setRemoteAddr(LOCALHOST_IP);
request.setLocalAddr(LOCALHOST_IP);
ClientInfoHolder.setClientInfo(new ClientInfo(request));
final MockHttpServletResponse response = new MockHttpServletResponse();
request.addHeader("User-Agent", "Test");
final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
when(tgt.getId()).thenReturn(TEST_STRING);
WebUtils.putTicketGrantingTicketInScopes(this.context, tgt);
this.context.setExternalContext(new ServletExternalContext(new MockServletContext(),
request, response));
assertEquals(SUCCESS, this.action.execute(this.context).getId());
request.setCookies(response.getCookies());
assertEquals(tgt.getId(), this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request));
}
示例5: verifySsoSessionCookieOnRenewAsParameter
import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void verifySsoSessionCookieOnRenewAsParameter() throws Exception {
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(CasProtocolConstants.PARAMETER_RENEW, "true");
final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
when(tgt.getId()).thenReturn(TEST_STRING);
request.setCookies(new Cookie("TGT", "test5"));
WebUtils.putTicketGrantingTicketInScopes(this.context, tgt);
this.context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
final SendTicketGrantingTicketAction action = new SendTicketGrantingTicketAction(centralAuthenticationService, servicesManager,
ticketGrantingTicketCookieGenerator, false);
assertEquals(SUCCESS, action.execute(this.context).getId());
assertEquals(0, response.getCookies().length);
}
示例6: verifySsoSessionCookieOnServiceSsoDisallowed
import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void verifySsoSessionCookieOnServiceSsoDisallowed() throws Exception {
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockHttpServletRequest request = new MockHttpServletRequest();
final WebApplicationService svc = mock(WebApplicationService.class);
when(svc.getId()).thenReturn("TestSsoFalse");
final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
when(tgt.getId()).thenReturn(TEST_STRING);
request.setCookies(new Cookie("TGT", "test5"));
WebUtils.putTicketGrantingTicketInScopes(this.context, tgt);
this.context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
this.context.getFlowScope().put("service", svc);
final SendTicketGrantingTicketAction action = new SendTicketGrantingTicketAction(centralAuthenticationService, servicesManager,
ticketGrantingTicketCookieGenerator, false);
assertEquals(SUCCESS, action.execute(this.context).getId());
assertEquals(0, response.getCookies().length);
}
示例7: testServiceTicketFromCookie
import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void testServiceTicketFromCookie() throws Exception {
MockRequestContext context = new MockRequestContext();
context.getFlowScope().put("service", TestUtils.getService());
context.getFlowScope().put("ticketGrantingTicketId", this.ticketGrantingTicket);
MockHttpServletRequest request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
request.addParameter("service", "service");
request.setCookies(new Cookie[] {new Cookie("TGT",
this.ticketGrantingTicket)});
this.action.execute(context);
assertNotNull(WebUtils.getServiceTicketFromRequestScope(context));
}
示例8: verifyServiceTicketFromCookie
import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void verifyServiceTicketFromCookie() throws Exception {
final MockRequestContext context = new MockRequestContext();
context.getFlowScope().put("service", org.jasig.cas.services.TestUtils.getService());
context.getFlowScope().put("ticketGrantingTicketId", this.ticketGrantingTicket.getId());
final MockHttpServletRequest request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
request.addParameter("service", "service");
request.setCookies(new Cookie("TGT", this.ticketGrantingTicket.getId()));
this.action.execute(context);
assertNotNull(WebUtils.getServiceTicketFromRequestScope(context));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:16,代码来源:GenerateServiceTicketActionTests.java
示例9: testCookieRetrieve
import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void testCookieRetrieve() {
final MockHttpServletRequest request = new MockHttpServletRequest();
final Cookie cookie = new Cookie("test", "test");
cookie.setDomain("cas.org");
cookie.setMaxAge(5);
request.setCookies(new Cookie[] {cookie});
assertEquals("test", this.g.retrieveCookieValue(request));
}
示例10: verifyServiceTicketFromCookie
import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void verifyServiceTicketFromCookie() throws Exception {
final MockRequestContext context = new MockRequestContext();
context.getFlowScope().put("service", TestUtils.getService());
context.getFlowScope().put("ticketGrantingTicketId", this.ticketGrantingTicket.getId());
final MockHttpServletRequest request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
request.addParameter("service", "service");
request.setCookies(new Cookie("TGT", this.ticketGrantingTicket.getId()));
this.action.execute(context);
assertNotNull(WebUtils.getServiceTicketFromRequestScope(context));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:16,代码来源:GenerateServiceTicketActionTests.java
示例11: verifyTgtToSet
import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void verifyTgtToSet() throws Exception {
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockHttpServletRequest request = new MockHttpServletRequest();
final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
when(tgt.getId()).thenReturn("test");
WebUtils.putTicketGrantingTicketInScopes(this.context, tgt);
this.context.setExternalContext(new ServletExternalContext(new MockServletContext(),
request, response));
assertEquals("success", this.action.execute(this.context).getId());
request.setCookies(response.getCookies());
assertEquals(tgt.getId(), this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:16,代码来源:SendTicketGrantingTicketActionTests.java
示例12: verifyCookieAddWithRememberMe
import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void verifyCookieAddWithRememberMe() {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(RememberMeCredential.REQUEST_PARAMETER_REMEMBER_ME, "true");
final MockHttpServletResponse response = new MockHttpServletResponse();
this.generator.addCookie(request, response, "test");
request.setCookies(response.getCookies());
final Cookie c = response.getCookie("test");
assertEquals(100, c.getMaxAge());
assertEquals("test", this.generator.retrieveCookieValue(request));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:14,代码来源:CookieRetrievingCookieGeneratorTests.java
示例13: verifyServiceTicketFromCookie
import org.springframework.mock.web.MockHttpServletRequest; //导入方法依赖的package包/类
@Test
public void verifyServiceTicketFromCookie() throws Exception {
final MockRequestContext context = new MockRequestContext();
context.getFlowScope().put(SERVICE_PARAM, RegisteredServiceTestUtils.getService());
context.getFlowScope().put("ticketGrantingTicketId", this.ticketGrantingTicket.getId());
final MockHttpServletRequest request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(
new MockServletContext(), request, new MockHttpServletResponse()));
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, SERVICE_PARAM);
request.setCookies(new Cookie("TGT", this.ticketGrantingTicket.getId()));
this.action.execute(context);
assertNotNull(WebUtils.getServiceTicketFromRequestScope(context));
}