-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 #4337 from cescoffier/features/fix-filter-and-rout…
…e-hotreload Fix Hot reload when mixing filters and routes
- Loading branch information
Showing
5 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...nsions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/hotreload/DevFilter.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,15 @@ | ||
package io.quarkus.vertx.http.hotreload; | ||
|
||
import javax.enterprise.event.Observes; | ||
|
||
import io.quarkus.vertx.http.runtime.filters.Filters; | ||
|
||
public class DevFilter { | ||
|
||
public void init(@Observes Filters filters) { | ||
filters.register(rc -> { | ||
rc.response().putHeader("X-Header", "AAAA"); | ||
rc.next(); | ||
}, 100); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...ttp/deployment/src/test/java/io/quarkus/vertx/http/hotreload/HotReloadWithFilterTest.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,63 @@ | ||
package io.quarkus.vertx.http.hotreload; | ||
|
||
import static org.hamcrest.core.Is.is; | ||
|
||
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; | ||
import io.restassured.RestAssured; | ||
|
||
public class HotReloadWithFilterTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest test = new QuarkusDevModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClass(DevBean.class) | ||
.addClass(DevFilter.class)); | ||
|
||
private static final String USER_FILE = "DevBean.java"; | ||
private static final String USER_FILTER = "DevFilter.java"; | ||
|
||
@Test | ||
public void testFilterChange() { | ||
RestAssured.when().get("/dev").then() | ||
.statusCode(200) | ||
.body(is("Hello World")) | ||
.header("X-Header", is("AAAA")); | ||
|
||
test.modifySourceFile(USER_FILTER, s -> s.replace("AAAA", "BBBB")); | ||
|
||
RestAssured.when().get("/dev").then() | ||
.statusCode(200) | ||
.body(is("Hello World")) | ||
.header("X-Header", is("BBBB")); | ||
|
||
test.modifySourceFile(USER_FILE, s -> s.replace("World", "Quarkus")); | ||
RestAssured.when().get("/dev").then() | ||
.statusCode(200) | ||
.body(is("Hello Quarkus")) | ||
.header("X-Header", is("BBBB")); | ||
|
||
test.modifySourceFile(USER_FILTER, s -> s.replace("BBBB", "CCC")); | ||
|
||
RestAssured.when().get("/dev").then() | ||
.statusCode(200) | ||
.body(is("Hello Quarkus")) | ||
.header("X-Header", is("CCC")); | ||
|
||
} | ||
|
||
@Test | ||
public void testAddFilter() { | ||
test.addSourceFile(NewFilter.class); | ||
|
||
RestAssured.when().get("/dev").then() | ||
.statusCode(200) | ||
.body(is("Hello World")) | ||
.header("X-Header", is("AAAA")) | ||
.header("X-Header-2", is("Some new header")); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
...nsions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/hotreload/NewFilter.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,15 @@ | ||
package io.quarkus.vertx.http.hotreload; | ||
|
||
import javax.enterprise.event.Observes; | ||
|
||
import io.quarkus.vertx.http.runtime.filters.Filters; | ||
|
||
public class NewFilter { | ||
|
||
public void init(@Observes Filters filters) { | ||
filters.register(rc -> { | ||
rc.response().putHeader("X-Header-2", "Some new header"); | ||
rc.next(); | ||
}, 100); | ||
} | ||
} |
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