Пример #1
0
  public Map<String, String> getHeaders() {
    final Map<String, String> headersCopy = new HashMap<String, String>(headers);
    final Set<Map.Entry<String, String>> entrySet = headersCopy.entrySet();
    this.headers.clear();
    for (final Map.Entry<String, String> entry : entrySet) {
      this.headers.put(StringUtils.toLower(entry.getKey()), entry.getValue());
    }

    return headers;
  }
Пример #2
0
  public static StubRequest createFromHttpServletRequest(final HttpServletRequest request)
      throws IOException {
    final StubRequest assertionRequest =
        StubRequest.newStubRequest(
            request.getPathInfo(), HandlerUtils.extractPostRequestBody(request, "stubs"));
    assertionRequest.addMethod(request.getMethod());

    final Enumeration<String> headerNamesEnumeration = request.getHeaderNames();
    final List<String> headerNames =
        ObjectUtils.isNotNull(headerNamesEnumeration)
            ? Collections.list(request.getHeaderNames())
            : new LinkedList<String>();
    for (final String headerName : headerNames) {
      final String headerValue = request.getHeader(headerName);
      assertionRequest.getHeaders().put(StringUtils.toLower(headerName), headerValue);
    }

    assertionRequest.getQuery().putAll(CollectionUtils.constructParamMap(request.getQueryString()));

    return assertionRequest;
  }