-
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.
(cherry picked from commit 6b88449)
- Loading branch information
Showing
7 changed files
with
109 additions
and
15 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
13 changes: 9 additions & 4 deletions
13
...ain/java/io/quarkus/resteasy/reactive/server/deployment/ResteasyReactiveServerConfig.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 |
---|---|---|
@@ -1,15 +1,20 @@ | ||
package io.quarkus.resteasy.reactive.server.deployment; | ||
|
||
import java.util.Optional; | ||
|
||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
@ConfigRoot(name = "rest") | ||
public class ResteasyReactiveServerConfig { | ||
|
||
/** | ||
* Set this to override the default path for JAX-RS resources if there are no | ||
* annotated application classes. | ||
* Set this to define the application path that serves as the base URI for all | ||
* JAX-RS resource URIs provided by {@code @Path} annotations when there are no | ||
* {@code @ApplicationPath} annotations defined on {@code Application} classes. | ||
* <p> | ||
* This value is always resolved relative to {@code quarkus.http.root-path}. | ||
*/ | ||
@ConfigItem(defaultValue = "/") | ||
String path; | ||
@ConfigItem | ||
Optional<String> path; | ||
} |
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
29 changes: 29 additions & 0 deletions
29
...src/test/java/io/quarkus/resteasy/reactive/server/test/path/RelativeRestPathTestCase.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,29 @@ | ||
package io.quarkus.resteasy.reactive.server.test.path; | ||
|
||
import org.hamcrest.Matchers; | ||
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; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class RelativeRestPathTestCase { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withConfigurationResource("empty.properties") | ||
.overrideConfigKey("quarkus.rest.path", "foo") | ||
.overrideConfigKey("quarkus.http.root-path", "/app") | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClass(HelloResource.class)); | ||
|
||
@Test | ||
public void testRestPath() { | ||
RestAssured.basePath = "/"; | ||
// This is expected behavior (relative path appended to HTTP root path) | ||
RestAssured.when().get("/app/foo/hello").then().body(Matchers.is("hello")); | ||
RestAssured.when().get("/app/foo/hello/nested").then().body(Matchers.is("world hello")); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
.../test/java/io/quarkus/resteasy/reactive/server/test/path/RestApplicationPathTestCase.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,45 @@ | ||
package io.quarkus.resteasy.reactive.server.test.path; | ||
|
||
import javax.ws.rs.ApplicationPath; | ||
import javax.ws.rs.core.Application; | ||
|
||
import org.hamcrest.Matchers; | ||
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; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class RestApplicationPathTestCase { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withConfigurationResource("empty.properties") | ||
.overrideConfigKey("quarkus.rest.path", "/foo") | ||
.overrideConfigKey("quarkus.http.root-path", "/app") | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(HelloResource.class, BarApp.class)); | ||
|
||
/** | ||
* Using @ApplicationPath will overlay/replace `quarkus.rest.path`. | ||
* Per spec: | ||
* <quote> | ||
* Identifies the application path that serves as the base URI for all resource | ||
* URIs provided by Path. May only be applied to a subclass of Application. | ||
* </quote> | ||
* | ||
* This path will also be relative to the configured HTTP root | ||
*/ | ||
@ApplicationPath("/bar") | ||
public static class BarApp extends Application { | ||
} | ||
|
||
@Test | ||
public void testRestPath() { | ||
RestAssured.basePath = "/"; | ||
RestAssured.when().get("/app/bar/hello").then().body(Matchers.is("hello")); | ||
RestAssured.when().get("/app/bar/hello/nested").then().body(Matchers.is("world hello")); | ||
} | ||
} |
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
Empty file.