-
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.
Browse files
Browse the repository at this point in the history
Ensure that duplicate endpoints don't prevent hot-reload
- Loading branch information
Showing
3 changed files
with
74 additions
and
2 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
48 changes: 48 additions & 0 deletions
48
...uarkus/resteasy/reactive/server/test/duplicate/DuplicateResourceDetectionDevModeTest.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,48 @@ | ||
package io.quarkus.resteasy.reactive.server.test.duplicate; | ||
|
||
import static io.restassured.RestAssured.when; | ||
|
||
import java.util.function.Function; | ||
|
||
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.QuarkusDevModeTest; | ||
|
||
public class DuplicateResourceDetectionDevModeTest { | ||
|
||
@RegisterExtension | ||
static QuarkusDevModeTest TEST = new QuarkusDevModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(GreetingResource3.class, GreetingResource4.class)) | ||
.setAllowFailedStart(true); | ||
|
||
@Test | ||
public void testRestarts() { | ||
// The build should fail initially | ||
when() | ||
.get("/hello-resteasy") | ||
.then() | ||
.statusCode(500); | ||
|
||
TEST.modifySourceFile(GreetingResource4.class.getSimpleName() + ".java", new Function<>() { | ||
@Override | ||
public String apply(String s) { | ||
return s.replace("hello-resteasy", "hello-resteasy2"); | ||
} | ||
}); | ||
|
||
// after changing the paths to remove the collision, the endpoints should work | ||
when() | ||
.get("/hello-resteasy") | ||
.then() | ||
.statusCode(200); | ||
when() | ||
.get("/hello-resteasy2") | ||
.then() | ||
.statusCode(200); | ||
|
||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...t/src/test/java/io/quarkus/resteasy/reactive/server/test/duplicate/GreetingResource4.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,24 @@ | ||
package io.quarkus.resteasy.reactive.server.test.duplicate; | ||
|
||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
@Path("/hello-resteasy") | ||
public class GreetingResource4 { | ||
|
||
@GET | ||
@Consumes(MediaType.APPLICATION_ATOM_XML) | ||
public String helloGet(String tutu) { | ||
return "Hello get"; | ||
} | ||
|
||
@POST | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String helloPost(String yo) { | ||
return "Hello post"; | ||
} | ||
} |