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.
Merge pull request quarkusio#39030 from Ladicek/fault-tolerance-hot-r…
…eload-test Fault Tolerance: add simple test for hot reload
- Loading branch information
Showing
4 changed files
with
72 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
21 changes: 21 additions & 0 deletions
21
...oyment/src/test/java/io/quarkus/smallrye/faulttolerance/test/hotreload/HotReloadBean.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,21 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.hotreload; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.eclipse.microprofile.faulttolerance.Fallback; | ||
|
||
@ApplicationScoped | ||
public class HotReloadBean { | ||
@Fallback(fallbackMethod = "fallback1") | ||
public String hello() { | ||
throw new RuntimeException(); | ||
} | ||
|
||
public String fallback1() { | ||
return "fallback1"; | ||
} | ||
|
||
public String fallback2() { | ||
return "fallback2"; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...yment/src/test/java/io/quarkus/smallrye/faulttolerance/test/hotreload/HotReloadRoute.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.smallrye.faulttolerance.test.hotreload; | ||
|
||
import jakarta.enterprise.event.Observes; | ||
import jakarta.inject.Singleton; | ||
|
||
import io.vertx.ext.web.Router; | ||
|
||
@Singleton | ||
public class HotReloadRoute { | ||
public void route(@Observes Router router, HotReloadBean bean) { | ||
router.get("/").handler(ctx -> { | ||
ctx.response().setStatusCode(200).end(bean.hello()); | ||
}); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...oyment/src/test/java/io/quarkus/smallrye/faulttolerance/test/hotreload/HotReloadTest.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,26 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.hotreload; | ||
|
||
import static io.restassured.RestAssured.when; | ||
import static org.hamcrest.CoreMatchers.is; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
public class HotReloadTest { | ||
@RegisterExtension | ||
final static QuarkusDevModeTest test = new QuarkusDevModeTest() | ||
.withApplicationRoot(jar -> jar.addClasses(HotReloadBean.class, HotReloadRoute.class)); | ||
|
||
@Test | ||
public void test() { | ||
when().get("/").then().statusCode(200).body(is("fallback1")); | ||
|
||
test.modifySourceFile("HotReloadBean.java", src -> { | ||
return src.replace("fallbackMethod = \"fallback1\"", "fallbackMethod = \"fallback2\""); | ||
}); | ||
|
||
when().get("/").then().statusCode(200).body(is("fallback2")); | ||
} | ||
} |