Skip to content

Commit

Permalink
Add Integration test for Microprofile/Liberty for Jee9 package
Browse files Browse the repository at this point in the history
Tidy-up pom files and filepaths

Signed-off-by: alex-butcher <[email protected]>
  • Loading branch information
abutch3r committed Sep 22, 2022
1 parent a5f4ba3 commit 7124971
Show file tree
Hide file tree
Showing 19 changed files with 405 additions and 39 deletions.
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<modules>
<module>kafka</module>
<module>restful-ws-quarkus</module>
<module>restful-ws-microprofile-ee9</module>
<module>restful-ws-microprofile-liberty</module>
<module>vertx</module>
<module>basic-http</module>
<module>restful-ws-spring-boot</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This project uses Microprofile 5.0 with OpenLiberty

If you would like to know more about Microprofile go to https://microprofile.io

This Example uses Jakarta EE9 features as such the top level namespace of the `ws-api` packages has changed from `javax` to `jakarta` and uses the `cloudevents-http-restful-ws-ee9` artifact.
This Example uses Jakarta EE9 features as such the top level namespace of the `ws-api` packages has changed from `javax` to `jakarta` and uses the `cloudevents-http-restful-ws-jakarta` artifact.

## Build and Execution

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cloudevents-restful-ws-microprofile-example</artifactId>
<artifactId>cloudevents-restful-ws-microprofile-liberty-example</artifactId>
<packaging>war</packaging>

<properties>
Expand Down Expand Up @@ -44,7 +44,7 @@
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-http-restful-ws-ee9</artifactId>
<artifactId>cloudevents-http-restful-ws-jakarta</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
Expand Down
5 changes: 3 additions & 2 deletions http/restful-ws-jakarta-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>restful-ws-jakarta-integration-tests</artifactId>
<artifactId>cloudevents-http-restful-ws-jakarta-integration-tests</artifactId>
<name>CloudEvents - JAX-RS Jakarta EE9+ Web Http Binding Integration Tests</name>
<packaging>pom</packaging>

<properties>
Expand All @@ -20,9 +21,9 @@

<modules>
<module>restful-ws-jakarta-common</module>
<module>restful-ws-microprofile</module>
<module>restful-ws-resteasy</module>
<module>restful-ws-jersey</module>
<module>restful-ws-liberty</module>
</modules>

</project>
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<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/maven-v4_0_0.xsd">
<parent>
<artifactId>restful-ws-jakarta-integration-tests</artifactId>
<artifactId>cloudevents-http-restful-ws-jakarta-integration-tests</artifactId>
<groupId>io.cloudevents</groupId>
<version>2.4.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cloudevents-http-restful-ws-jakarta-integration-tests-common</artifactId>
<name>CloudEvents - JAX-RS Jakarta Integration Tests - Common</name>
<name>CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - Common</name>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-http-restful-ws-ee9</artifactId>
<artifactId>cloudevents-http-restful-ws-jakarta</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
Expand All @@ -24,7 +24,6 @@
<type>test-jar</type>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
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">
<parent>
<artifactId>restful-ws-jakarta-integration-tests</artifactId>
<artifactId>cloudevents-http-restful-ws-jakarta-integration-tests</artifactId>
<groupId>io.cloudevents</groupId>
<version>2.4.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>cloudevents-http-restful-ws-jakarta-integration-tests-jersey</artifactId>
<name>CloudEvents - JAX-RS Integration Tests - Jersey</name>
<name>CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - Jersey</name>
<packaging>jar</packaging>

