forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make subresource handling for interfaces more nuanced
We don't want to create subresources for interfaces that are used by multiple resource classes for the purpose of reusing resource methods and JAX-RS annotations Fixes: quarkusio#34657
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 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
80 changes: 80 additions & 0 deletions
80
.../resteasy/reactive/server/test/resource/basic/MultipleResourceImplementInterfaceTest.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,80 @@ | ||
package io.quarkus.resteasy.reactive.server.test.resource.basic; | ||
|
||
import static io.restassured.RestAssured.when; | ||
import static org.hamcrest.CoreMatchers.is; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
import org.jboss.resteasy.reactive.RestPath; | ||
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; | ||
|
||
public class MultipleResourceImplementInterfaceTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest testExtension = new QuarkusUnitTest() | ||
.setArchiveProducer(new Supplier<>() { | ||
@Override | ||
public JavaArchive get() { | ||
JavaArchive war = ShrinkWrap.create(JavaArchive.class); | ||
war.addClass(HelloResource.class); | ||
war.addClass(Hello2Resource.class); | ||
war.addClass(Shared.class); | ||
return war; | ||
} | ||
}); | ||
|
||
@Test | ||
public void hello() { | ||
when().get("/hello") | ||
.then().statusCode(200).body(is("hello")); | ||
|
||
when().get("/hello/shared/1") | ||
.then().statusCode(200).body(is("1")); | ||
} | ||
|
||
@Test | ||
public void hello2() { | ||
when().get("/hello2") | ||
.then().statusCode(200).body(is("hello2")); | ||
|
||
when().get("/hello2/shared/h2") | ||
.then().statusCode(200).body(is("h2")); | ||
} | ||
|
||
@Path("/hello") | ||
public static class HelloResource implements Shared { | ||
|
||
@GET | ||
public String hello() { | ||
return "hello"; | ||
} | ||
|
||
} | ||
|
||
@Path("/hello2") | ||
public static class Hello2Resource implements Shared { | ||
|
||
@GET | ||
public String hello() { | ||
return "hello2"; | ||
} | ||
|
||
} | ||
|
||
public interface Shared { | ||
|
||
@GET | ||
@Path("/shared/{id}") | ||
default String version(@RestPath String id) { | ||
return id; | ||
} | ||
} | ||
} |