Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3995 - Update Piranha Server - Create a Hello World web application guide #3997

Merged
merged 2 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ Create an empty directory to store your Maven project. Inside of that directory
<modelVersion>4.0.0</modelVersion>
<groupId>cloud.piranha.guides.server</groupId>
<artifactId>helloworld</artifactId>
<version>24.10.0-SNAPSHOT</version>
<version>24.9.0</version>
<packaging>war</packaging>
<name>Piranha Server - HelloWorld web application</name>
<name>Create a Hello World application</name>
<properties>
<java.version>17</java.version>
<junit.version>5.10.0-M1</junit.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<maven-failsafe-plugin.version>3.0.0</maven-failsafe-plugin.version>
<maven-war-plugin.version>3.3.2</maven-war-plugin.version>
<!-- dependencies -->
<junit.version>5.11.0</junit.version>
<!-- other -->
<java.version>21</java.version>
<piranha.distribution>server</piranha.distribution>
<piranha.version>23.6.0</piranha.version>
<piranha.version>${project.version}</piranha.version>
<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.5.0</maven-failsafe-plugin.version>
<maven-war-plugin.version>3.4.0</maven-war-plugin.version>
</properties>
<dependencies>
<dependency>
Expand All @@ -62,7 +65,7 @@ Create an empty directory to store your Maven project. Inside of that directory
<finalName>helloworld</finalName>
<plugins>
<plugin>
<groupId>cloud.piranha.maven.plugins</groupId>
<groupId>cloud.piranha.maven</groupId>
<artifactId>piranha-maven-plugin</artifactId>
<version>${piranha.version}</version>
<executions>
Expand Down
110 changes: 57 additions & 53 deletions test/server/helloworld/pom.xml
Original file line number Diff line number Diff line change
@@ -1,77 +1,70 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<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/server/create_a_hello_world_web_application.md.

When updating the guide drop the parent part below and change the name to
read 'Create a Hello World application'.

-->
<parent>
<groupId>cloud.piranha.test.server</groupId>
<artifactId>project</artifactId>
<version>24.10.0-SNAPSHOT</version>
</parent>

<artifactId>piranha-test-server-helloworld</artifactId>
<groupId>cloud.piranha.guides.server</groupId>
<artifactId>helloworld</artifactId>
<version>24.10.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>Piranha - Test - Server - Hello World</name>

<name>Piranha - Test - Server - Hello World application</name>
<properties>
<!-- dependencies -->
<junit.version>5.11.0</junit.version>
<!-- other -->
<java.version>21</java.version>
<piranha.distribution>server</piranha.distribution>
<piranha.version>${project.version}</piranha.version>
<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.5.0</maven-failsafe-plugin.version>
<maven-war-plugin.version>3.4.0</maven-war-plugin.version>
</properties>

<dependencies>
<!-- provided -->
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<scope>provided</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!--

This dependency is here to make sure piranha-dist-server.zip exists
prior to executing the tests when building in parallel.

-->
<dependency>
<groupId>cloud.piranha.dist</groupId>
<artifactId>piranha-dist-server</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
<type>zip</type>
<optional>true</optional>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>piranha-test-server-helloworld</finalName>
<finalName>helloworld</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<portNames>
<portName>httpPort</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>cloud.piranha.maven</groupId>
<artifactId>piranha-maven-plugin</artifactId>
<version>${project.version}</version>
<version>${piranha.version}</version>
<executions>
<execution>
<id>pre-integration-test</id>
Expand All @@ -89,23 +82,34 @@
</execution>
</executions>
<configuration>
<distribution>server</distribution>
<httpPort>${httpPort}</httpPort>
<distribution>${piranha.distribution}</distribution>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<forkCount>1</forkCount>
<systemPropertyVariables>
<httpPort>${httpPort}</httpPort>
</systemPropertyVariables>
<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>
Expand Down

This file was deleted.

18 changes: 0 additions & 18 deletions test/server/helloworld/src/main/webapp/WEB-INF/web.xml

This file was deleted.

12 changes: 12 additions & 0 deletions test/server/helloworld/src/main/webapp/helloworld.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>

<html>
<head>
<title>Hello World</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>Hello World!</div>
</body>
</html>
13 changes: 0 additions & 13 deletions test/server/helloworld/src/main/webapp/helloworld.jsp

This file was deleted.

31 changes: 3 additions & 28 deletions test/server/helloworld/src/test/java/helloworld/HelloWorldIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,13 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;

/**
* The 'Hello World!' integration tests.
*
* @author Manfred Riem (mriem@manorrock.com)
*/
class HelloWorldIT {

/**
* Test the 'helloworld.jsp' page.
*
* @throws Exception when a serious error occurs.
*/
@Test
void testHelloWorldJsp() throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest
.newBuilder(new URI("http://localhost:" + System.getProperty("httpPort") + "/piranha-test-server-helloworld/helloworld.jsp"))
.build();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
assertTrue(response.body().contains("Hello World!"));
}

/**
* Test the HelloWorldServlet.
*
* @throws Exception when a serious error occurs.
*/

@Test
void testHelloWorldServlet() throws Exception {
void testHelloWorldHtml() throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest
.newBuilder(new URI("http://localhost:" + System.getProperty("httpPort") + "/piranha-test-server-helloworld/HelloWorldServlet"))
.newBuilder(new URI("http://localhost:8080/helloworld/helloworld.html"))
.build();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
assertTrue(response.body().contains("Hello World!"));
Expand Down
19 changes: 15 additions & 4 deletions test/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,34 @@

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>cloud.piranha.test</groupId>
<artifactId>project</artifactId>
<version>24.10.0-SNAPSHOT</version>
</parent>

<groupId>cloud.piranha.test.server</groupId>
<artifactId>project</artifactId>
<packaging>pom</packaging>

<name>Piranha - Test - Server - Project</name>

<modules>
<module>helloworld</module>
<module>programmatic</module>
<module>wasp</module>
<module>wasp2</module>
</modules>
<!--

Make sure the Piranha Server distribution is available before
attempting to build any of the modules.

-->
<dependencies>
<dependency>
<groupId>cloud.piranha.dist</groupId>
<artifactId>piranha-dist-server</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Loading