Skip to content

Commit

Permalink
Qute: add integration test for test templates
Browse files Browse the repository at this point in the history
- i.e. add a test with templates in both (1)
src/main/resources/templates and (2) src/test/resources/templates
  • Loading branch information
mkouba committed May 2, 2024
1 parent 0f29d73 commit 5a17f1d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions integration-tests/qute/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-qute</artifactId>
<artifactId>quarkus-rest-qute</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down Expand Up @@ -51,7 +51,7 @@
<!-- Minimal test dependencies to *-deployment artifacts for consistent build order -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-qute-deployment</artifactId>
<artifactId>quarkus-rest-qute-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.quarkus.it.qute;

import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;

import io.quarkus.qute.Template;
import io.quarkus.qute.TemplateInstance;

@Path("/hi")
public class HiResource {

@Inject
Template hi;

@GET
@Produces(MediaType.TEXT_PLAIN)
public TemplateInstance get(@QueryParam("name") String name) {
return hi.data("name", name);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import static jakarta.ws.rs.core.Response.Status.NOT_FOUND;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.DisabledOnIntegrationTest;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
Expand Down Expand Up @@ -33,4 +35,12 @@ public void testNotFoundPageStatusCode() {
.body(containsString("Not Found!"))
.statusCode(NOT_FOUND.getStatusCode());
}

// Keep in mind that src/test/java is not part of the native image
@DisabledOnIntegrationTest
@Test
public void testTemplateLocatedInTestSource() {
RestAssured.when().get("/hi?name=Ciri").then().body(equalTo("Hi Ciri!"));
}

}
1 change: 1 addition & 0 deletions integration-tests/qute/src/test/resources/templates/hi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hi {name}!

0 comments on commit 5a17f1d

Please sign in to comment.