<properties>
Expand All @@ -48,21 +48,25 @@
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>${jakarta-ee.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*
* Ported from https://github.com/hanleyt/jersey-junit as no version support Jesery versions >=3.0.0
* Ported from https://github.com/hanleyt/jersey-junit as no version supports Jesery versions >=3.0.0
*
* Only update is the replacement of the ws-rs package namespace from javax. to jakarta.
*/

package com.github.hanleyt;
Expand Down
164 changes: 164 additions & 0 deletions http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<?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">
<parent>
<artifactId>cloudevents-http-restful-ws-jakarta-integration-tests</artifactId>
<groupId>io.cloudevents</groupId>
<version>2.4.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>cloudevents-http-restful-ws-jakarta-integration-tests-microprofile</artifactId>
<name>CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - Microprofile and Liberty</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- Liberty configuration -->
<liberty.var.default.http.port>9080</liberty.var.default.http.port>
<liberty.var.default.https.port>9443</liberty.var.default.https.port>
<!-- arquillian configuration -->
<arquillian.war.name>microprofile-test</arquillian.war.name>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.6.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- Provided dependencies -->
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>9.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>5.0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-http-restful-ws-jakarta</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-core</artifactId>
<classifier>tests</classifier>
<type>test-jar</type>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>6.0.0.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-json-binding-provider</artifactId>
<version>6.0.0.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.json</artifactId>
<version>2.0.1</version>
<scope>test</scope>
</dependency>
<!-- For JDK 9 & above Support -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>io.openliberty.arquillian</groupId>
<artifactId>arquillian-liberty-managed-jakarta-junit</artifactId>
<version>2.0.2</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<packagingExcludes>pom.xml</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<systemPropertyVariables>
<arquillian.war.name>${arquillian.war.name}.war</arquillian.war.name>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<arquillianProperties>
<javaVmArguments>
-Dsystem.context.root=/${arquillian.war.name}
</javaVmArguments>
</arquillianProperties>
</configuration>
<executions>
<execution>
<id>arquillian-configuration</id>
<phase>generate-test-resources</phase>
<goals>
<goal>create</goal>
<goal>install-feature</goal>
<goal>configure-arquillian</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.cloudevents.restful.mp.test;

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

@ApplicationPath("/")
public class MpCEApp extends Application {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package io.cloudevents.restful.mp.test;

import io.cloudevents.CloudEvent;
import io.cloudevents.core.mock.CSVFormat;
import io.cloudevents.core.provider.EventFormatProvider;
import io.cloudevents.core.test.Data;
import io.cloudevents.http.restful.ws.StructuredEncoding;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.RequestScoped;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Response;

@RequestScoped
@Path("/")
public class TestResource{

@PostConstruct
void init() {
EventFormatProvider.getInstance().registerFormat(CSVFormat.INSTANCE);
}

@GET
@Path("getMinEvent")
public CloudEvent getMinEvent() {
return Data.V1_MIN;
}

@GET
@Path("getStructuredEvent")
@StructuredEncoding("application/cloudevents+csv")
public CloudEvent getStructuredEvent() {
return Data.V1_MIN;
}

@GET
@Path("getEvent")
public CloudEvent getEvent() {
return Data.V1_WITH_JSON_DATA_WITH_EXT_STRING;
}

@POST
@Path("postEventWithoutBody")
public Response postEventWithoutBody(CloudEvent inputEvent) {
if (inputEvent.equals(Data.V1_MIN)) {
return Response.ok().build();
}
return Response.serverError().build();
}

@POST
@Path("postEvent")
public Response postEvent(CloudEvent inputEvent) {
if (inputEvent.equals(Data.V1_WITH_JSON_DATA_WITH_EXT_STRING)) {
return Response.ok().build();
}
return Response.serverError().build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<server description="new server">

<featureManager>
<feature>microProfile-5.0</feature>
<!--Used solely for testing-->
<feature>localConnector-1.0</feature>
<feature>servlet-5.0</feature>
</featureManager>

<variable name="default.http.port" defaultValue="9080" />
<variable name="default.https.port" defaultValue="9443" />

<httpEndpoint id="defaultHttpEndpoint" httpPort="${default.http.port}"
httpsPort="${default.https.port}" />
<webApplication location="${project.name}.war">
<classloader apiTypeVisibility="+third-party" />
</webApplication>
</server>
Loading

0 comments on commit 7124971

Please sign in to comment.