@Test public void endingSlashNotTakenIntoAccount() throws IOException { RecordedRequest recordedRequest = createRecordedRequest("/foo/bar/"); RequestMatcher matcher = RequestMatchers.pathEndsWith("bar"); assertTrue(matcher.matches(recordedRequest)); }
public static RequestMatcher pathEndsWith(final String urlPart) { return new RequestMatcher("path ends with: " + urlPart) { @Override protected boolean matchesSafely(RecordedRequest item) { String urlPartWithoutEndingSlash = urlPart.replaceAll("/$", ""); String itemPathWithoutEndingSlash = item.getPath().replaceAll("/$", ""); return itemPathWithoutEndingSlash.toLowerCase(Locale.US).endsWith(urlPartWithoutEndingSlash.toLowerCase(Locale.US)); } }; }
RequestMatchers { public static RequestMatcher pathEndsWith(final String urlPart) { return new RequestMatcher("path ends with: " + urlPart) { @Override protected boolean matchesSafely(RecordedRequest item) { String urlPartWithoutEndingSlash = urlPart.replaceAll("/$", ""); String itemPathWithoutEndingSlash = item.getPath().replaceAll("/$", ""); return itemPathWithoutEndingSlash.toLowerCase(Locale.US).endsWith(urlPartWithoutEndingSlash.toLowerCase(Locale.US)); } }; } }
RequestMatchers { public static RequestMatcher pathEndsWith(final String urlPart) { return new RequestMatcher("path ends with: " + urlPart) { @Override protected boolean matchesSafely(RecordedRequest item) { String urlPartWithoutEndingSlash = urlPart.replaceAll("/$", ""); String itemPathWithoutEndingSlash = item.getPath().replaceAll("/$", ""); return itemPathWithoutEndingSlash.toLowerCase(Locale.US).endsWith(urlPartWithoutEndingSlash.toLowerCase(Locale.US)); } }; } private  RequestMatchers(); }
RequestMatchers { public static RequestMatcher pathEndsWith(final String urlPart) { return new RequestMatcher("path ends with: " + urlPart) { @Override protected boolean matchesSafely(RecordedRequest item) { String urlPartWithoutEndingSlash = urlPart.replaceAll("/$", ""); String itemPathWithoutEndingSlash = item.getPath().replaceAll("/$", ""); return itemPathWithoutEndingSlash.toLowerCase(Locale.US).endsWith(urlPartWithoutEndingSlash.toLowerCase(Locale.US)); } }; } private  RequestMatchers(); static RequestMatcher pathContains(final String urlPart); static RequestMatcher pathDoesNotContain(final String urlPart); static RequestMatcher pathMatchesRegex(final String pattern); static RequestMatcher pathEndsWith(final String urlPart); static RequestMatcher pathEndsWithIgnoringQueryParams(final String endOfUrlPath); static RequestMatcher pathStartsWith(final String urlPart); static RequestMatcher hasHeaderNames(final String... headerNames); static RequestMatcher hasQueryParameters(); static RequestMatcher hasQueryParameterNames(final String... expectedParamsNames); static RequestMatcher hasExactQueryParameters(final QueryParam... expectedParams); static RequestMatcher httpMethodIs(final String method); static RequestMatcher isGET(); static RequestMatcher isPOST(); static RequestMatcher isPATCH(); static RequestMatcher isDELETE(); static RequestMatcher isPUT(); static RequestMatcher isHEAD(); }
RequestMatchers { public static RequestMatcher pathEndsWith(final String urlPart) { return new RequestMatcher("path ends with: " + urlPart) { @Override protected boolean matchesSafely(RecordedRequest item) { String urlPartWithoutEndingSlash = urlPart.replaceAll("/$", ""); String itemPathWithoutEndingSlash = item.getPath().replaceAll("/$", ""); return itemPathWithoutEndingSlash.toLowerCase(Locale.US).endsWith(urlPartWithoutEndingSlash.toLowerCase(Locale.US)); } }; } private  RequestMatchers(); static RequestMatcher pathContains(final String urlPart); static RequestMatcher pathDoesNotContain(final String urlPart); static RequestMatcher pathMatchesRegex(final String pattern); static RequestMatcher pathEndsWith(final String urlPart); static RequestMatcher pathEndsWithIgnoringQueryParams(final String endOfUrlPath); static RequestMatcher pathStartsWith(final String urlPart); static RequestMatcher hasHeaderNames(final String... headerNames); static RequestMatcher hasQueryParameters(); static RequestMatcher hasQueryParameterNames(final String... expectedParamsNames); static RequestMatcher hasExactQueryParameters(final QueryParam... expectedParams); static RequestMatcher httpMethodIs(final String method); static RequestMatcher isGET(); static RequestMatcher isPOST(); static RequestMatcher isPATCH(); static RequestMatcher isDELETE(); static RequestMatcher isPUT(); static RequestMatcher isHEAD();  }