From ea9f8419c94a908ade8ca2dd517c3c07e911db0b Mon Sep 17 00:00:00 2001 From: Manfred Riem Date: Wed, 9 Oct 2024 16:57:22 -0500 Subject: [PATCH] Fixes #4043 - Update Piranha Servlet - Create a Pages application guide (#4044) --- test/servlet/pages/.gitignore | 1 + test/servlet/pages/README.md | 6 + test/servlet/pages/pom.xml | 122 ++++++++++++++++++ .../pages/src/main/webapp/hellopages.jsp | 12 ++ .../pages/src/test/java/hello/HelloIT.java | 28 ++++ test/servlet/pom.xml | 1 + 6 files changed, 170 insertions(+) create mode 100644 test/servlet/pages/.gitignore create mode 100644 test/servlet/pages/README.md create mode 100644 test/servlet/pages/pom.xml create mode 100644 test/servlet/pages/src/main/webapp/hellopages.jsp create mode 100644 test/servlet/pages/src/test/java/hello/HelloIT.java diff --git a/test/servlet/pages/.gitignore b/test/servlet/pages/.gitignore new file mode 100644 index 000000000..2f7896d1d --- /dev/null +++ b/test/servlet/pages/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/test/servlet/pages/README.md b/test/servlet/pages/README.md new file mode 100644 index 000000000..91eab9102 --- /dev/null +++ b/test/servlet/pages/README.md @@ -0,0 +1,6 @@ + +# Create a Jakarta Pages application on Piranha Servlet + +See [Create a Jakarta Pages application on Piranha Servlet](https://piranha.cloud/servlet/guides/pages) +for the step by step guide. This repository contains the resulting project for +your reference. diff --git a/test/servlet/pages/pom.xml b/test/servlet/pages/pom.xml new file mode 100644 index 000000000..b861a05a4 --- /dev/null +++ b/test/servlet/pages/pom.xml @@ -0,0 +1,122 @@ + + + + 4.0.0 + + + cloud.piranha.test.servlet + project + 24.10.0-SNAPSHOT + + cloud.piranha.test.servlet + pages + 24.10.0-SNAPSHOT + war + Piranha - Test - Servlet - Jakarta Pages application + + + 5.10.2 + 24.4.0 + + 21 + servlet + UTF-8 + + 3.13.0 + 3.2.5 + 3.4.0 + + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit.version} + test + + + + pages + + + cloud.piranha.maven.plugins + piranha-maven-plugin + ${piranha.version} + + + pre-integration-test + pre-integration-test + + start + + + + post-integration-test + post-integration-test + + stop + + + + + servlet + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${java.version} + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${maven-failsafe-plugin.version} + + + + integration-test + verify + + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + false + + + + + diff --git a/test/servlet/pages/src/main/webapp/hellopages.jsp b/test/servlet/pages/src/main/webapp/hellopages.jsp new file mode 100644 index 000000000..a5b8c26a1 --- /dev/null +++ b/test/servlet/pages/src/main/webapp/hellopages.jsp @@ -0,0 +1,12 @@ +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + + + +

Hello from Jakarta Pages!

+ + diff --git a/test/servlet/pages/src/test/java/hello/HelloIT.java b/test/servlet/pages/src/test/java/hello/HelloIT.java new file mode 100644 index 000000000..2eb000593 --- /dev/null +++ b/test/servlet/pages/src/test/java/hello/HelloIT.java @@ -0,0 +1,28 @@ +package hello; + +import java.net.URI; +import java.net.http.HttpClient; +import static java.net.http.HttpClient.Redirect.ALWAYS; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; +import java.time.Duration; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; + +public class HelloIT { + + @Test + public void testHelloPagesJsp() throws Exception { + HttpClient client = HttpClient + .newBuilder() + .connectTimeout(Duration.ofSeconds(60)) + .followRedirects(ALWAYS) + .build(); + HttpRequest request = HttpRequest + .newBuilder(new URI("http://localhost:8080/pages/hellopages.jsp")) + .build(); + HttpResponse response = client.send(request, BodyHandlers.ofString()); + assertTrue(response.body().contains("Hello from Jakarta Pages!")); + } +} diff --git a/test/servlet/pom.xml b/test/servlet/pom.xml index 73191fca3..d5967d881 100644 --- a/test/servlet/pom.xml +++ b/test/servlet/pom.xml @@ -34,5 +34,6 @@ faces hello helloworld + pages