private static RoutingContext withMethod(HttpMethod method) {
        return DefaultRoutingContext.of(virtualHost(), "example.com",
                                        REQ_TARGET, RequestHeaders.of(method, PATH), RoutingStatus.OK,
                                        SessionProtocol.H2C);
    }
")   // Use shortcut.
                     .build();
        assertThat(route.apply(withPath("/foo/baz"), false).isPresent()).isTrue();
        assertThat(route.apply(withPath("/foo/bar"), false).isPresent()).isTrue();
        assertThat(route.apply(withPath("/foo/bar/"), false).isPresent()).isFalse();
        assertThat(route.apply(withPath("/foo/bar/baz"), false).isPresent()).isFalse();
    }

    @Test
    void testRouteExclusionIsEvaluatedAtLast() {
        final Route route = Route.builder()
                                 .pathPrefix(PATH)
                                 .methods(HttpMethod.GET, HttpMethod.POST)
                                 .consumes(MediaType.JSON)
                                 .produces(MediaType.JSON)
                                 .matchesHeaders("x-custom-header", Strings::isNotNullAndNotEmpty)
                                 .matchesParams("custom-param", Strings::isNotNullAndNotEmpty)
                                 .exclude(Route.builder().exact(PATH + "/excluded").build())
                                 .build();

        // Make sure that RoutingResult.empty() and RoutingResult.excluded() are different.
        assertThat(RoutingResult.empty()).isNotEqualTo(RoutingResult.excluded());

        RoutingContext ctx = withRequestHeaders(RequestHeaders.of(HttpMethod.PUT, PATH + "/bar"));
        assertThat(route.apply(ctx, false)).isEqualTo(RoutingResult.empty());
        assertThat(ctx.deferredStatusException().httpStatus()).isEqualTo(HttpStatus.METHOD_NOT_ALLOWED);

        ctx = withRequestHeaders(RequestHeaders.builder()
                                               .method(HttpMethod.POST)
                                               .path(PATH + "/bar")
                                               .contentType(MediaType.APPLICATION_XML_UTF_8)
                                               .build());
        assertThat(route.apply(ctx, false)).isEqualTo(RoutingResult.empty());
        assertThat(ctx.deferredStatusException().httpStatus()).isEqualTo(HttpStatus.UNSUPPORTED_MEDIA_TYPE);

        ctx = withRequestHeaders(
                RequestHeaders.builder()
                              .method(HttpMethod.POST)
                              .path(PATH + "/bar")
                              .add(HttpHeaderNames.ACCEPT, MediaType.APPLICATION_XML_UTF_8.toString())
                              .build());
        assertThat(route.apply(ctx, false)).isEqualTo(RoutingResult.empty());
        assertThat(ctx.deferredStatusException().httpStatus()).isEqualTo(HttpStatus.NOT_ACCEPTABLE);

        // No x-custom-header exists.
        ctx = withRequestHeaders(RequestHeaders.builder()
                                               .method(HttpMethod.POST)
                                               .path(PATH + "/bar")
                                               .contentType(MediaType.JSON)
                                               .add(HttpHeaderNames.ACCEPT, "
core/src/test/java/com/linecorp/armeria/server/RouteTest.java