Skip to content

Commit

Permalink
Fixes #4043 - Update Piranha Servlet - Create a Pages application gui…
Browse files Browse the repository at this point in the history
…de (#4044)
  • Loading branch information
mnriem authored Oct 9, 2024
1 parent c05dfe2 commit ea9f841
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/servlet/pages/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
6 changes: 6 additions & 0 deletions test/servlet/pages/README.md
Original file line number Diff line number Diff line change
@@ -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.
122 changes: 122 additions & 0 deletions test/servlet/pages/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>

<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--
WARNING - Do not remove the versions in the properties section as this
particular project is used as a basis for the guide content at
docs/src/site/markdown/servlet/create_a_jakarta_pages_application.md.
When updating the guide do the following:
1. Drop the parent part below
2. Change the name of the project to read 'Create a Jakara Pages application'
3. Change the piranha.version to the latest released version of Piranha
-->
<parent>
<groupId>cloud.piranha.test.servlet</groupId>
<artifactId>project</artifactId>
<version>24.10.0-SNAPSHOT</version>
</parent>
<groupId>cloud.piranha.test.servlet</groupId>
<artifactId>pages</artifactId>
<version>24.10.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Piranha - Test - Servlet - Jakarta Pages application</name>
<properties>
<!-- dependencies -->
<junit.version>5.10.2</junit.version>
<piranha.version>24.4.0</piranha.version>
<!-- other -->
<java.version>21</java.version>
<piranha.distribution>servlet</piranha.distribution>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- plugins -->
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<maven-failsafe-plugin.version>3.2.5</maven-failsafe-plugin.version>
<maven-war-plugin.version>3.4.0</maven-war-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>pages</finalName>
<plugins>
<plugin>
<groupId>cloud.piranha.maven.plugins</groupId>
<artifactId>piranha-maven-plugin</artifactId>
<version>${piranha.version}</version>
<executions>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<distribution>servlet</distribution>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<release>${java.version}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
12 changes: 12 additions & 0 deletions test/servlet/pages/src/main/webapp/hellopages.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h1>Hello from Jakarta Pages!</h1>
</body>
</html>
28 changes: 28 additions & 0 deletions test/servlet/pages/src/test/java/hello/HelloIT.java
Original file line number Diff line number Diff line change
@@ -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<String> response = client.send(request, BodyHandlers.ofString());
assertTrue(response.body().contains("Hello from Jakarta Pages!"));
}
}
1 change: 1 addition & 0 deletions test/servlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
<module>faces</module>
<module>hello</module>
<module>helloworld</module>
<module>pages</module>
</modules>
</project>

0 comments on commit ea9f841

Please sign in to comment.