-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25489 from Postremus/issues/25462
Refine how resource classes with same components are merged
- Loading branch information
Showing
2 changed files
with
178 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...t/java/org/jboss/resteasy/reactive/server/vertx/test/matching/ResourceClassMergeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package org.jboss.resteasy.reactive.server.vertx.test.matching; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.jboss.resteasy.reactive.server.vertx.test.framework.ResteasyReactiveUnitTest; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class ResourceClassMergeTest { | ||
@RegisterExtension | ||
static ResteasyReactiveUnitTest test = new ResteasyReactiveUnitTest() | ||
.setArchiveProducer(new Supplier<>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(MatchDefaultRegexDifferentNameResourceA.class, | ||
MatchDefaultRegexDifferentNameResourceB.class, MatchCustomRegexDifferentNameResourceA.class, | ||
MatchCustomRegexDifferentNameResourceB.class); | ||
} | ||
}); | ||
|
||
@Test | ||
public void testCallMatchDefaultRegexDifferentNameResource() { | ||
given() | ||
.when().get("routing-broken/abc/some/other/path") | ||
.then() | ||
.statusCode(200) | ||
.body(is("abc")); | ||
|
||
given() | ||
.when().get("routing-broken/efg/some/path") | ||
.then() | ||
.statusCode(200) | ||
.body(is("efg")); | ||
} | ||
|
||
@Test | ||
public void testCallMatchCustomRegexDifferentNameResource() { | ||
given() | ||
.when().get("routing-broken-custom-regex/abc/some/other/path") | ||
.then() | ||
.statusCode(200) | ||
.body(is("abc")); | ||
|
||
given() | ||
.when().get("routing-broken-custom-regex/efg/some/path") | ||
.then() | ||
.statusCode(200) | ||
.body(is("efg")); | ||
} | ||
|
||
@Path("/routing-broken/{id1}") | ||
public static class MatchDefaultRegexDifferentNameResourceA { | ||
@GET | ||
@Path("/some/other/path") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Response doSomething(@PathParam("id1") String id) { | ||
return Response.ok(id).build(); | ||
} | ||
} | ||
|
||
@Path("/routing-broken/{id}") | ||
public static class MatchDefaultRegexDifferentNameResourceB { | ||
@GET | ||
@Path("/some/path") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Response doSomething(@PathParam("id") String id) { | ||
return Response.ok(id).build(); | ||
} | ||
} | ||
|
||
@Path("/routing-broken-custom-regex/{id1: [a-zA-Z]+}") | ||
public static class MatchCustomRegexDifferentNameResourceA { | ||
@GET | ||
@Path("/some/other/path") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Response doSomething(@PathParam("id1") String id) { | ||
return Response.ok(id).build(); | ||
} | ||
} | ||
|
||
@Path("/routing-broken-custom-regex/{id: [a-zA-Z]+}") | ||
public static class MatchCustomRegexDifferentNameResourceB { | ||
@GET | ||
@Path("/some/path") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Response doSomething(@PathParam("id") String id) { | ||
return Response.ok(id).build(); | ||
} | ||
} | ||
} |