Package com.github.tomakehurst.wiremock.matching

Examples of com.github.tomakehurst.wiremock.matching.RequestPattern


  public void shouldLogMessageIndicatingFailedMethodMatch() {
    context.checking(new Expectations() {{
      one(notifier).info("URL /for/logging is match, but method GET is not");
    }});
   
    RequestPattern requestPattern = new RequestPattern(POST, "/for/logging");
   
    Request request = aRequest(context)
      .withUrl("/for/logging")
      .withMethod(GET)
      .build();
   
    requestPattern.isMatchedBy(request);
  }
View Full Code Here


  public void shouldLogMessageIndicatingFailedHeaderMatch() {
    context.checking(new Expectations() {{
      one(notifier).info("URL /for/logging is match, but header Content-Type is not. For a match, value should equal text/xml");
    }});
   
    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")
      .build();
   
    requestPattern.isMatchedBy(request);
  }
View Full Code Here

  public void shouldLogMessageIndicatingFailedBodyMatch() {
    context.checking(new Expectations() {{
      one(notifier).info("URL /for/logging is match, but body is not: Actual Content");
    }});
   
    RequestPattern requestPattern = new RequestPattern(POST, "/for/logging");
    requestPattern.setBodyPatterns(asList(ValuePattern.matches("Expected content")));
   
    Request request = aRequest(context)
      .withUrl("/for/logging")
      .withMethod(POST)
      .withBody("Actual Content")
      .build();
   
    requestPattern.isMatchedBy(request);
  }
View Full Code Here

 
  @Test
  public void shouldVerifyRequestMadeWhenCountMoreThan0() {
    context.checking(new Expectations() {{
      allowing(admin).countRequestsMatching(
                    new RequestPattern(RequestMethod.DELETE, "/to/delete")); will(returnValue(VerificationResult.withCount(3)));
    }});
   
    UrlMatchingStrategy urlStrategy = new UrlMatchingStrategy();
    urlStrategy.setUrl("/to/delete");
    wireMock.verifyThat(new RequestPatternBuilder(RequestMethod.DELETE, urlStrategy));
View Full Code Here

  public static ResponseDefinitionBuilder aResponse() {
    return new ResponseDefinitionBuilder();
  }
 
  public void verifyThat(RequestPatternBuilder requestPatternBuilder) {
    RequestPattern requestPattern = requestPatternBuilder.build();
        VerificationResult result = admin.countRequestsMatching(requestPattern);
        result.assertRequestJournalEnabled();

    if (result.getCount() < 1) {
      throw new VerificationException(requestPattern, find(allRequests()));
View Full Code Here

      throw new VerificationException(requestPattern, find(allRequests()));
    }
  }

  public void verifyThat(int count, RequestPatternBuilder requestPatternBuilder) {
    RequestPattern requestPattern = requestPatternBuilder.build();
        VerificationResult result = admin.countRequestsMatching(requestPattern);
        result.assertRequestJournalEnabled();

    if (result.getCount() != count) {
            throw new VerificationException(requestPattern, count, find(allRequests()));
View Full Code Here

    headers.add(new HttpHeader(key, value));
    return this;
  }
 
  public StubMapping build() {
    RequestPattern requestPattern = new RequestPattern(method, url);
    ResponseDefinition response = new ResponseDefinition(responseStatus, responseBody);
    response.setHeaders(new HttpHeaders(headers));
    StubMapping mapping = new StubMapping(requestPattern, response);
    return mapping;
  }
View Full Code Here

    "}                        ";
 
  @Test
  public void shouldReturnCountOfMatchingRequests() {
    context.checking(new Expectations() {{
      RequestPattern requestPattern = new RequestPattern(DELETE, "/some/resource");
      allowing(admin).countRequestsMatching(requestPattern); will(returnValue(VerificationResult.withCount(5)));
    }});
   
    Response response = handler.handle(aRequest(context)
        .withUrl("/requests/count")
View Full Code Here

TOP

Related Classes of com.github.tomakehurst.wiremock.matching.RequestPattern

Copyright © 2018 www.massapicom. 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.