Restful-ws jakarta ee9 namespace support (#469)
* Replace javax restful-ws namespace usage with jakarata in own module * Add microprofile with openliberty example using new jar * Update gitignore to cover all copied directories * Update Jersey Version to support jakarta.* namespace packages * Port jersey integration tests from javax.* to jakarta.* * Undo changes to existing integration test package names * Add Integration test for Microprofile/Liberty for Jee9 package * Add documentation for new Jakarta package Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com>
This commit is contained in:
parent
4139fb7e57
commit
f08a099ed9
|
@ -45,3 +45,5 @@ _site/
|
|||
|
||||
# MacOS
|
||||
*.DS_Store
|
||||
/http/restful-ws-jakarta/src/main/*
|
||||
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
---
|
||||
title: CloudEvents HTTP Jakarta EE 9+ - Jakarta RESTful Web Services
|
||||
nav_order: 5
|
||||
---
|
||||
|
||||
# HTTP Protocol Binding for Jakarta EE 9+ - Jakarta RESTful Web Services
|
||||
|
||||
[](https://www.javadoc.io/doc/io.cloudevents/cloudevents-http-restful-ws)
|
||||
|
||||
For Maven based projects, use the following to configure the CloudEvents Jakarta
|
||||
RESTful Web Services Binding for Jakarta EE 9+:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<artifactId>cloudevents-http-restful-ws-jakarta</artifactId>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
This integration is tested with Jersey (Requires JDK11 or higher), RestEasy & Microprofile Liberty.
|
||||
|
||||
#### * Before using this package ensure your web framework does support the `jakarta.*` namespace.
|
||||
|
||||
## Receiving CloudEvents
|
||||
|
||||
You need to configure the `CloudEventsProvider` to enable
|
||||
marshalling/unmarshalling of CloudEvents.
|
||||
|
||||
Below is a sample on how to read and write CloudEvents:
|
||||
|
||||
```java
|
||||
import io.cloudevents.CloudEvent;
|
||||
import io.cloudevents.core.builder.CloudEventBuilder;
|
||||
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("/")
|
||||
public class EventReceiverResource {
|
||||
|
||||
|
||||
|
||||
@GET
|
||||
@Path("getMinEvent")
|
||||
public CloudEvent getMinEvent() {
|
||||
return CloudEventBuilder.v1()
|
||||
.withId("hello")
|
||||
.withType("example.vertx")
|
||||
.withSource(URI.create("http://localhost"))
|
||||
.build();
|
||||
}
|
||||
|
||||
// Return the CloudEvent using the HTTP binding structured encoding
|
||||
@GET
|
||||
@Path("getStructuredEvent")
|
||||
@StructuredEncoding("application/cloudevents+csv")
|
||||
public CloudEvent getStructuredEvent() {
|
||||
return CloudEventBuilder.v1()
|
||||
.withId("hello")
|
||||
.withType("example.vertx")
|
||||
.withSource(URI.create("http://localhost"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("postEventWithoutBody")
|
||||
public Response postEvent(CloudEvent inputEvent) {
|
||||
// Handle the event
|
||||
return Response.ok().build();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Sending CloudEvents
|
||||
|
||||
You need to configure the `CloudEventsProvider` to enable
|
||||
marshalling/unmarshalling of CloudEvents.
|
||||
|
||||
Below is a sample on how to use the client to send a CloudEvent:
|
||||
|
||||
```java
|
||||
import io.cloudevents.CloudEvent;
|
||||
import io.cloudevents.http.restful.ws.CloudEventsProvider;
|
||||
|
||||
import jakarta.ws.rs.client.Entity;
|
||||
import jakarta.ws.rs.client.WebTarget;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
public class CloudEventSender {
|
||||
|
||||
public Response sendEvent(WebTarget target, CloudEvent event) {
|
||||
return target
|
||||
.path("postEvent")
|
||||
.request()
|
||||
.buildPost(Entity.entity(event, CloudEventsProvider.CLOUDEVENT_TYPE))
|
||||
.invoke();
|
||||
}
|
||||
|
||||
public Response sendEventAsStructured(WebTarget target, CloudEvent event) {
|
||||
return target
|
||||
.path("postEvent")
|
||||
.request()
|
||||
.buildPost(Entity.entity(event, "application/cloudevents+json"))
|
||||
.invoke();
|
||||
}
|
||||
|
||||
public CloudEvent getEvent(WebTarget target) {
|
||||
Response response = target
|
||||
.path("getEvent")
|
||||
.request()
|
||||
.buildGet()
|
||||
.invoke();
|
||||
|
||||
return response.readEntity(CloudEvent.class);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Migrating EE 8 applications to EE 9+
|
||||
The main change between Jakarta EE 8 and Jakarta EE 9 and future versions is the changing of the `javax.` to `jakarta.` namespaces used by key packages such as `jakarta.ws.rs-api` which provides the restful-ws API.
|
||||
|
||||
This change largely impacts only `import` statements it does filter down to dependencies such as this.
|
||||
|
||||
### Application migration
|
||||
For application migration we would recommend reviewing materials available from https://jakarta.ee/resources/#documentation as a starting point.
|
||||
|
||||
### CloudEvents Dependency
|
||||
To migrate to use EE 9+ supported package - replace `cloudevents-http-restful-ws` with `cloudevents-http-restful-ws-jakarta` and ensure the version is a minimum of `2.5.0-SNAPSHOT`
|
||||
|
||||
## Examples
|
||||
|
||||
- [Microprofile and Liberty](https://github.com/cloudevents/sdk-java/tree/master/examples/restful-ws-micropofile-liberty)
|
||||
|
|
@ -3,12 +3,12 @@ title: CloudEvents HTTP Jakarta RESTful Web Services
|
|||
nav_order: 5
|
||||
---
|
||||
|
||||
# HTTP Protocol Binding for Jakarta RESTful Web Services
|
||||
# HTTP Protocol Binding for Jakarta EE8 - RESTful Web Services
|
||||
|
||||
[](http://www.javadoc.io/doc/io.cloudevents/cloudevents-http-restful-ws)
|
||||
|
||||
For Maven based projects, use the following to configure the CloudEvents Jakarta
|
||||
RESTful Web Services Binding:
|
||||
RESTful Web Services Binding for Jakarta EE 8:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
|
|
|
@ -62,7 +62,8 @@ receive CloudEvents, check out the dedicated pages:
|
|||
|
||||
- [AMQP using Proton](amqp-proton.md)
|
||||
- [HTTP using Vert.x](http-vertx.md)
|
||||
- [HTTP using Jakarta Restful WS](http-jakarta-restful-ws.md)
|
||||
- [HTTP using Jakarta EE 8 - Jakarta Restful WS](http-jakarta-restful-ws.md)
|
||||
- [HTTP using Jakarta EE 9+ - Jakarta Restful WS](http-jakarta-restful-ws-jakarta.md)
|
||||
- [HTTP using Spring](spring.md)
|
||||
- [HTTP using Jackson](json-jackson.md)
|
||||
- [Kafka](kafka.md)
|
||||
|
@ -98,7 +99,9 @@ a different feature from the different sub specs of
|
|||
- [`cloudevents-http-vertx`] Implementation of [HTTP Protocol Binding] with
|
||||
[Vert.x Core](https://vertx.io/)
|
||||
- [`cloudevents-http-restful-ws`] Implementation of [HTTP Protocol Binding]
|
||||
for [Jakarta Restful WS](https://jakarta.ee/specifications/restful-ws/)
|
||||
for [Jakarta EE 8 Restful WS](https://jakarta.ee/specifications/restful-ws/2.1/)
|
||||
- [`cloudevents-http-restful-ws-jakarta`] Implementation of [HTTP Protocol Binding]
|
||||
for [Jakarta EE 9+ Restful WS](https://jakarta.ee/specifications/restful-ws/)
|
||||
- [`cloudevents-http-basic`] Generic implementation of [HTTP Protocol
|
||||
Binding], primarily intended for integrators
|
||||
- [`cloudevents-kafka`] Implementation of [Kafka Protocol Binding]
|
||||
|
@ -123,6 +126,7 @@ You can look at the latest published artifacts on
|
|||
[`cloudevents-http-vertx`]: https://github.com/cloudevents/sdk-java/tree/master/http/vertx
|
||||
[`cloudevents-http-basic`]: https://github.com/cloudevents/sdk-java/tree/master/http/basic
|
||||
[`cloudevents-http-restful-ws`]: https://github.com/cloudevents/sdk-java/tree/master/http/restful-ws
|
||||
[`cloudevents-http-restful-ws-jakarta`]: https://github.com/cloudevents/sdk-java/tree/master/http/restful-ws-jakarta
|
||||
[`cloudevents-kafka`]: https://github.com/cloudevents/sdk-java/tree/master/kafka
|
||||
[`cloudevents-amqp-proton`]: https://github.com/cloudevents/sdk-java/tree/master/amqp
|
||||
[`cloudevents-spring`]: https://github.com/cloudevents/sdk-java/tree/master/spring
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<modules>
|
||||
<module>kafka</module>
|
||||
<module>restful-ws-quarkus</module>
|
||||
<module>restful-ws-microprofile-liberty</module>
|
||||
<module>vertx</module>
|
||||
<module>basic-http</module>
|
||||
<module>restful-ws-spring-boot</module>
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
# Cloudevents Restful WS Microprofile Example
|
||||
|
||||
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-jakarta` artifact.
|
||||
|
||||
## Build and Execution
|
||||
|
||||
### Running the application in dev mode
|
||||
|
||||
You can run your application in dev mode that enables live coding using:
|
||||
```
|
||||
mvn liberty:dev
|
||||
```
|
||||
|
||||
### Packaging and running the application
|
||||
|
||||
To Package and run as a minimum jar without a full OpenLiberty server
|
||||
```
|
||||
mvn liberty:package -Drunnable=mvn liberty:package -Dinclude=runnable
|
||||
```
|
||||
|
||||
### Making requests against the server
|
||||
|
||||
This sample application has a `/events` RESTful endpoint on the application `cloudevents-restful-ws-microprofile-example
|
||||
the base application is available at `http://localhost:9080/cloudevents-restful-ws-microprofile-example/`
|
||||
|
||||
There are three operations that can be performed:
|
||||
#### GET /events
|
||||
Returns a Cloud event with a payload containing a message
|
||||
|
||||
```shell
|
||||
curl -v http://localhost:9080/cloudevents-restful-ws-microprofile-example/events
|
||||
|
||||
* Trying 127.0.0.1:9080...
|
||||
* Connected to localhost (127.0.0.1) port 9080 (#0)
|
||||
> GET /cloudevents-restful-ws-microprofile-example/events HTTP/1.1
|
||||
> Host: localhost:9080
|
||||
> User-Agent: curl/7.83.1
|
||||
> Accept: */*
|
||||
>
|
||||
* Mark bundle as not supporting multiuse
|
||||
< HTTP/1.1 201 no-content
|
||||
< Ce-Id: hello
|
||||
< Ce-Source: http://localhost
|
||||
< Ce-Specversion: 1.0
|
||||
< Ce-Type: example.http
|
||||
< Content-Type: application/json
|
||||
< Content-Language: en-GB
|
||||
< Content-Length: 64
|
||||
< Date: Wed, 17 Aug 2022 14:01:50 GMT
|
||||
<
|
||||
{"message":"Welcome to this Cloudevents + Microprofile example"}
|
||||
```
|
||||
|
||||
#### POST /events
|
||||
POST a Cloudevent with a payload that is printed out in the server logs
|
||||
|
||||
```shell
|
||||
curl -v http://localhost:9080/cloudevents-restful-ws-microprofile-example/events \
|
||||
-H "Ce-Specversion: 1.0" \
|
||||
-H "Ce-Type: User" \
|
||||
-H "Ce-Source: io.cloudevents.examples/user" \
|
||||
-H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f78" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Ce-Subject: SUBJ-0001" \
|
||||
-d "hello"
|
||||
|
||||
* Trying 127.0.0.1:9080...
|
||||
* Connected to localhost (127.0.0.1) port 9080 (#0)
|
||||
> POST /cloudevents-restful-ws-microprofile-example/events HTTP/1.1
|
||||
> Host: localhost:9080
|
||||
> User-Agent: curl/7.83.1
|
||||
> Accept: */*
|
||||
> Ce-Specversion: 1.0
|
||||
> Ce-Type: User
|
||||
> Ce-Source: io.cloudevents.examples/user
|
||||
> Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f78
|
||||
> Content-Type: application/json
|
||||
> Ce-Subject: SUBJ-0001
|
||||
> Content-Length: 5
|
||||
>
|
||||
* Mark bundle as not supporting multiuse
|
||||
< HTTP/1.1 204 No Content
|
||||
< Content-Language: en-GB
|
||||
< Content-Length: 0
|
||||
< Date: Thu, 18 Aug 2022 13:33:03 GMT
|
||||
<
|
||||
* Connection #0 to host localhost left intact
|
||||
```
|
||||
Server log statement
|
||||
```
|
||||
[INFO] Received request providing a event with body hello
|
||||
[INFO] CloudEvent{id='536808d3-88be-4077-9d7a-a3f162705f78', source=io.cloudevents.examples/user, type='User', datacontenttype='application/json', subject='SUBJ-0001', data=BytesCloudEventData{value=[104, 101, 108, 108, 111]}, extensions={}}
|
||||
```
|
||||
|
||||
#### POST /events/echo
|
||||
POST a Cloudevent with a payload and have it echoed back as a Cloudevent
|
||||
|
||||
```shell
|
||||
curl -v http://localhost:9080/cloudevents-restful-ws-microprofile-example/events/echo \
|
||||
-H "Ce-Specversion: 1.0" \
|
||||
-H "Ce-Type: User" \
|
||||
-H "Ce-Source: io.cloudevents.examples/user" \
|
||||
-H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f78" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Ce-Subject: SUBJ-0001" \
|
||||
-d "hello"
|
||||
|
||||
* Trying 127.0.0.1:9080...
|
||||
* Connected to localhost (127.0.0.1) port 9080 (#0)
|
||||
> POST /cloudevents-restful-ws-microprofile-example/rest/events/echo HTTP/1.1
|
||||
> Host: localhost:9080
|
||||
> User-Agent: curl/7.83.1
|
||||
> Accept: */*
|
||||
> Ce-Specversion: 1.0
|
||||
> Ce-Type: User
|
||||
> Ce-Source: io.cloudevents.examples/user
|
||||
> Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f78
|
||||
> Content-Type: application/json
|
||||
> Ce-Subject: SUBJ-0001
|
||||
> Content-Length: 5
|
||||
>
|
||||
* Mark bundle as not supporting multiuse
|
||||
< HTTP/1.1 200 OK
|
||||
< Ce-Id: echo
|
||||
< Ce-Source: http://localhost
|
||||
< Ce-Specversion: 1.0
|
||||
< Ce-Type: echo.http
|
||||
< Content-Type: application/json
|
||||
< Content-Language: en-GB
|
||||
< Content-Length: 17
|
||||
< Date: Wed, 17 Aug 2022 12:57:59 GMT
|
||||
<
|
||||
{"echo": "hello"}* Connection #0 to host localhost left intact
|
||||
```
|
||||
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
<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>cloudevents-examples</artifactId>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cloudevents-restful-ws-microprofile-liberty-example</artifactId>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<properties>
|
||||
<openliberty.maven.version>3.5.1</openliberty.maven.version>
|
||||
<app.name>cloudevents-microprofile</app.name>
|
||||
|
||||
<!-- Liberty server properties -->
|
||||
<final.name>cloudeventsServer</final.name>
|
||||
<testServerHttpPort>9080</testServerHttpPort>
|
||||
<testServerHttpsPort>9443</testServerHttpsPort>
|
||||
<!--This is set in the ibm-web-ext.xml file -->
|
||||
<warContext>cloudeventsexperiments</warContext>
|
||||
<package.file>${project.build.directory}/${app.name}.zip</package.file>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>runnable</id>
|
||||
<properties>
|
||||
<package.file>${project.build.directory}/${app.name}.jar</package.file>
|
||||
<packaging.type>runnable</packaging.type>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
<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.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-core</artifactId>
|
||||
<version>3.4.21</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.3.2</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
<packagingExcludes>pom.xml</packagingExcludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.10</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-server-files</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<includeArtifactIds>server-snippet</includeArtifactIds>
|
||||
<prependGroupId>true</prependGroupId>
|
||||
<outputDirectory>
|
||||
${project.build.directory}/wlp/usr/servers/${wlpServerName}/configDropins/defaults
|
||||
</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-app</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/wlp/usr/servers/${wlpServerName}/dropins
|
||||
</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<includes>
|
||||
<include>${project.artifactId}-${project.version}.war</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Enable liberty-maven plugin -->
|
||||
<plugin>
|
||||
<groupId>io.openliberty.tools</groupId>
|
||||
<artifactId>liberty-maven-plugin</artifactId>
|
||||
<version>${openliberty.maven.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>package-server</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>create</goal>
|
||||
<goal>install-feature</goal>
|
||||
<goal>deploy</goal>
|
||||
<goal>package</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>target/wlp-package</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<include>runnable</include>
|
||||
<serverName>${final.name}</serverName>
|
||||
<bootstrapProperties>
|
||||
<project.name>${final.name}</project.name>
|
||||
<jwt.issuer>https://server.example.com</jwt.issuer>
|
||||
<app.context.root>/</app.context.root>
|
||||
</bootstrapProperties>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Plugin to run functional tests -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>integration-test</phase>
|
||||
<id>integration-test</id>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/it/**</include>
|
||||
</includes>
|
||||
<systemPropertyVariables>
|
||||
<liberty.test.port>${testServerHttpPort}</liberty.test.port>
|
||||
<war.name>${warContext}</war.name>
|
||||
<running.bluemix>${running.bluemix}</running.bluemix>
|
||||
<cf.context.root>${cf.context.root}</cf.context.root>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>verify-results</id>
|
||||
<goals>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<summaryFile>${project.build.directory}/test-reports/it/failsafe-summary.xml</summaryFile>
|
||||
<reportsDirectory>${project.build.directory}/test-reports/it</reportsDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,9 @@
|
|||
package io.cloudevents.examples.microprofile;
|
||||
|
||||
import jakarta.ws.rs.ApplicationPath;
|
||||
import jakarta.ws.rs.core.Application;
|
||||
|
||||
@ApplicationPath("/")
|
||||
public class CloudEventsApplication extends Application {
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package io.cloudevents.examples.microprofile;
|
||||
|
||||
import io.cloudevents.CloudEvent;
|
||||
import io.cloudevents.core.builder.CloudEventBuilder;
|
||||
import jakarta.enterprise.context.RequestScoped;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@RequestScoped
|
||||
@Path("events")
|
||||
public class CloudEventsJaxrsService {
|
||||
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public CloudEvent retrieveEvent(){
|
||||
System.out.println("Received request for an event");
|
||||
return CloudEventBuilder.v1()
|
||||
.withData("{\"message\":\"Welcome to this Cloudevents + Microprofile example\"}".getBytes())
|
||||
.withDataContentType("application/json")
|
||||
.withId("hello")
|
||||
.withType("example.http")
|
||||
.withSource(URI.create("http://localhost"))
|
||||
.build();
|
||||
}
|
||||
|
||||
//Example Curl - curl -v http://localhost:9080/cloudevents-restful-ws-microprofile-example/events -H "Ce-Specversion: 1.0" -H "Ce-Type: User" -H "Ce-Source: io.cloudevents.examples/user" -H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f78" -H "Content-Type: application/json" -H "Ce-Subject: SUBJ-0001" -d "hello"
|
||||
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Response postEvent(CloudEvent event){
|
||||
System.out.println("Received request providing a event with body "+ new String(event.getData().toBytes(), StandardCharsets.UTF_8));
|
||||
System.out.println(event);
|
||||
return Response.noContent().build();
|
||||
}
|
||||
|
||||
//Example Curl - curl -v http://localhost:9080/cloudevents-restful-ws-microprofile-example/events/echo -H "Ce-Specversion: 1.0" -H "Ce-Type: User" -H "Ce-Source: io.cloudevents.examples/user" -H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f78" -H "Content-Type: application/json" -H "Ce-Subject: SUBJ-0001" -d "hello"
|
||||
|
||||
@POST
|
||||
@Path("/echo")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public CloudEvent echo(CloudEvent event){
|
||||
return CloudEventBuilder.v1()
|
||||
.withData("application/json", ("{\"echo\": \"" + new String(event.getData().toBytes(),StandardCharsets.UTF_8) + "\"}").getBytes())
|
||||
.withId("echo")
|
||||
.withType("echo.http")
|
||||
.withSource(URI.create("http://localhost"))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<server description="${project.name}">
|
||||
|
||||
<featureManager>
|
||||
<feature>microProfile-5.0</feature>
|
||||
</featureManager>
|
||||
|
||||
|
||||
<httpEndpoint id="defaultHttpEndpoint"
|
||||
httpPort="9080"
|
||||
httpsPort="9443"/>
|
||||
|
||||
<webApplication location="${project.name}.war">
|
||||
<classloader apiTypeVisibility="+third-party" />
|
||||
</webApplication>
|
||||
<mpMetrics authentication="false"/>
|
||||
|
||||
<!-- This is the keystore that will be used by SSL and by JWT. -->
|
||||
<keyStore id="defaultKeyStore" location="public.jks" type="JKS" password="atbash" />
|
||||
|
||||
|
||||
<!-- The MP JWT configuration that injects the caller's JWT into a ResourceScoped bean for inspection. -->
|
||||
<mpJwt id="jwtUserConsumer" keyName="theKeyId" audiences="targetService" issuer="${jwt.issuer}"/>
|
||||
|
||||
</server>
|
|
@ -0,0 +1,30 @@
|
|||
<?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-parent</artifactId>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<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>
|
||||
<!-- No need to generate javadocs for these IT tests -->
|
||||
<maven.javadoc.skip>true</maven.javadoc.skip>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>restful-ws-jakarta-common</module>
|
||||
<module>restful-ws-resteasy</module>
|
||||
<!-- Requires JDK11 to be used -->
|
||||
<!-- <module>restful-ws-jersey</module> -->
|
||||
<module>restful-ws-liberty</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,38 @@
|
|||
<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>cloudevents-http-restful-ws-jakarta-integration-tests</artifactId>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<version>2.5.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 EE9+ Integration Tests - Common</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<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.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj-core.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Copyright 2018-Present The CloudEvents Authors
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package io.cloudevents.http.restful.ws;
|
||||
|
||||
import io.cloudevents.CloudEvent;
|
||||
import io.cloudevents.core.mock.CSVFormat;
|
||||
import io.cloudevents.core.test.Data;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.ws.rs.client.Entity;
|
||||
import jakarta.ws.rs.client.WebTarget;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public abstract class BaseTest {
|
||||
|
||||
protected abstract WebTarget getWebTarget();
|
||||
|
||||
@Test
|
||||
void getMinEvent() {
|
||||
Response res = getWebTarget().path("getMinEvent").request().buildGet().invoke();
|
||||
|
||||
assertThat(res.getHeaderString("ce-specversion"))
|
||||
.isEqualTo("1.0");
|
||||
|
||||
CloudEvent outEvent = res.readEntity(CloudEvent.class);
|
||||
assertThat(outEvent)
|
||||
.isEqualTo(Data.V1_MIN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getStructuredEvent() {
|
||||
Response res = getWebTarget().path("getStructuredEvent").request().buildGet().invoke();
|
||||
|
||||
CloudEvent outEvent = res.readEntity(CloudEvent.class);
|
||||
assertThat(outEvent)
|
||||
.isEqualTo(Data.V1_MIN);
|
||||
assertThat(res.getHeaderString(HttpHeaders.CONTENT_TYPE))
|
||||
.isEqualTo(CSVFormat.INSTANCE.serializedContentType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getEvent() {
|
||||
Response res = getWebTarget().path("getEvent").request().buildGet().invoke();
|
||||
|
||||
CloudEvent outEvent = res.readEntity(CloudEvent.class);
|
||||
assertThat(outEvent)
|
||||
.isEqualTo(Data.V1_WITH_JSON_DATA_WITH_EXT_STRING);
|
||||
}
|
||||
|
||||
@Test
|
||||
void postEventWithoutBody() {
|
||||
Response res = getWebTarget()
|
||||
.path("postEventWithoutBody")
|
||||
.request()
|
||||
.buildPost(Entity.entity(Data.V1_MIN, CloudEventsProvider.CLOUDEVENT_TYPE))
|
||||
.invoke();
|
||||
|
||||
assertThat(res.getStatus())
|
||||
.isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void postEventStructured() {
|
||||
Response res = getWebTarget()
|
||||
.path("postEventWithoutBody")
|
||||
.request()
|
||||
.buildPost(Entity.entity(Data.V1_MIN, "application/cloudevents+csv"))
|
||||
.invoke();
|
||||
|
||||
assertThat(res.getStatus())
|
||||
.isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void postEvent() {
|
||||
Response res = getWebTarget()
|
||||
.path("postEvent")
|
||||
.request()
|
||||
.buildPost(Entity.entity(Data.V1_WITH_JSON_DATA_WITH_EXT_STRING, CloudEventsProvider.CLOUDEVENT_TYPE))
|
||||
.invoke();
|
||||
|
||||
assertThat(res.getStatus())
|
||||
.isEqualTo(200);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright 2018-Present The CloudEvents Authors
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package io.cloudevents.http.restful.ws;
|
||||
|
||||
import io.cloudevents.CloudEvent;
|
||||
import io.cloudevents.core.test.Data;
|
||||
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("/")
|
||||
public class TestResource {
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2018-Present The CloudEvents Authors
|
||||
~ <p>
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~ <p>
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~ <p>
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<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.5.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 Jakarta EE9+ Integration Tests - Jersey</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<jersey.version>3.0.8</jersey.version>
|
||||
<jakarta-ee.version>3.0.0</jakarta-ee.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<artifactId>cloudevents-http-restful-ws-jakarta-integration-tests-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<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>
|
||||
</project>
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import org.glassfish.jersey.client.ClientConfig;
|
||||
import org.glassfish.jersey.test.DeploymentContext;
|
||||
import org.glassfish.jersey.test.JerseyTest;
|
||||
import org.glassfish.jersey.test.TestProperties;
|
||||
import org.glassfish.jersey.test.spi.TestContainerException;
|
||||
import org.glassfish.jersey.test.spi.TestContainerFactory;
|
||||
import org.junit.jupiter.api.extension.AfterEachCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.ParameterContext;
|
||||
import org.junit.jupiter.api.extension.ParameterResolver;
|
||||
|
||||
import jakarta.ws.rs.client.Client;
|
||||
import jakarta.ws.rs.client.WebTarget;
|
||||
import jakarta.ws.rs.core.Application;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class JerseyExtension implements BeforeEachCallback, AfterEachCallback, ParameterResolver {
|
||||
|
||||
private static final Collection<Class<?>> INJECTABLE_PARAMETER_TYPES = Arrays.asList(Client.class, WebTarget.class, URI.class);
|
||||
|
||||
private final Function<ExtensionContext, TestContainerFactory> testContainerFactoryProvider;
|
||||
private final Function<ExtensionContext, DeploymentContext> deploymentContextProvider;
|
||||
private final BiFunction<ExtensionContext, ClientConfig, ClientConfig> configProvider;
|
||||
|
||||
private JerseyExtension() {
|
||||
throw new IllegalStateException("JerseyExtension must be registered programmatically");
|
||||
}
|
||||
|
||||
public JerseyExtension(Supplier<Application> applicationSupplier) {
|
||||
this((unused) -> applicationSupplier.get(), null);
|
||||
}
|
||||
|
||||
public JerseyExtension(Supplier<Application> applicationSupplier,
|
||||
BiFunction<ExtensionContext, ClientConfig, ClientConfig> configProvider) {
|
||||
this((unused) -> applicationSupplier.get(), configProvider);
|
||||
}
|
||||
|
||||
public JerseyExtension(Function<ExtensionContext, Application> applicationProvider) {
|
||||
this(applicationProvider, null);
|
||||
}
|
||||
|
||||
public JerseyExtension(Function<ExtensionContext, Application> applicationProvider,
|
||||
BiFunction<ExtensionContext, ClientConfig, ClientConfig> configProvider) {
|
||||
this(null, (context) -> DeploymentContext.builder(applicationProvider.apply(context)).build(), configProvider);
|
||||
}
|
||||
|
||||
public JerseyExtension(Function<ExtensionContext, TestContainerFactory> testContainerFactoryProvider,
|
||||
Function<ExtensionContext, DeploymentContext> deploymentContextProvider,
|
||||
BiFunction<ExtensionContext, ClientConfig, ClientConfig> configProvider) {
|
||||
this.testContainerFactoryProvider = testContainerFactoryProvider;
|
||||
this.deploymentContextProvider = deploymentContextProvider;
|
||||
this.configProvider = configProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext context) throws Exception {
|
||||
JerseyTest jerseyTest = initJerseyTest(context);
|
||||
getStore(context).put(Client.class, jerseyTest.client());
|
||||
getStore(context).put(WebTarget.class, jerseyTest.target());
|
||||
getStore(context).put(URI.class, jerseyTest.target().getUri());
|
||||
}
|
||||
|
||||
private JerseyTest initJerseyTest(ExtensionContext context) throws Exception {
|
||||
JerseyTest jerseyTest = new JerseyTest() {
|
||||
|
||||
@Override
|
||||
protected DeploymentContext configureDeployment() {
|
||||
forceSet(TestProperties.CONTAINER_PORT, "0");
|
||||
return deploymentContextProvider.apply(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
|
||||
if (testContainerFactoryProvider != null) {
|
||||
return testContainerFactoryProvider.apply(context);
|
||||
}
|
||||
return super.getTestContainerFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureClient(ClientConfig config) {
|
||||
if (configProvider != null) {
|
||||
config = configProvider.apply(context, config);
|
||||
}
|
||||
super.configureClient(config);
|
||||
}
|
||||
};
|
||||
jerseyTest.setUp();
|
||||
getStore(context).put(JerseyTest.class, jerseyTest);
|
||||
return jerseyTest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterEach(ExtensionContext context) throws Exception {
|
||||
ExtensionContext.Store store = getStore(context);
|
||||
store.remove(JerseyTest.class, JerseyTest.class).tearDown();
|
||||
INJECTABLE_PARAMETER_TYPES.forEach(store::remove);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
|
||||
Class<?> parameterType = parameterContext.getParameter().getType();
|
||||
return INJECTABLE_PARAMETER_TYPES.contains(parameterType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
|
||||
Class<?> parameterType = parameterContext.getParameter().getType();
|
||||
return getStore(extensionContext).get(parameterType, parameterType);
|
||||
}
|
||||
|
||||
public static ExtensionContext.Store getStore(ExtensionContext context) {
|
||||
return context.getStore(ExtensionContext.Namespace.GLOBAL);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright 2018-Present The CloudEvents Authors
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package io.cloudevents.http.restful.ws.jakarta.jersey;
|
||||
|
||||
import com.github.hanleyt.JerseyExtension;
|
||||
import io.cloudevents.core.mock.CSVFormat;
|
||||
import io.cloudevents.core.provider.EventFormatProvider;
|
||||
import io.cloudevents.http.restful.ws.BaseTest;
|
||||
import io.cloudevents.http.restful.ws.CloudEventsProvider;
|
||||
import io.cloudevents.http.restful.ws.TestResource;
|
||||
import org.glassfish.jersey.client.ClientConfig;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import jakarta.ws.rs.client.WebTarget;
|
||||
import jakarta.ws.rs.core.Application;
|
||||
|
||||
public class TestJersey extends BaseTest {
|
||||
|
||||
private WebTarget target;
|
||||
|
||||
@Override
|
||||
protected WebTarget getWebTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
EventFormatProvider.getInstance().registerFormat(CSVFormat.INSTANCE);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach(WebTarget target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@RegisterExtension
|
||||
JerseyExtension jerseyExtension = new JerseyExtension(this::configureJersey, this::configureJerseyClient);
|
||||
|
||||
private Application configureJersey() {
|
||||
return new ResourceConfig(TestResource.class)
|
||||
.register(CloudEventsProvider.class);
|
||||
}
|
||||
|
||||
private ClientConfig configureJerseyClient(ExtensionContext extensionContext, ClientConfig clientConfig) {
|
||||
return clientConfig
|
||||
.register(CloudEventsProvider.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
<?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.5.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>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<properties>
|
||||
<!-- 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.3.Final</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-json-binding-provider</artifactId>
|
||||
<version>6.0.3.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.1.0</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>
|
|
@ -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 {
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -0,0 +1,123 @@
|
|||
package io.cloudevents.http.restful.ws.jakarta.microprofile;
|
||||
|
||||
import io.cloudevents.CloudEvent;
|
||||
import io.cloudevents.core.mock.CSVFormat;
|
||||
import io.cloudevents.core.test.Data;
|
||||
import io.cloudevents.http.restful.ws.CloudEventsProvider;
|
||||
import jakarta.ws.rs.client.Client;
|
||||
import jakarta.ws.rs.client.ClientBuilder;
|
||||
import jakarta.ws.rs.client.Entity;
|
||||
import jakarta.ws.rs.client.WebTarget;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.container.test.api.RunAsClient;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.arquillian.test.api.ArquillianResource;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
||||
/**
|
||||
* Arquilian does not support assertj, so test cases have been ported to Junit to work with arquilian
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
public class TestMicroprofile {
|
||||
|
||||
private static final String WARNAME = "microprofile-test.war";
|
||||
private Client client = ClientBuilder.newClient();
|
||||
|
||||
@Deployment(testable = true)
|
||||
public static WebArchive createDeployment() {
|
||||
System.out.println(WARNAME);
|
||||
WebArchive archive = ShrinkWrap.create(WebArchive.class, WARNAME).addPackages(true,"io.cloudevents");
|
||||
return archive;
|
||||
}
|
||||
|
||||
@ArquillianResource
|
||||
private URL baseURL;
|
||||
|
||||
private WebTarget webTarget;
|
||||
|
||||
public WebTarget getWebTarget() {
|
||||
if(webTarget == null){
|
||||
webTarget = client.target(baseURL.toString());
|
||||
webTarget.register(CloudEventsProvider.class);
|
||||
}
|
||||
return webTarget;
|
||||
}
|
||||
|
||||
@Test
|
||||
@RunAsClient
|
||||
public void getMinEvent() {
|
||||
Response res = getWebTarget().path("getMinEvent").request().buildGet().invoke();
|
||||
|
||||
Assert.assertEquals("1.0",res.getHeaderString("ce-specversion"));
|
||||
Assert.assertEquals(Data.V1_MIN,res.readEntity(CloudEvent.class));
|
||||
|
||||
res.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RunAsClient
|
||||
public void getStructuredEvent() {
|
||||
Response res = getWebTarget().path("getStructuredEvent").request().buildGet().invoke();
|
||||
|
||||
Assert.assertEquals(Data.V1_MIN,res.readEntity(CloudEvent.class));
|
||||
Assert.assertEquals(CSVFormat.INSTANCE.serializedContentType(),res.getHeaderString(HttpHeaders.CONTENT_TYPE));
|
||||
|
||||
res.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RunAsClient
|
||||
public void testGetEvent() throws Exception {
|
||||
Response response = getWebTarget().path("getEvent").request().buildGet().invoke();
|
||||
|
||||
Assert.assertEquals("Valid response code", 200, response.getStatus());
|
||||
Assert.assertEquals("should match", Data.V1_WITH_JSON_DATA_WITH_EXT_STRING, response.readEntity(CloudEvent.class));
|
||||
|
||||
response.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RunAsClient
|
||||
public void postEventWithoutBody() {
|
||||
Response res = getWebTarget()
|
||||
.path("postEventWithoutBody")
|
||||
.request()
|
||||
.buildPost(Entity.entity(Data.V1_MIN, CloudEventsProvider.CLOUDEVENT_TYPE))
|
||||
.invoke();
|
||||
|
||||
Assert.assertEquals(200,res.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
@RunAsClient
|
||||
public void postEventStructured() {
|
||||
Response res = getWebTarget()
|
||||
.path("postEventWithoutBody")
|
||||
.request()
|
||||
.buildPost(Entity.entity(Data.V1_MIN, "application/cloudevents+csv"))
|
||||
.invoke();
|
||||
|
||||
Assert.assertEquals(200,res.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
@RunAsClient
|
||||
public void postEvent() {
|
||||
Response res = getWebTarget()
|
||||
.path("postEvent")
|
||||
.request()
|
||||
.buildPost(Entity.entity(Data.V1_WITH_JSON_DATA_WITH_EXT_STRING, CloudEventsProvider.CLOUDEVENT_TYPE))
|
||||
.invoke();
|
||||
|
||||
Assert.assertEquals(200,res.getStatus());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<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>cloudevents-http-restful-ws-jakarta-integration-tests</artifactId>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cloudevents-http-restful-ws-jakarta-integration-tests-resteasy</artifactId>
|
||||
<name>CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - RESTEasy</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
<properties>
|
||||
<vertx.version>4.3.3</vertx.version>
|
||||
<resteasy.version>6.0.3.Final</resteasy.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<artifactId>cloudevents-http-restful-ws-jakarta-integration-tests-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-core</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-vertx</artifactId>
|
||||
<version>${resteasy.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,62 @@
|
|||
|
||||
/*
|
||||
* Copyright 2018-Present The CloudEvents Authors
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package io.cloudevents.http.restful.ws.jakarta.resteasy;
|
||||
|
||||
import io.cloudevents.core.mock.CSVFormat;
|
||||
import io.cloudevents.core.provider.EventFormatProvider;
|
||||
import io.cloudevents.http.restful.ws.BaseTest;
|
||||
import io.cloudevents.http.restful.ws.CloudEventsProvider;
|
||||
import io.cloudevents.http.restful.ws.TestResource;
|
||||
import org.jboss.resteasy.plugins.server.vertx.VertxContainer;
|
||||
import org.jboss.resteasy.plugins.server.vertx.VertxResteasyDeployment;
|
||||
import org.jboss.resteasy.test.TestPortProvider;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
||||
import jakarta.ws.rs.client.ClientBuilder;
|
||||
import jakarta.ws.rs.client.WebTarget;
|
||||
|
||||
public class TestResteasy extends BaseTest {
|
||||
|
||||
private static VertxResteasyDeployment resteasyDeployment;
|
||||
private static WebTarget target;
|
||||
|
||||
@Override
|
||||
protected WebTarget getWebTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeClass() throws Exception {
|
||||
EventFormatProvider.getInstance().registerFormat(CSVFormat.INSTANCE);
|
||||
|
||||
String base = TestPortProvider.generateBaseUrl();
|
||||
TestResteasy.resteasyDeployment = VertxContainer.start(base);
|
||||
TestResteasy.resteasyDeployment.getProviderFactory().register(CloudEventsProvider.class);
|
||||
TestResteasy.resteasyDeployment.getRegistry().addPerRequestResource(TestResource.class);
|
||||
|
||||
TestResteasy.target = ClientBuilder.newClient().register(CloudEventsProvider.class).target(base);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void after() throws Exception {
|
||||
TestResteasy.resteasyDeployment.stop();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
# HTTP Protocol Binding for Jakarta EE9+ - Jakarta RESTful Web Services
|
||||
|
||||
Javadocs: [](http://www.javadoc.io/doc/io.cloudevents/cloudevents-http-restful-ws)
|
||||
|
||||
Documentation: https://cloudevents.github.io/sdk-java/http-jakarta-restful-ws
|
||||
|
||||
The code for this package lies within the [restful-ws](https://github.com/cloudevents/sdk-java/tree/master/http/restful-ws) directory and is copied within here and has `javax.` replaced with `jakarta.`
|
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2018-Present The CloudEvents Authors
|
||||
~ <p>
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~ <p>
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~ <p>
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<artifactId>cloudevents-parent</artifactId>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloudevents-http-restful-ws-jakarta</artifactId>
|
||||
<name>CloudEvents - Jakarta EE 9+ - Jakarta RESTful Web Services Http Binding</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<layout>default</layout>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<properties>
|
||||
<jakarta-ee.version>3.0.0</jakarta-ee.version>
|
||||
<jersey.version>3.0.8</jersey.version>
|
||||
<vertx.version>4.4.3</vertx.version>
|
||||
<resteasy.version>6.0.3.Final</resteasy.version>
|
||||
<module-name>io.cloudevents.http.restfulws</module-name>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<artifactId>cloudevents-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.ws.rs</groupId>
|
||||
<artifactId>jakarta.ws.rs-api</artifactId>
|
||||
<version>${jakarta-ee.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources
|
||||
</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<delete dir="src/main"/>
|
||||
<copy todir="src">
|
||||
<fileset dir="../restful-ws\src" />
|
||||
<filterchain>
|
||||
<replaceregex pattern="javax." replace="jakarta." />
|
||||
</filterchain>
|
||||
</copy>
|
||||
<move todir="src/main/resources/META-INF/services">
|
||||
<fileset dir="src/main/resources/META-INF/services" />
|
||||
<mapper type="regexp" from="(.*)javax.(.*)" to="\1jakarta.\2"/>
|
||||
</move>
|
||||
</target>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
2
pom.xml
2
pom.xml
|
@ -74,6 +74,7 @@
|
|||
<module>http/basic</module>
|
||||
<module>http/vertx</module>
|
||||
<module>http/restful-ws</module>
|
||||
<module>http/restful-ws-jakarta</module>
|
||||
<module>kafka</module>
|
||||
<module>spring</module>
|
||||
<module>sql</module>
|
||||
|
@ -209,6 +210,7 @@
|
|||
<modules>
|
||||
<module>benchmarks</module>
|
||||
<module>http/restful-ws-integration-tests</module>
|
||||
<module>http/restful-ws-jakarta-integration-tests</module>
|
||||
<module>examples</module>
|
||||
</modules>
|
||||
</profile>
|
||||
|
|
Loading…
Reference in New Issue