forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quarkusio#42687 handle trailing slash
- Loading branch information
1 parent
89baf33
commit 0acbda3
Showing
2 changed files
with
108 additions
and
8 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
89 changes: 89 additions & 0 deletions
89
...x/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/matching/RegexPathTest.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,89 @@ | ||
package org.jboss.resteasy.reactive.server.vertx.test.matching; | ||
|
||
import static io.restassured.RestAssured.get; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
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 RegexPathTest { | ||
|
||
@RegisterExtension | ||
static ResteasyReactiveUnitTest test = new ResteasyReactiveUnitTest() | ||
.setArchiveProducer(new Supplier<>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(EndingSlashTest.TestResource.class); | ||
} | ||
}); | ||
|
||
@Test | ||
public void test() { | ||
|
||
get("/hello/world/1") | ||
.then() | ||
.statusCode(200) | ||
.body(equalTo("Hello World! 1")); | ||
|
||
get("/hello/world/1/") | ||
.then() | ||
.statusCode(200) | ||
.body(equalTo("Hello World! 1")); | ||
|
||
get("/hello/again/1") | ||
.then() | ||
.statusCode(200) | ||
.body(equalTo("Hello Again! 1")); | ||
|
||
get("/hello/again/1/") | ||
.then() | ||
.statusCode(200) | ||
.body(equalTo("Hello Again! 1")); | ||
|
||
get("/hello/again/2/surprise") | ||
.then() | ||
.statusCode(200) | ||
.body(equalTo("Hello Surprise! 2")); | ||
|
||
get("/hello/again/2/surprise/") | ||
.then() | ||
.statusCode(200) | ||
.body(equalTo("Hello Surprise! 2")); | ||
} | ||
|
||
@Path("/hello") | ||
public static class TestResource { | ||
|
||
@GET | ||
@Path("/world/{sample}") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String hello(int sample) { | ||
return "Hello World! " + sample; | ||
} | ||
|
||
@GET | ||
@Path("/again/{sample:\\d+}") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String helloWithRegex(int sample) { | ||
return "Hello Again! " + sample; | ||
} | ||
|
||
@GET | ||
@Path("/again/{sample:\\d+}/surprise") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String helloWithRegexSecond(int sample) { | ||
return "Hello Surprise! " + sample; | ||
} | ||
} | ||
} |