-
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.
Dev mode: add QuteWatchedResourceTest
- Loading branch information
Showing
3 changed files
with
91 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
32 changes: 32 additions & 0 deletions
32
integration-tests/devmode/src/test/java/io/quarkus/test/qute/HelloResource.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,32 @@ | ||
package io.quarkus.test.qute; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
import org.jboss.resteasy.reactive.RestQuery; | ||
|
||
import io.quarkus.qute.Engine; | ||
import io.quarkus.qute.Template; | ||
|
||
@Path("hello") | ||
public class HelloResource { | ||
|
||
@Inject | ||
Template hello; | ||
|
||
@Inject | ||
Engine engine; | ||
|
||
@GET | ||
public String get(@RestQuery String name) { | ||
return hello.data("name", name).render(); | ||
} | ||
|
||
@GET | ||
@Path("ping") | ||
public String ping() { | ||
return engine.getTemplate("ping").render(); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
integration-tests/devmode/src/test/java/io/quarkus/test/qute/QuteWatchedResourceTest.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,51 @@ | ||
package io.quarkus.test.qute; | ||
|
||
import static io.restassured.RestAssured.when; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
public class QuteWatchedResourceTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest config = new QuarkusDevModeTest() | ||
.withApplicationRoot( | ||
root -> root.addClass(HelloResource.class) | ||
.addAsResource(new StringAsset("Hello {name}!"), "templates/hello.txt")); | ||
|
||
@Test | ||
public void testWatchedFiles() { | ||
when().get("/hello?name=Martin").then() | ||
.body(containsString("Hello Martin!")) | ||
.statusCode(200); | ||
|
||
config.modifyResourceFile("templates/hello.txt", file -> "Hi {name}!"); | ||
|
||
when().get("/hello?name=Martin").then() | ||
.body(containsString("Hi Martin!")) | ||
.statusCode(200); | ||
|
||
config.modifyResourceFile("templates/hello.txt", file -> "Hello {name}!"); | ||
|
||
when().get("/hello?name=Martin").then() | ||
.body(containsString("Hello Martin!")) | ||
.statusCode(200); | ||
|
||
config.addResourceFile("templates/ping.txt", "pong"); | ||
|
||
when().get("/hello/ping").then() | ||
.body(containsString("pong")) | ||
.statusCode(200); | ||
|
||
config.modifyResourceFile("templates/ping.txt", file -> "pong!"); | ||
|
||
when().get("/hello/ping").then() | ||
.body(containsString("pong!")) | ||
.statusCode(200); | ||
} | ||
|
||
} |