コード例 #1
0
 @Test
 public void isSecureWithHttpSchemeAndSecureFlagIsFalse() {
   assertFalse(request.isSecure());
   request.setScheme("http");
   request.setSecure(false);
   assertFalse(request.isSecure());
 }
コード例 #2
0
 @Test
 public void isSecureWithHttpsSchemeAndSecureFlagIsTrue() {
   assertFalse(request.isSecure());
   request.setScheme("https");
   request.setSecure(true);
   assertTrue(request.isSecure());
 }
コード例 #3
0
  private MockHttpServletRequest newMockRequest(
      String method, String requestUri, String host, int port) {
    MockHttpServletRequest req = new MockHttpServletRequest(method, requestUri);
    req.setRemoteHost(host);
    req.setContentType("application/x-www-form-urlencoded");
    req.setRemotePort(port);
    if (port == 443) {
      req.setScheme("https");
      req.setSecure(true);
    } else {
      req.setScheme("http");
      req.setSecure(false);
    }

    return req;
  }