Package com.github.tomakehurst.wiremock.matching

Examples of com.github.tomakehurst.wiremock.matching.RequestPattern.addHeader()


    private RequestPattern buildRequestPatternFrom(Request request) {
        RequestPattern requestPattern = new RequestPattern(request.getMethod(), request.getUrl());
        if (!headersToMatch.isEmpty()) {
            for (HttpHeader header: request.getHeaders().all()) {
                if (headersToMatch.contains(header.caseInsensitiveKey())) {
                    requestPattern.addHeader(header.key(), ValuePattern.equalTo(header.firstValue()));
                }
            }
        }

        String body = request.getBodyAsString();
View Full Code Here


  public RequestPattern build() {
    RequestPattern requestPattern = new RequestPattern();
    requestPattern.setMethod(method);
    urlMatchingStrategy.contributeTo(requestPattern);
    for (Map.Entry<String, ValueMatchingStrategy> header: headers.entrySet()) {
      requestPattern.addHeader(header.getKey(), header.getValue().asValuePattern());
    }

        for (String key: withoutHeaders) {
            requestPattern.addHeader(key, ValuePattern.absent());
        }
View Full Code Here

    for (Map.Entry<String, ValueMatchingStrategy> header: headers.entrySet()) {
      requestPattern.addHeader(header.getKey(), header.getValue().asValuePattern());
    }

        for (String key: withoutHeaders) {
            requestPattern.addHeader(key, ValuePattern.absent());
        }

        for (Map.Entry<String, ValueMatchingStrategy> queryParam: queryParameters.entrySet()) {
            requestPattern.addQueryParam(queryParam.getKey(), queryParam.getValue().asValuePattern());
        }
View Full Code Here

    @Test
    public void supportsMatchingOnAbsentHeader() {
        ignoringNotifier();

        RequestPattern requestPattern = new RequestPattern(GET, "/without/header");
        requestPattern.addHeader("X-My-Header", ValuePattern.absent());
        Request request = aRequest(context)
                .withUrl("/without/header")
                .withMethod(GET)
                .withHeader("X-Another-Header", "value")
                .build();
View Full Code Here

    @Test
    public void shouldFailMatchWhenRequiredAbsentHeaderIsPresent() {
        ignoringNotifier();

        RequestPattern requestPattern = new RequestPattern(GET, "/without/header/fail");
        requestPattern.addHeader("X-My-Header", ValuePattern.absent());
        Request request = aRequest(context)
                .withUrl("/without/header/fail")
                .withMethod(GET)
                .withHeader("X-My-Header", "value")
                .build();
View Full Code Here

    }});
   
    RequestPattern requestPattern = new RequestPattern(POST, "/for/logging");
    ValuePattern headerPattern = new ValuePattern();
    headerPattern.setEqualTo("text/xml");
    requestPattern.addHeader("Content-Type", headerPattern);
   
    Request request = aRequest(context)
      .withUrl("/for/logging")
      .withMethod(POST)
      .withHeader("Content-Type", "text/plain")
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.