本文整理匯總了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));
}