From 7b56d91b5cdb397467f7de6e5c3523f94792459b Mon Sep 17 00:00:00 2001 From: Stephane Epardaud Date: Fri, 10 Jun 2022 16:07:30 +0200 Subject: [PATCH] Test for #25932: content type incorrect for Qute templates --- .../reactive/qute/deployment/ItemResource.java | 12 ++++++++++++ .../qute/deployment/VariantTemplateTest.java | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-qute/deployment/src/test/java/io/quarkus/resteasy/reactive/qute/deployment/ItemResource.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-qute/deployment/src/test/java/io/quarkus/resteasy/reactive/qute/deployment/ItemResource.java index 5e913fa1cb6ef..e4ab08e1c5844 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-qute/deployment/src/test/java/io/quarkus/resteasy/reactive/qute/deployment/ItemResource.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-qute/deployment/src/test/java/io/quarkus/resteasy/reactive/qute/deployment/ItemResource.java @@ -7,12 +7,18 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import io.quarkus.qute.CheckedTemplate; import io.quarkus.qute.Template; import io.quarkus.qute.TemplateInstance; @Path("item") public class ItemResource { + @CheckedTemplate + public static class Templates { + public static native TemplateInstance item(Item item); + } + @Inject Template item; @@ -23,6 +29,12 @@ public TemplateInstance get(@PathParam("id") Integer id) { return item.data(new Item(id, "foo")); } + @GET + @Path("checked/{id}") + public TemplateInstance getChecked(@PathParam("id") Integer id) { + return Templates.item(new Item(id, "foo")); + } + public static class Item { public final Integer price; diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-qute/deployment/src/test/java/io/quarkus/resteasy/reactive/qute/deployment/VariantTemplateTest.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-qute/deployment/src/test/java/io/quarkus/resteasy/reactive/qute/deployment/VariantTemplateTest.java index 3aeea509de1c9..509f8dc9859ac 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-qute/deployment/src/test/java/io/quarkus/resteasy/reactive/qute/deployment/VariantTemplateTest.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-qute/deployment/src/test/java/io/quarkus/resteasy/reactive/qute/deployment/VariantTemplateTest.java @@ -18,13 +18,17 @@ public class VariantTemplateTest { .addClasses(ItemResource.class, Item.class) .addAsResource(new StringAsset("Item {name}: {price}"), "templates/item.txt") .addAsResource(new StringAsset("Item {name}: {price}"), - "templates/item.html")); + "templates/item.html") + .addAsResource(new StringAsset("Item {item.name}: {item.price}"), + "templates/ItemResource/item.html")); @Test public void testVariant() { given().when().accept("text/plain").get("/item/10").then().contentType("text/plain").body(Matchers.is("Item foo: 10")); given().when().accept("text/html").get("/item/20").then().contentType("text/html") .body(Matchers.is("Item foo: 20")); + given().when().get("/item/checked/20").then().contentType("text/html") + .body(Matchers.is("Item foo: 20")); } }