Skip to content

Commit

Permalink
Fixes #4169 - Add Piranha Web Profile distribution integration tests (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem authored Nov 5, 2024
1 parent a215102 commit 903127a
Show file tree
Hide file tree
Showing 19 changed files with 989 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,14 @@ private String toAppName(Archive<?> archive) {
private File getPiranhaJarFile(String version) throws IOException {
URL downloadUrl = createMavenCentralArtifactUrl(
"cloud.piranha.dist",
"piranha-dist-coreprofile",
"piranha-dist-" + configuration.getDistribution(),
version,
"jar"
);

String artifactPath = createArtifactPath(
"cloud.piranha.dist",
"piranha-dist-coreprofile",
"piranha-dist-" + configuration.getDistribution(),
version,
"jar"
);
Expand Down Expand Up @@ -348,11 +348,16 @@ private void startPiranha(File runtimeDirectory, File warFile) throws IOExceptio

if (classpath.isEmpty()) {
commands.add("-jar");
commands.add("piranha-dist-coreprofile.jar");
commands.add("piranha-" + configuration.getDistribution() + ".jar");
} else {
commands.add("-cp");
commands.add(classpath.toString() + "piranha-dist-coreprofile.jar");
commands.add("cloud.piranha.dist.coreprofile.CoreProfilePiranhaMain");
commands.add(classpath.toString() + "piranha-" + configuration.getDistribution() + ".jar");
if (configuration.getDistribution().equals("coreprofile")) {
commands.add("cloud.piranha.dist.coreprofile.CoreProfilePiranhaMain");
}
if (configuration.getDistribution().equals("webprofile")) {
commands.add("cloud.piranha.dist.webprofile.WebProfilePiranhaMain");
}
}
commands.add("--http-port");
commands.add(Integer.toString(configuration.getHttpPort()));
Expand All @@ -370,13 +375,15 @@ private void startPiranha(File runtimeDirectory, File warFile) throws IOExceptio
Starting Piranha
Directory: {0}
Log: {1}
URL: {2}
Classpath: {0}
Directory: {1}
Log: {2}
URL: {3}
""",

classpath.toString(),
runtimeDirectory,
logFile.getAbsolutePath(),
appURL);
Expand Down Expand Up @@ -443,7 +450,7 @@ private void copyPiranhaJarFile(File runtimeDirectory, File zipFile) throws IOEx
}

Files.copy(zipFile.toPath(),
Path.of(runtimeDirectory + "/piranha-dist-coreprofile.jar"),
Path.of(runtimeDirectory + "/piranha-" + configuration.getDistribution() + ".jar"),
REPLACE_EXISTING);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
* <td>not enabled by default</td>
* </tr>
* <tr>
* <td>piranha.distribution</td>
* <td>The Piranha distribution to use</td>
* <td>coreprofile by default</td>
* </tr>
* <tr>
* <td>piranha.httpPort</td>
* <td>The integer to select the HTTP port to use for the Piranha process</td>
* <td>if not set an unused port will be automatically chosen</td>
Expand Down Expand Up @@ -83,6 +88,11 @@ public class ManagedPiranhaContainerConfiguration implements ContainerConfigurat
*/
private static final System.Logger LOGGER = System.getLogger(ManagedPiranhaContainerConfiguration.class.getName());

/**
* Stores the distribution to use.
*/
private String distribution = System.getProperty("piranha.distribution", "coreprofile");

/**
* Stores the debug flag.
*/
Expand Down Expand Up @@ -113,6 +123,15 @@ public class ManagedPiranhaContainerConfiguration implements ContainerConfigurat
*/
public ManagedPiranhaContainerConfiguration() {
}

/**
* Get the distribution.
*
* @return the distribution.
*/
public String getDistribution() {
return distribution;
}

/**
* Get the HTTP port.
Expand Down Expand Up @@ -171,6 +190,15 @@ public void setDebug(boolean debug) {
this.debug = debug;
}

/**
* Set the distribution.
*
* @param distribution the distribution.
*/
public void setDistribution(String distribution) {
this.distribution = distribution;
}

/**
* Set the HTTP port.
*
Expand Down
85 changes: 85 additions & 0 deletions test/webprofile/integration/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cloud.piranha.test.webprofile</groupId>
<artifactId>project</artifactId>
<version>24.11.0-SNAPSHOT</version>
</parent>
<artifactId>piranha-test-webprofile-integration</artifactId>
<packaging>war</packaging>
<name>Piranha - Test - Web Profile - Distribution Integration Tests</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- provided -->
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- test -->
<dependency>
<groupId>cloud.piranha.arquillian</groupId>
<artifactId>piranha-arquillian-managed</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-container</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>piranha-test-webprofile-integration</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<rerunFailingTestsCount>10</rerunFailingTestsCount>
<systemPropertyVariables>
<piranha.distribution>webprofile</piranha.distribution>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2002-2024 Manorrock.com. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package integration;

import jakarta.enterprise.context.ApplicationScoped;

/**
* The one and only Dependency Injection bean.
*
* @author Manfred Riem ([email protected])
*/
@ApplicationScoped
public class DependencyInjectionBean {

/**
* Get the string to validate dependency injection works.
*
* @return the string.
*/
public String dependencyInjection() {
return "Dependency Injection works!";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2002-2024 Manorrock.com. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package integration;

import jakarta.inject.Named;
import jakarta.enterprise.context.ApplicationScoped;

/**
* The Expression bean.
*
* @author Manfred Riem ([email protected])
*/
@Named(value = "expressionBean")
@ApplicationScoped
public class ExpressionBean {

/**
* Get the message.
*
* @return the message.
*/
public String getMessage() {
return "Expression Language works!";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2002-2024 Manorrock.com. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package integration;

import jakarta.inject.Named;
import jakarta.enterprise.context.ApplicationScoped;

/**
* The Faces bean.
*
* @author Manfred Riem ([email protected])
*/
@Named(value = "facesBean")
@ApplicationScoped
public class FacesBean {

/**
* Get the message.
*
* @return the message.
*/
public String getMessage() {
return "Faces works!";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2002-2024 Manorrock.com. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package integration;

import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

/**
* The HelloWorld application.
*
* @author Manfred Riem ([email protected])
*/
@ApplicationPath("rest")
public class IntegrationApplication extends Application {
}
Loading

0 comments on commit 903127a

Please sign in to comment.