From c9aa8675c09af2eecd123140a1e1d2632b6a8dfa Mon Sep 17 00:00:00 2001 From: alex-butcher Date: Fri, 19 Aug 2022 11:07:13 +0100 Subject: [PATCH 01/19] Initial commit - replace javax restful-ws namespace usage with jakarata in own module Add microprofile with openliberty example using new jar Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- .gitignore | 1 + examples/pom.xml | 1 + .../restful-ws-microprofile-ee9/README.md | 140 +++++++++++++ examples/restful-ws-microprofile-ee9/pom.xml | 184 ++++++++++++++++++ .../microprofile/CloudEventsApplication.java | 9 + .../microprofile/CloudEventsJaxrsService.java | 56 ++++++ .../src/main/liberty/config/server.xml | 25 +++ .../ws/{ => jakarta}/jersey/TestJersey.java | 2 +- .../{ => jakarta}/resteasy/TestResteasy.java | 2 +- .../pom.xml | 27 +++ .../restful-ws-jakarta-common/pom.xml | 39 ++++ .../cloudevents/http/restful/ws/BaseTest.java | 103 ++++++++++ .../http/restful/ws/TestResource.java | 67 +++++++ .../restful-ws-microprofile/pom.xml | 16 ++ .../restful-ws-resteasy/pom.xml | 44 +++++ .../ws/jakarta/resteasy/TestResteasy.java | 62 ++++++ http/restful-ws-jakarta/pom.xml | 96 +++++++++ pom.xml | 2 + 18 files changed, 874 insertions(+), 2 deletions(-) create mode 100644 examples/restful-ws-microprofile-ee9/README.md create mode 100644 examples/restful-ws-microprofile-ee9/pom.xml create mode 100644 examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java create mode 100644 examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java create mode 100644 examples/restful-ws-microprofile-ee9/src/main/liberty/config/server.xml rename http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/{ => jakarta}/jersey/TestJersey.java (97%) rename http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/{ => jakarta}/resteasy/TestResteasy.java (97%) create mode 100644 http/restful-ws-jakarta-integration-tests/pom.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/BaseTest.java create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/TestResource.java create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java create mode 100644 http/restful-ws-jakarta/pom.xml diff --git a/.gitignore b/.gitignore index 4320cfaa4..dfd7df02e 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ _site/ # MacOS *.DS_Store +/http/restful-ws-jakarta/src/main/java/ diff --git a/examples/pom.xml b/examples/pom.xml index 9a7ee82be..9ffa6486d 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -21,6 +21,7 @@ kafka restful-ws-quarkus + restful-ws-microprofile-ee9 vertx basic-http restful-ws-spring-boot diff --git a/examples/restful-ws-microprofile-ee9/README.md b/examples/restful-ws-microprofile-ee9/README.md new file mode 100644 index 000000000..6e6db680e --- /dev/null +++ b/examples/restful-ws-microprofile-ee9/README.md @@ -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-ee9` 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 +``` + + diff --git a/examples/restful-ws-microprofile-ee9/pom.xml b/examples/restful-ws-microprofile-ee9/pom.xml new file mode 100644 index 000000000..9fb4cabe5 --- /dev/null +++ b/examples/restful-ws-microprofile-ee9/pom.xml @@ -0,0 +1,184 @@ + + + cloudevents-examples + io.cloudevents + 2.4.0-SNAPSHOT + ../ + + 4.0.0 + cloudevents-restful-ws-microprofile-example + war + + + 3.5.1 + cloudevents-microprofile + + + cloudeventsServer + 9080 + 9443 + + cloudeventsexperiments + ${project.build.directory}/${app.name}.zip + UTF-8 + + + + + runnable + + ${project.build.directory}/${app.name}.jar + runnable + + + + + + + org.eclipse.microprofile + microprofile + 5.0 + pom + provided + + + io.cloudevents + cloudevents-http-restful-ws-ee9 + ${project.parent.version} + + + io.projectreactor + reactor-core + 3.4.21 + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + false + pom.xml + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.10 + + + copy-server-files + package + + copy-dependencies + + + server-snippet + true + + ${project.build.directory}/wlp/usr/servers/${wlpServerName}/configDropins/defaults + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.7 + + + copy-app + package + + copy-resources + + + ${project.build.directory}/wlp/usr/servers/${wlpServerName}/dropins + + + + ${project.build.directory} + + ${project.artifactId}-${project.version}.war + + + + + + + + + + io.openliberty.tools + liberty-maven-plugin + ${openliberty.maven.version} + + + package-server + package + + create + install-feature + deploy + package + + + target/wlp-package + + + + + runnable + ${final.name} + + ${final.name} + https://server.example.com + / + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.18.1 + + + integration-test + integration-test + + integration-test + + + + **/it/** + + + ${testServerHttpPort} + ${warContext} + ${running.bluemix} + ${cf.context.root} + + + + + verify-results + + verify + + + + + ${project.build.directory}/test-reports/it/failsafe-summary.xml + ${project.build.directory}/test-reports/it + + + + + diff --git a/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java b/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java new file mode 100644 index 000000000..fc212316f --- /dev/null +++ b/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java @@ -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 { + +} diff --git a/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java b/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java new file mode 100644 index 000000000..eef7fe882 --- /dev/null +++ b/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java @@ -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(); + } + + +} diff --git a/examples/restful-ws-microprofile-ee9/src/main/liberty/config/server.xml b/examples/restful-ws-microprofile-ee9/src/main/liberty/config/server.xml new file mode 100644 index 000000000..eaac3901f --- /dev/null +++ b/examples/restful-ws-microprofile-ee9/src/main/liberty/config/server.xml @@ -0,0 +1,25 @@ + + + + + microProfile-5.0 + + + + + + + + + + + + + + + + + + diff --git a/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jersey/TestJersey.java b/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java similarity index 97% rename from http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jersey/TestJersey.java rename to http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java index 6c17e0505..772cc90b4 100644 --- a/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jersey/TestJersey.java +++ b/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java @@ -15,7 +15,7 @@ * */ -package io.cloudevents.http.restful.ws.jersey; +package io.cloudevents.http.restful.ws.jakarta.jersey; import com.github.hanleyt.JerseyExtension; import io.cloudevents.core.mock.CSVFormat; diff --git a/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/resteasy/TestResteasy.java b/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java similarity index 97% rename from http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/resteasy/TestResteasy.java rename to http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java index cba075146..3bbcf02bb 100644 --- a/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/resteasy/TestResteasy.java +++ b/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java @@ -16,7 +16,7 @@ * */ -package io.cloudevents.http.restful.ws.resteasy; +package io.cloudevents.http.restful.ws.jakarta.resteasy; import io.cloudevents.core.mock.CSVFormat; import io.cloudevents.core.provider.EventFormatProvider; diff --git a/http/restful-ws-jakarta-integration-tests/pom.xml b/http/restful-ws-jakarta-integration-tests/pom.xml new file mode 100644 index 000000000..40f5288a7 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/pom.xml @@ -0,0 +1,27 @@ + + + + cloudevents-parent + io.cloudevents + 2.4.0-SNAPSHOT + ../ + + 4.0.0 + + restful-ws-jakarta-integration-tests + pom + + + + true + + + + restful-ws-jakarta-common + restful-ws-microprofile + restful-ws-resteasy + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml new file mode 100644 index 000000000..16f4f04b9 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml @@ -0,0 +1,39 @@ + + + restful-ws-jakarta-integration-tests + io.cloudevents + 2.4.0-SNAPSHOT + ../ + + 4.0.0 + cloudevents-http-restful-ws-jakarta-integration-tests-common + CloudEvents - JAX-RS Jakarta Integration Tests - Common + jar + + + + io.cloudevents + cloudevents-http-restful-ws-ee9 + ${project.parent.version} + + + io.cloudevents + cloudevents-core + tests + test-jar + ${project.version} + + + + org.assertj + assertj-core + ${assertj-core.version} + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/BaseTest.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/BaseTest.java new file mode 100644 index 000000000..ea5cc7569 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/BaseTest.java @@ -0,0 +1,103 @@ +/* + * Copyright 2018-Present The CloudEvents Authors + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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); + } +} diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/TestResource.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/TestResource.java new file mode 100644 index 000000000..923a8572d --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/TestResource.java @@ -0,0 +1,67 @@ +/* + * Copyright 2018-Present The CloudEvents Authors + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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(); + } +} diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml new file mode 100644 index 000000000..595e1e3a5 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml @@ -0,0 +1,16 @@ + + + + restful-ws-jakarta-integration-tests + io.cloudevents + 2.4.0-SNAPSHOT + ../ + + 4.0.0 + + cloudevents-http-restful-ws-jakarta-integration-tests-microprofile + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml new file mode 100644 index 000000000..f29f7eaf4 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml @@ -0,0 +1,44 @@ + + + restful-ws-jakarta-integration-tests + io.cloudevents + 2.4.0-SNAPSHOT + + 4.0.0 + + cloudevents-http-restful-ws-jakarta-integration-tests-resteasy + CloudEvents - JAX-RS Jakarta Integration Tests - RESTEasy + jar + + + + 4.3.3 + 6.0.3.Final + + + + + + io.cloudevents + cloudevents-http-restful-ws-jakarta-integration-tests-common + ${project.version} + test + + + + io.vertx + vertx-core + ${vertx.version} + test + + + org.jboss.resteasy + resteasy-vertx + ${resteasy.version} + test + + + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java new file mode 100644 index 000000000..5cac8fdff --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java @@ -0,0 +1,62 @@ + +/* + * Copyright 2018-Present The CloudEvents Authors + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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(); + } + +} diff --git a/http/restful-ws-jakarta/pom.xml b/http/restful-ws-jakarta/pom.xml new file mode 100644 index 000000000..e09b36905 --- /dev/null +++ b/http/restful-ws-jakarta/pom.xml @@ -0,0 +1,96 @@ + + + + 4.0.0 + + io.cloudevents + cloudevents-parent + 2.4.0-SNAPSHOT + ../../pom.xml + + + cloudevents-http-restful-ws-ee9 + CloudEvents - Jakarta EE9 RESTful Web Services Http Binding + jar + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + default + + true + + + + + + 3.0.0 + 2.30.1 + 3.9.0 + 4.5.3.Final + io.cloudevents.http.restfulws + + + + + io.cloudevents + cloudevents-core + ${project.version} + + + jakarta.ws.rs + jakarta.ws.rs-api + ${jakarta-ee.version} + + + + + + + maven-antrun-plugin + 3.0.0 + + + generate-sources + + + + + + + + + + + + + + + run + + + + + + + + diff --git a/pom.xml b/pom.xml index f63d8a47a..842002e70 100644 --- a/pom.xml +++ b/pom.xml @@ -74,10 +74,12 @@ http/basic http/vertx http/restful-ws + http/restful-ws-jakarta kafka spring sql bom + http/restful-ws-jakarta-integration-tests From af0483c5c6f619dfff0e1010fec9c95c3f86cd62 Mon Sep 17 00:00:00 2001 From: alex-butcher <21243172+abutch3r@users.noreply.github.com> Date: Fri, 19 Aug 2022 11:18:24 +0100 Subject: [PATCH 02/19] update gitignore to cover all copied directories Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index dfd7df02e..9cc77463c 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,5 @@ _site/ # MacOS *.DS_Store -/http/restful-ws-jakarta/src/main/java/ +/http/restful-ws-jakarta/src/main/* + From d564b9e715d1c58b60fd83a1eb123d3bc75149f9 Mon Sep 17 00:00:00 2001 From: alex-butcher <21243172+abutch3r@users.noreply.github.com> Date: Mon, 12 Sep 2022 12:17:41 +0100 Subject: [PATCH 03/19] Update Jersey Version to support jakarta.* namespace packages Port jersey integration tests from javax.* to jakarta.* Includes port of jersey-junit to support jakarta as no current version exists that does. Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- .../pom.xml | 1 + .../restful-ws-jakarta-jersey/pom.xml | 68 ++++++++++ .../com/github/hanleyt/JerseyExtension.java | 128 ++++++++++++++++++ .../restful/ws/jakarta/jersey/TestJersey.java | 68 ++++++++++ http/restful-ws-jakarta/pom.xml | 2 +- 5 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java diff --git a/http/restful-ws-jakarta-integration-tests/pom.xml b/http/restful-ws-jakarta-integration-tests/pom.xml index 40f5288a7..ddc086b1c 100644 --- a/http/restful-ws-jakarta-integration-tests/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/pom.xml @@ -22,6 +22,7 @@ restful-ws-jakarta-common restful-ws-microprofile restful-ws-resteasy + restful-ws-jakarta-jersey diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml new file mode 100644 index 000000000..32a6d4881 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml @@ -0,0 +1,68 @@ + + + + + + restful-ws-jakarta-integration-tests + io.cloudevents + 2.4.0-SNAPSHOT + ../ + + 4.0.0 + + cloudevents-http-restful-ws-jakarta-integration-tests-jersey + CloudEvents - JAX-RS Integration Tests - Jersey + jar + + + 3.0.0 + + + + + + io.cloudevents + cloudevents-http-restful-ws-jakarta-integration-tests-common + ${project.version} + test + + + jakarta.ws.rs + jakarta.ws.rs-api + ${jakarta-ee.version} + + + org.glassfish.jersey.test-framework.providers + jersey-test-framework-provider-jetty + ${jersey.version} + + + org.glassfish.jersey.inject + jersey-hk2 + ${jersey.version} + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java new file mode 100644 index 000000000..b1453c87e --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java @@ -0,0 +1,128 @@ +/* + * Ported from https://github.com/hanleyt/jersey-junit as no version support Jesery versions >=3.0.0 + */ + +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> INJECTABLE_PARAMETER_TYPES = Arrays.asList(Client.class, WebTarget.class, URI.class); + + private final Function testContainerFactoryProvider; + private final Function deploymentContextProvider; + private final BiFunction configProvider; + + private JerseyExtension() { + throw new IllegalStateException("JerseyExtension must be registered programmatically"); + } + + public JerseyExtension(Supplier applicationSupplier) { + this((unused) -> applicationSupplier.get(), null); + } + + public JerseyExtension(Supplier applicationSupplier, + BiFunction configProvider) { + this((unused) -> applicationSupplier.get(), configProvider); + } + + public JerseyExtension(Function applicationProvider) { + this(applicationProvider, null); + } + + public JerseyExtension(Function applicationProvider, + BiFunction configProvider) { + this(null, (context) -> DeploymentContext.builder(applicationProvider.apply(context)).build(), configProvider); + } + + public JerseyExtension(Function testContainerFactoryProvider, + Function deploymentContextProvider, + BiFunction 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); + } + +} diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java new file mode 100644 index 000000000..fb54c3164 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java @@ -0,0 +1,68 @@ +/* + * Copyright 2018-Present The CloudEvents Authors + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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); + } + +} diff --git a/http/restful-ws-jakarta/pom.xml b/http/restful-ws-jakarta/pom.xml index e09b36905..97ee6caa7 100644 --- a/http/restful-ws-jakarta/pom.xml +++ b/http/restful-ws-jakarta/pom.xml @@ -42,7 +42,7 @@ 3.0.0 - 2.30.1 + 3.0.8 3.9.0 4.5.3.Final io.cloudevents.http.restfulws From a5f4ba3c066dfe0152337077287b9ae80b684bad Mon Sep 17 00:00:00 2001 From: alex-butcher <21243172+abutch3r@users.noreply.github.com> Date: Mon, 12 Sep 2022 15:24:07 +0100 Subject: [PATCH 04/19] Undo changes to existing integration test package names fix file paths Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- .../http/restful/ws/{jakarta => }/jersey/TestJersey.java | 2 +- .../http/restful/ws/{jakarta => }/resteasy/TestResteasy.java | 2 +- http/restful-ws-jakarta-integration-tests/pom.xml | 2 +- .../{restful-ws-jakarta-jersey => restful-ws-jersey}/pom.xml | 1 + .../src/main/java/com/github/hanleyt/JerseyExtension.java | 0 .../cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java | 0 6 files changed, 4 insertions(+), 3 deletions(-) rename http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/{jakarta => }/jersey/TestJersey.java (97%) rename http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/{jakarta => }/resteasy/TestResteasy.java (97%) rename http/restful-ws-jakarta-integration-tests/{restful-ws-jakarta-jersey => restful-ws-jersey}/pom.xml (98%) rename http/restful-ws-jakarta-integration-tests/{restful-ws-jakarta-jersey => restful-ws-jersey}/src/main/java/com/github/hanleyt/JerseyExtension.java (100%) rename http/restful-ws-jakarta-integration-tests/{restful-ws-jakarta-jersey => restful-ws-jersey}/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java (100%) diff --git a/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java b/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jersey/TestJersey.java similarity index 97% rename from http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java rename to http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jersey/TestJersey.java index 772cc90b4..6c17e0505 100644 --- a/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java +++ b/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jersey/TestJersey.java @@ -15,7 +15,7 @@ * */ -package io.cloudevents.http.restful.ws.jakarta.jersey; +package io.cloudevents.http.restful.ws.jersey; import com.github.hanleyt.JerseyExtension; import io.cloudevents.core.mock.CSVFormat; diff --git a/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java b/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/resteasy/TestResteasy.java similarity index 97% rename from http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java rename to http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/resteasy/TestResteasy.java index 3bbcf02bb..cba075146 100644 --- a/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java +++ b/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/resteasy/TestResteasy.java @@ -16,7 +16,7 @@ * */ -package io.cloudevents.http.restful.ws.jakarta.resteasy; +package io.cloudevents.http.restful.ws.resteasy; import io.cloudevents.core.mock.CSVFormat; import io.cloudevents.core.provider.EventFormatProvider; diff --git a/http/restful-ws-jakarta-integration-tests/pom.xml b/http/restful-ws-jakarta-integration-tests/pom.xml index ddc086b1c..5347893db 100644 --- a/http/restful-ws-jakarta-integration-tests/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/pom.xml @@ -22,7 +22,7 @@ restful-ws-jakarta-common restful-ws-microprofile restful-ws-resteasy - restful-ws-jakarta-jersey + restful-ws-jersey diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml similarity index 98% rename from http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml rename to http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml index 32a6d4881..2da17db2d 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml @@ -32,6 +32,7 @@ jar + 3.0.8 3.0.0 diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java similarity index 100% rename from http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java rename to http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java similarity index 100% rename from http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java rename to http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java From 71249711e4eb153ca4c8737e12f7f36e0b4f310c Mon Sep 17 00:00:00 2001 From: alex-butcher <21243172+abutch3r@users.noreply.github.com> Date: Fri, 16 Sep 2022 16:09:00 +0100 Subject: [PATCH 05/19] Add Integration test for Microprofile/Liberty for Jee9 package Tidy-up pom files and filepaths Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- examples/pom.xml | 2 +- .../README.md | 2 +- .../pom.xml | 4 +- .../microprofile/CloudEventsApplication.java | 0 .../microprofile/CloudEventsJaxrsService.java | 0 .../src/main/liberty/config/server.xml | 0 .../pom.xml | 5 +- .../restful-ws-jakarta-common/pom.xml | 7 +- .../restful-ws-jersey/pom.xml | 8 +- .../com/github/hanleyt/JerseyExtension.java | 4 +- .../restful-ws-liberty/pom.xml | 164 ++++++++++++++++++ .../cloudevents/restful/mp/test/MpCEApp.java | 9 + .../restful/mp/test/TestResource.java | 60 +++++++ .../src/main/liberty/config/server.xml | 18 ++ .../microprofile/TestMicroprofile.java | 123 +++++++++++++ .../restful-ws-microprofile/pom.xml | 16 -- .../restful-ws-resteasy/pom.xml | 5 +- http/restful-ws-jakarta/pom.xml | 15 +- pom.xml | 2 +- 19 files changed, 405 insertions(+), 39 deletions(-) rename examples/{restful-ws-microprofile-ee9 => restful-ws-microprofile-liberty}/README.md (98%) rename examples/{restful-ws-microprofile-ee9 => restful-ws-microprofile-liberty}/pom.xml (98%) rename examples/{restful-ws-microprofile-ee9 => restful-ws-microprofile-liberty}/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java (100%) rename examples/{restful-ws-microprofile-ee9 => restful-ws-microprofile-liberty}/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java (100%) rename examples/{restful-ws-microprofile-ee9 => restful-ws-microprofile-liberty}/src/main/liberty/config/server.xml (100%) rename http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/{main => test}/java/com/github/hanleyt/JerseyExtension.java (97%) create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/MpCEApp.java create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/TestResource.java create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/liberty/config/server.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/test/java/io/cloudevents/http/restful/ws/jakarta/microprofile/TestMicroprofile.java delete mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml diff --git a/examples/pom.xml b/examples/pom.xml index 9ffa6486d..fe13f0540 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -21,7 +21,7 @@ kafka restful-ws-quarkus - restful-ws-microprofile-ee9 + restful-ws-microprofile-liberty vertx basic-http restful-ws-spring-boot diff --git a/examples/restful-ws-microprofile-ee9/README.md b/examples/restful-ws-microprofile-liberty/README.md similarity index 98% rename from examples/restful-ws-microprofile-ee9/README.md rename to examples/restful-ws-microprofile-liberty/README.md index 6e6db680e..a5a320222 100644 --- a/examples/restful-ws-microprofile-ee9/README.md +++ b/examples/restful-ws-microprofile-liberty/README.md @@ -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 diff --git a/examples/restful-ws-microprofile-ee9/pom.xml b/examples/restful-ws-microprofile-liberty/pom.xml similarity index 98% rename from examples/restful-ws-microprofile-ee9/pom.xml rename to examples/restful-ws-microprofile-liberty/pom.xml index 9fb4cabe5..8a4338cd1 100644 --- a/examples/restful-ws-microprofile-ee9/pom.xml +++ b/examples/restful-ws-microprofile-liberty/pom.xml @@ -7,7 +7,7 @@ ../ 4.0.0 - cloudevents-restful-ws-microprofile-example + cloudevents-restful-ws-microprofile-liberty-example war @@ -44,7 +44,7 @@ io.cloudevents - cloudevents-http-restful-ws-ee9 + cloudevents-http-restful-ws-jakarta ${project.parent.version} diff --git a/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java b/examples/restful-ws-microprofile-liberty/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java similarity index 100% rename from examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java rename to examples/restful-ws-microprofile-liberty/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java diff --git a/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java b/examples/restful-ws-microprofile-liberty/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java similarity index 100% rename from examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java rename to examples/restful-ws-microprofile-liberty/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java diff --git a/examples/restful-ws-microprofile-ee9/src/main/liberty/config/server.xml b/examples/restful-ws-microprofile-liberty/src/main/liberty/config/server.xml similarity index 100% rename from examples/restful-ws-microprofile-ee9/src/main/liberty/config/server.xml rename to examples/restful-ws-microprofile-liberty/src/main/liberty/config/server.xml diff --git a/http/restful-ws-jakarta-integration-tests/pom.xml b/http/restful-ws-jakarta-integration-tests/pom.xml index 5347893db..4d813060e 100644 --- a/http/restful-ws-jakarta-integration-tests/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/pom.xml @@ -10,7 +10,8 @@ 4.0.0 - restful-ws-jakarta-integration-tests + cloudevents-http-restful-ws-jakarta-integration-tests + CloudEvents - JAX-RS Jakarta EE9+ Web Http Binding Integration Tests pom @@ -20,9 +21,9 @@ restful-ws-jakarta-common - restful-ws-microprofile restful-ws-resteasy restful-ws-jersey + restful-ws-liberty diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml index 16f4f04b9..0845b89a2 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml @@ -1,20 +1,20 @@ - restful-ws-jakarta-integration-tests + cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents 2.4.0-SNAPSHOT ../ 4.0.0 cloudevents-http-restful-ws-jakarta-integration-tests-common - CloudEvents - JAX-RS Jakarta Integration Tests - Common + CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - Common jar io.cloudevents - cloudevents-http-restful-ws-ee9 + cloudevents-http-restful-ws-jakarta ${project.parent.version} @@ -24,7 +24,6 @@ test-jar ${project.version} - org.assertj assertj-core diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml index 2da17db2d..5480c4ae9 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml @@ -20,7 +20,7 @@ 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"> - restful-ws-jakarta-integration-tests + cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents 2.4.0-SNAPSHOT ../ @@ -28,7 +28,7 @@ 4.0.0 cloudevents-http-restful-ws-jakarta-integration-tests-jersey - CloudEvents - JAX-RS Integration Tests - Jersey + CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - Jersey jar @@ -48,21 +48,25 @@ jakarta.ws.rs jakarta.ws.rs-api ${jakarta-ee.version} + test org.glassfish.jersey.test-framework.providers jersey-test-framework-provider-jetty ${jersey.version} + test org.glassfish.jersey.inject jersey-hk2 ${jersey.version} + test org.junit.jupiter junit-jupiter-api ${junit-jupiter.version} + test diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/test/java/com/github/hanleyt/JerseyExtension.java similarity index 97% rename from http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java rename to http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/test/java/com/github/hanleyt/JerseyExtension.java index b1453c87e..066535c05 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/test/java/com/github/hanleyt/JerseyExtension.java @@ -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; diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml new file mode 100644 index 000000000..81d1098fa --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml @@ -0,0 +1,164 @@ + + + + cloudevents-http-restful-ws-jakarta-integration-tests + io.cloudevents + 2.4.0-SNAPSHOT + ../ + + 4.0.0 + + cloudevents-http-restful-ws-jakarta-integration-tests-microprofile + CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - Microprofile and Liberty + + + UTF-8 + UTF-8 + 1.8 + 1.8 + + 9080 + 9443 + + microprofile-test + + + + + + org.jboss.arquillian + arquillian-bom + 1.6.0.Final + pom + import + + + + + + + + jakarta.platform + jakarta.jakartaee-api + 9.1.0 + provided + + + org.eclipse.microprofile + microprofile + 5.0 + pom + provided + + + io.cloudevents + cloudevents-http-restful-ws-jakarta + ${project.version} + + + io.cloudevents + cloudevents-core + tests + test-jar + ${project.version} + + + org.jboss.resteasy + resteasy-client + 6.0.0.Final + test + + + org.jboss.resteasy + resteasy-json-binding-provider + 6.0.0.Final + test + + + org.glassfish + jakarta.json + 2.0.1 + test + + + + javax.xml.bind + jaxb-api + 2.3.1 + + + javax.activation + activation + 1.1.1 + + + io.openliberty.arquillian + arquillian-liberty-managed-jakarta-junit + 2.0.2 + pom + test + + + org.jboss.shrinkwrap + shrinkwrap-api + test + + + + + ${project.artifactId} + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + pom.xml + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.22.2 + + + ${arquillian.war.name}.war + + + + + test + + integration-test + + + + + + io.openliberty.tools + liberty-maven-plugin + 3.5.1 + + + + -Dsystem.context.root=/${arquillian.war.name} + + + + + + arquillian-configuration + generate-test-resources + + create + install-feature + configure-arquillian + + + + + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/MpCEApp.java b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/MpCEApp.java new file mode 100644 index 000000000..279cdb3e4 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/MpCEApp.java @@ -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 { + +} diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/TestResource.java b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/TestResource.java new file mode 100644 index 000000000..5a73efeb6 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/TestResource.java @@ -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(); + } +} diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/liberty/config/server.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/liberty/config/server.xml new file mode 100644 index 000000000..9725cb9c8 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/liberty/config/server.xml @@ -0,0 +1,18 @@ + + + + microProfile-5.0 + + localConnector-1.0 + servlet-5.0 + + + + + + + + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/test/java/io/cloudevents/http/restful/ws/jakarta/microprofile/TestMicroprofile.java b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/test/java/io/cloudevents/http/restful/ws/jakarta/microprofile/TestMicroprofile.java new file mode 100644 index 000000000..184fa2c8d --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/test/java/io/cloudevents/http/restful/ws/jakarta/microprofile/TestMicroprofile.java @@ -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()); + } +} diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml deleted file mode 100644 index 595e1e3a5..000000000 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - restful-ws-jakarta-integration-tests - io.cloudevents - 2.4.0-SNAPSHOT - ../ - - 4.0.0 - - cloudevents-http-restful-ws-jakarta-integration-tests-microprofile - - - diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml index f29f7eaf4..b4db4b968 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml @@ -1,14 +1,15 @@ - restful-ws-jakarta-integration-tests + cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents 2.4.0-SNAPSHOT + ../ 4.0.0 cloudevents-http-restful-ws-jakarta-integration-tests-resteasy - CloudEvents - JAX-RS Jakarta Integration Tests - RESTEasy + CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - RESTEasy jar diff --git a/http/restful-ws-jakarta/pom.xml b/http/restful-ws-jakarta/pom.xml index 97ee6caa7..b4909068f 100644 --- a/http/restful-ws-jakarta/pom.xml +++ b/http/restful-ws-jakarta/pom.xml @@ -25,8 +25,8 @@ ../../pom.xml - cloudevents-http-restful-ws-ee9 - CloudEvents - Jakarta EE9 RESTful Web Services Http Binding + cloudevents-http-restful-ws-jakarta + CloudEvents - Jakarta EE 9+ - Jakarta RESTful Web Services Http Binding jar @@ -43,8 +43,8 @@ 3.0.0 3.0.8 - 3.9.0 - 4.5.3.Final + 4.4.3 + 6.0.3.Final io.cloudevents.http.restfulws @@ -79,9 +79,10 @@ - + + + + diff --git a/pom.xml b/pom.xml index 842002e70..dd99ae28f 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,6 @@ spring sql bom - http/restful-ws-jakarta-integration-tests @@ -211,6 +210,7 @@ benchmarks http/restful-ws-integration-tests + http/restful-ws-jakarta-integration-tests examples From 8e52f7d4dd0f7b4d785a37076c15e9fbeb5c2374 Mon Sep 17 00:00:00 2001 From: alex-butcher <21243172+abutch3r@users.noreply.github.com> Date: Tue, 20 Sep 2022 11:48:19 +0100 Subject: [PATCH 06/19] Add documentation for new Jakarta package Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- docs/http-jakarta-restful-ws-jakarta.md | 137 ++++++++++++++++++++++++ docs/http-jakarta-restful-ws.md | 4 +- docs/index.md | 8 +- http/restful-ws-jakarta/README.md | 7 ++ 4 files changed, 152 insertions(+), 4 deletions(-) create mode 100644 docs/http-jakarta-restful-ws-jakarta.md create mode 100644 http/restful-ws-jakarta/README.md diff --git a/docs/http-jakarta-restful-ws-jakarta.md b/docs/http-jakarta-restful-ws-jakarta.md new file mode 100644 index 000000000..e9f8c8280 --- /dev/null +++ b/docs/http-jakarta-restful-ws-jakarta.md @@ -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 + +[![Javadocs](https://www.javadoc.io/badge/io.cloudevents/cloudevents-http-restful-ws.svg?color=green)](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 + + io.cloudevents + cloudevents-http-restful-ws-jakarta + 2.5.0-SNAPSHOT + +``` + +This integration is tested with Jersey, 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) + diff --git a/docs/http-jakarta-restful-ws.md b/docs/http-jakarta-restful-ws.md index a7f08fefb..6cc179944 100644 --- a/docs/http-jakarta-restful-ws.md +++ b/docs/http-jakarta-restful-ws.md @@ -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 [![Javadocs](http://www.javadoc.io/badge/io.cloudevents/cloudevents-http-restful-ws.svg?color=green)](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 diff --git a/docs/index.md b/docs/index.md index ea4552f3a..07664c2ee 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 diff --git a/http/restful-ws-jakarta/README.md b/http/restful-ws-jakarta/README.md new file mode 100644 index 000000000..8f676ce2e --- /dev/null +++ b/http/restful-ws-jakarta/README.md @@ -0,0 +1,7 @@ +# HTTP Protocol Binding for Jakarta EE9+ - Jakarta RESTful Web Services + +Javadocs: [![Javadocs](http://www.javadoc.io/badge/io.cloudevents/cloudevents-http-restful-ws.svg?color=green)](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.` From 79a9290781882b2d5d6e4f356a3b7a8008682e26 Mon Sep 17 00:00:00 2001 From: Isaac Aymerich Date: Mon, 5 Sep 2022 13:14:38 +0200 Subject: [PATCH 07/19] Support dynamic JSON data content type (#471) Now checks if `datacontenttype` matches the regex: `^(application|text)\/([a-zA-Z]+\+)?json$")` This regex support `application/foobar+json` or standard ``` application/json text/json ``` Signed-off-by: Isaac Aymerich Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- .../io/cloudevents/jackson/JsonFormat.java | 8 +++++-- .../jackson/JsonCloudEventDataTest.java | 22 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/formats/json-jackson/src/main/java/io/cloudevents/jackson/JsonFormat.java b/formats/json-jackson/src/main/java/io/cloudevents/jackson/JsonFormat.java index 49467980b..8454a5a22 100644 --- a/formats/json-jackson/src/main/java/io/cloudevents/jackson/JsonFormat.java +++ b/formats/json-jackson/src/main/java/io/cloudevents/jackson/JsonFormat.java @@ -29,6 +29,7 @@ import io.cloudevents.rw.CloudEventRWException; import java.io.IOException; +import java.util.regex.Pattern; /** * Implementation of {@link EventFormat} for JSON event format @@ -43,7 +44,10 @@ public final class JsonFormat implements EventFormat { * Content type associated with the JSON event format */ public static final String CONTENT_TYPE = "application/cloudevents+json"; - + /** + * JSON Data Content Type Discriminator + */ + private static final Pattern JSON_CONTENT_TYPE_PATTERN = Pattern.compile("^(application|text)\\/([a-zA-Z]+\\+)?json$"); private final ObjectMapper mapper; private final JsonFormatOptions options; @@ -214,6 +218,6 @@ public static SimpleModule getCloudEventJacksonModule(JsonFormatOptions options) static boolean dataIsJsonContentType(String contentType) { // If content type, spec states that we should assume is json - return contentType == null || contentType.startsWith("application/json") || contentType.startsWith("text/json"); + return contentType == null || JSON_CONTENT_TYPE_PATTERN.matcher(contentType).matches(); } } diff --git a/formats/json-jackson/src/test/java/io/cloudevents/jackson/JsonCloudEventDataTest.java b/formats/json-jackson/src/test/java/io/cloudevents/jackson/JsonCloudEventDataTest.java index 9a4537e12..9ae8cfc26 100644 --- a/formats/json-jackson/src/test/java/io/cloudevents/jackson/JsonCloudEventDataTest.java +++ b/formats/json-jackson/src/test/java/io/cloudevents/jackson/JsonCloudEventDataTest.java @@ -23,16 +23,21 @@ import io.cloudevents.core.mock.MyCloudEventData; import io.cloudevents.core.provider.EventFormatProvider; import io.cloudevents.core.test.Data; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; public class JsonCloudEventDataTest { - @Test - public void testMapper() { + @ParameterizedTest + @MethodSource("textContentArguments") + public void testMapper(String contentType) { CloudEvent event = CloudEventBuilder.v1(Data.V1_MIN) - .withData("application/json", new JsonCloudEventData(JsonNodeFactory.instance.numberNode(10))) + .withData(contentType, new JsonCloudEventData(JsonNodeFactory.instance.numberNode(10))) .build(); byte[] serialized = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE) @@ -47,10 +52,19 @@ public void testMapper() { return new MyCloudEventData(((JsonCloudEventData) data).getNode().asInt()); }); + assertThat(deserialized.getDataContentType()) + .isEqualTo(contentType); assertThat(deserialized.getData()) .isInstanceOf(MyCloudEventData.class); assertThat(((MyCloudEventData) deserialized.getData()).getValue()) .isEqualTo(10); } + public static Stream textContentArguments() { + return Stream.of( + Arguments.of("application/json"), + Arguments.of("text/json"), + Arguments.of("application/foobar+json") + ); + } } From 17db1e7f2dd78b56ee5ffd36855962135c634c92 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 6 Sep 2022 15:52:34 +0200 Subject: [PATCH 08/19] Bump to 2.5.0-SNAPSHOT (#474) Signed-off-by: GitHub Co-authored-by: pierDipi Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- amqp/pom.xml | 2 +- api/pom.xml | 2 +- benchmarks/pom.xml | 2 +- bom/pom.xml | 2 +- core/pom.xml | 2 +- examples/amqp-proton/pom.xml | 2 +- examples/basic-http/pom.xml | 2 +- examples/kafka/pom.xml | 2 +- examples/pom.xml | 2 +- examples/restful-ws-quarkus/pom.xml | 2 +- examples/restful-ws-spring-boot/pom.xml | 2 +- examples/spring-function/pom.xml | 2 +- examples/spring-reactive/pom.xml | 2 +- examples/spring-rsocket/pom.xml | 2 +- examples/vertx/pom.xml | 2 +- formats/json-jackson/pom.xml | 2 +- formats/protobuf/pom.xml | 2 +- http/basic/pom.xml | 2 +- http/restful-ws-integration-tests/pom.xml | 2 +- http/restful-ws-integration-tests/restful-ws-common/pom.xml | 2 +- http/restful-ws-integration-tests/restful-ws-jersey/pom.xml | 2 +- http/restful-ws-integration-tests/restful-ws-resteasy/pom.xml | 2 +- http/restful-ws-integration-tests/restful-ws-spring/pom.xml | 2 +- http/restful-ws/pom.xml | 2 +- http/vertx/pom.xml | 2 +- kafka/pom.xml | 2 +- pom.xml | 2 +- spring/pom.xml | 2 +- sql/pom.xml | 2 +- 29 files changed, 29 insertions(+), 29 deletions(-) diff --git a/amqp/pom.xml b/amqp/pom.xml index cff9ac2d9..23853c594 100644 --- a/amqp/pom.xml +++ b/amqp/pom.xml @@ -6,7 +6,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT cloudevents-amqp-proton diff --git a/api/pom.xml b/api/pom.xml index 885668ba0..cb657fa82 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -24,7 +24,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT cloudevents-api diff --git a/benchmarks/pom.xml b/benchmarks/pom.xml index 5439585d5..78e6b87cd 100644 --- a/benchmarks/pom.xml +++ b/benchmarks/pom.xml @@ -21,7 +21,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT cloudevents-benchmarks diff --git a/bom/pom.xml b/bom/pom.xml index c7b6eaaff..8441369ce 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -22,7 +22,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT cloudevents-bom diff --git a/core/pom.xml b/core/pom.xml index e037daa15..5104d4ff8 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -22,7 +22,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT cloudevents-core diff --git a/examples/amqp-proton/pom.xml b/examples/amqp-proton/pom.xml index 5b888ae31..6919bf4f2 100644 --- a/examples/amqp-proton/pom.xml +++ b/examples/amqp-proton/pom.xml @@ -3,7 +3,7 @@ cloudevents-examples io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT 4.0.0 diff --git a/examples/basic-http/pom.xml b/examples/basic-http/pom.xml index 27b162cda..7b57dbe25 100644 --- a/examples/basic-http/pom.xml +++ b/examples/basic-http/pom.xml @@ -21,7 +21,7 @@ cloudevents-examples io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT 4.0.0 diff --git a/examples/kafka/pom.xml b/examples/kafka/pom.xml index f20ca8320..e39e9d8eb 100644 --- a/examples/kafka/pom.xml +++ b/examples/kafka/pom.xml @@ -5,7 +5,7 @@ cloudevents-examples io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT 4.0.0 diff --git a/examples/pom.xml b/examples/pom.xml index fe13f0540..a706a51e2 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -5,7 +5,7 @@ cloudevents-parent io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT 4.0.0 diff --git a/examples/restful-ws-quarkus/pom.xml b/examples/restful-ws-quarkus/pom.xml index c5c2e691c..c6a145837 100644 --- a/examples/restful-ws-quarkus/pom.xml +++ b/examples/restful-ws-quarkus/pom.xml @@ -5,7 +5,7 @@ cloudevents-examples io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT 4.0.0 cloudevents-restful-ws-quarkus-example diff --git a/examples/restful-ws-spring-boot/pom.xml b/examples/restful-ws-spring-boot/pom.xml index 9b5a25bd8..5a66b8f89 100644 --- a/examples/restful-ws-spring-boot/pom.xml +++ b/examples/restful-ws-spring-boot/pom.xml @@ -5,7 +5,7 @@ cloudevents-examples io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT 4.0.0 diff --git a/examples/spring-function/pom.xml b/examples/spring-function/pom.xml index bd9c0ecb8..42a071d1f 100644 --- a/examples/spring-function/pom.xml +++ b/examples/spring-function/pom.xml @@ -5,7 +5,7 @@ cloudevents-examples io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT 4.0.0 diff --git a/examples/spring-reactive/pom.xml b/examples/spring-reactive/pom.xml index 06313d9ea..86f2bdac7 100644 --- a/examples/spring-reactive/pom.xml +++ b/examples/spring-reactive/pom.xml @@ -5,7 +5,7 @@ cloudevents-examples io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT 4.0.0 diff --git a/examples/spring-rsocket/pom.xml b/examples/spring-rsocket/pom.xml index 348b4ab64..505339f0e 100644 --- a/examples/spring-rsocket/pom.xml +++ b/examples/spring-rsocket/pom.xml @@ -5,7 +5,7 @@ cloudevents-examples io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT 4.0.0 diff --git a/examples/vertx/pom.xml b/examples/vertx/pom.xml index 31d56c4a5..76601c4c0 100644 --- a/examples/vertx/pom.xml +++ b/examples/vertx/pom.xml @@ -5,7 +5,7 @@ cloudevents-examples io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT 4.0.0 diff --git a/formats/json-jackson/pom.xml b/formats/json-jackson/pom.xml index a1a8146e1..1994883af 100644 --- a/formats/json-jackson/pom.xml +++ b/formats/json-jackson/pom.xml @@ -22,7 +22,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../../pom.xml diff --git a/formats/protobuf/pom.xml b/formats/protobuf/pom.xml index 0a8a2f7f8..50571d02c 100644 --- a/formats/protobuf/pom.xml +++ b/formats/protobuf/pom.xml @@ -23,7 +23,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../../pom.xml diff --git a/http/basic/pom.xml b/http/basic/pom.xml index 63cd764a9..446744f86 100644 --- a/http/basic/pom.xml +++ b/http/basic/pom.xml @@ -21,7 +21,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../../pom.xml diff --git a/http/restful-ws-integration-tests/pom.xml b/http/restful-ws-integration-tests/pom.xml index 8018ba56e..e35b4b383 100644 --- a/http/restful-ws-integration-tests/pom.xml +++ b/http/restful-ws-integration-tests/pom.xml @@ -22,7 +22,7 @@ cloudevents-parent io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/http/restful-ws-integration-tests/restful-ws-common/pom.xml b/http/restful-ws-integration-tests/restful-ws-common/pom.xml index 63a17aae0..1f2b7bb55 100644 --- a/http/restful-ws-integration-tests/restful-ws-common/pom.xml +++ b/http/restful-ws-integration-tests/restful-ws-common/pom.xml @@ -22,7 +22,7 @@ cloudevents-http-restful-ws-integration-tests io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 diff --git a/http/restful-ws-integration-tests/restful-ws-jersey/pom.xml b/http/restful-ws-integration-tests/restful-ws-jersey/pom.xml index cb5f2b84e..601afea1b 100644 --- a/http/restful-ws-integration-tests/restful-ws-jersey/pom.xml +++ b/http/restful-ws-integration-tests/restful-ws-jersey/pom.xml @@ -22,7 +22,7 @@ cloudevents-http-restful-ws-integration-tests io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 diff --git a/http/restful-ws-integration-tests/restful-ws-resteasy/pom.xml b/http/restful-ws-integration-tests/restful-ws-resteasy/pom.xml index f778f7fa2..d1f3c5a73 100644 --- a/http/restful-ws-integration-tests/restful-ws-resteasy/pom.xml +++ b/http/restful-ws-integration-tests/restful-ws-resteasy/pom.xml @@ -22,7 +22,7 @@ cloudevents-http-restful-ws-integration-tests io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 diff --git a/http/restful-ws-integration-tests/restful-ws-spring/pom.xml b/http/restful-ws-integration-tests/restful-ws-spring/pom.xml index c9e329775..54a4e7e4e 100644 --- a/http/restful-ws-integration-tests/restful-ws-spring/pom.xml +++ b/http/restful-ws-integration-tests/restful-ws-spring/pom.xml @@ -22,7 +22,7 @@ cloudevents-http-restful-ws-integration-tests io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 diff --git a/http/restful-ws/pom.xml b/http/restful-ws/pom.xml index ce58fe5dc..fd6550a6f 100644 --- a/http/restful-ws/pom.xml +++ b/http/restful-ws/pom.xml @@ -21,7 +21,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../../pom.xml diff --git a/http/vertx/pom.xml b/http/vertx/pom.xml index be808981a..6ff546a1d 100644 --- a/http/vertx/pom.xml +++ b/http/vertx/pom.xml @@ -22,7 +22,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../../pom.xml diff --git a/kafka/pom.xml b/kafka/pom.xml index a7caae6e5..c301ef720 100644 --- a/kafka/pom.xml +++ b/kafka/pom.xml @@ -23,7 +23,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT cloudevents-kafka diff --git a/pom.xml b/pom.xml index dd99ae28f..c959a6441 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT pom CloudEvents diff --git a/spring/pom.xml b/spring/pom.xml index 945554a87..84c78f0dc 100644 --- a/spring/pom.xml +++ b/spring/pom.xml @@ -23,7 +23,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT cloudevents-spring diff --git a/sql/pom.xml b/sql/pom.xml index 746f8a569..63d4f5551 100644 --- a/sql/pom.xml +++ b/sql/pom.xml @@ -5,7 +5,7 @@ cloudevents-parent io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT 4.0.0 From f56b2d7c0c4c7261384bd33ecf70acf2fca34135 Mon Sep 17 00:00:00 2001 From: Jorge Oliva <61975803+jolivaSan@users.noreply.github.com> Date: Wed, 14 Sep 2022 10:39:25 +0100 Subject: [PATCH 09/19] Fix example in "Materialize an Extension" (#475) Was using `ExtensionParser` instead `ExtensionProvider` Signed-off-by: Jorge Oliva Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- docs/core.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core.md b/docs/core.md index fcafac13d..992c3aca2 100644 --- a/docs/core.md +++ b/docs/core.md @@ -110,6 +110,6 @@ CloudEvent extensions can be materialized in their respective POJOs using the import io.cloudevents.core.extensions.DistributedTracingExtension; import io.cloudevents.core.provider.ExtensionProvider; -DistributedTracingExtension dte = ExtensionsParser.getInstance() +DistributedTracingExtension dte = ExtensionProvider.getInstance() .parseExtension(DistributedTracingExtension.class, event); ``` From 98dd3b72e570d8e8e3c6e7e4662903adf7333665 Mon Sep 17 00:00:00 2001 From: Gerard Klijs Date: Wed, 14 Sep 2022 15:46:09 +0200 Subject: [PATCH 10/19] Correct URL to naming-conventions (#477) Signed-off-by: Gerard Klijs Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- .../java/io/cloudevents/core/impl/BaseCloudEventBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/io/cloudevents/core/impl/BaseCloudEventBuilder.java b/core/src/main/java/io/cloudevents/core/impl/BaseCloudEventBuilder.java index 3268e70a3..69846c8eb 100644 --- a/core/src/main/java/io/cloudevents/core/impl/BaseCloudEventBuilder.java +++ b/core/src/main/java/io/cloudevents/core/impl/BaseCloudEventBuilder.java @@ -213,7 +213,7 @@ protected static IllegalStateException createMissingAttributeException(String at * * @param name the extension name * @return true if extension name is valid, false otherwise - * @see attribute-naming-convention + * @see attribute-naming-conventions */ private static boolean isValidExtensionName(String name) { for (int i = 0; i < name.length(); i++) { From 4f40b0ce78177579ef2b8df1c27a571736911cea Mon Sep 17 00:00:00 2001 From: Vikram Vuppla Date: Mon, 19 Sep 2022 10:31:31 -0500 Subject: [PATCH 11/19] Fix typo in word Covert (#480) Signed-off-by: Vikram Vuppla Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- .../java/io/cloudevents/examples/vertx/SampleHTTPServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vertx/src/main/java/io/cloudevents/examples/vertx/SampleHTTPServer.java b/examples/vertx/src/main/java/io/cloudevents/examples/vertx/SampleHTTPServer.java index 03a0aa595..d7c4fcf1e 100644 --- a/examples/vertx/src/main/java/io/cloudevents/examples/vertx/SampleHTTPServer.java +++ b/examples/vertx/src/main/java/io/cloudevents/examples/vertx/SampleHTTPServer.java @@ -23,7 +23,7 @@ public static void main(String[] args) { // We need to read the event from the HTTP request we get, so create a MessageReader. VertxMessageFactory.createReader(request) - // Covert the MessageReader to a CloudEvent. + // Convert the MessageReader to a CloudEvent. .map(MessageReader::toEvent) .onSuccess(event -> { // Print out the event. From b410cb9784020d54e218715a718c3246829896a0 Mon Sep 17 00:00:00 2001 From: alex-butcher <21243172+abutch3r@users.noreply.github.com> Date: Wed, 21 Sep 2022 15:01:48 +0100 Subject: [PATCH 12/19] Update new package version to match new version Disable new Jakarta EE 9 + Jersey test case as requires builidng SDK version to be 11 or greater Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- docs/http-jakarta-restful-ws-jakarta.md | 2 +- examples/restful-ws-microprofile-liberty/pom.xml | 2 +- http/restful-ws-jakarta-integration-tests/pom.xml | 7 ++++--- .../restful-ws-jakarta-common/pom.xml | 4 ++-- .../restful-ws-jersey/pom.xml | 2 +- .../restful-ws-liberty/pom.xml | 13 +++++-------- .../restful-ws-resteasy/pom.xml | 2 +- http/restful-ws-jakarta/pom.xml | 2 +- 8 files changed, 16 insertions(+), 18 deletions(-) diff --git a/docs/http-jakarta-restful-ws-jakarta.md b/docs/http-jakarta-restful-ws-jakarta.md index e9f8c8280..0eb4f43da 100644 --- a/docs/http-jakarta-restful-ws-jakarta.md +++ b/docs/http-jakarta-restful-ws-jakarta.md @@ -18,7 +18,7 @@ RESTful Web Services Binding for Jakarta EE 9+: ``` -This integration is tested with Jersey, RestEasy & Microprofile Liberty. +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. diff --git a/examples/restful-ws-microprofile-liberty/pom.xml b/examples/restful-ws-microprofile-liberty/pom.xml index 8a4338cd1..fa62353c0 100644 --- a/examples/restful-ws-microprofile-liberty/pom.xml +++ b/examples/restful-ws-microprofile-liberty/pom.xml @@ -3,7 +3,7 @@ cloudevents-examples io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 diff --git a/http/restful-ws-jakarta-integration-tests/pom.xml b/http/restful-ws-jakarta-integration-tests/pom.xml index 4d813060e..11e49266c 100644 --- a/http/restful-ws-jakarta-integration-tests/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/pom.xml @@ -5,8 +5,8 @@ cloudevents-parent io.cloudevents - 2.4.0-SNAPSHOT - ../ + 2.5.0-SNAPSHOT + ../../pom.xml 4.0.0 @@ -22,7 +22,8 @@ restful-ws-jakarta-common restful-ws-resteasy - restful-ws-jersey + + restful-ws-liberty diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml index 0845b89a2..d9d63d571 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml @@ -3,7 +3,7 @@ cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 @@ -15,7 +15,7 @@ io.cloudevents cloudevents-http-restful-ws-jakarta - ${project.parent.version} + ${project.version} io.cloudevents diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml index 5480c4ae9..fdf8bd9f5 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml @@ -22,7 +22,7 @@ cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml index 81d1098fa..1789438fb 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml @@ -5,19 +5,16 @@ cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 cloudevents-http-restful-ws-jakarta-integration-tests-microprofile CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - Microprofile and Liberty + war - UTF-8 - UTF-8 - 1.8 - 1.8 9080 9443 @@ -67,13 +64,13 @@ org.jboss.resteasy resteasy-client - 6.0.0.Final + 6.0.3.Final test org.jboss.resteasy resteasy-json-binding-provider - 6.0.0.Final + 6.0.3.Final test @@ -96,7 +93,7 @@ io.openliberty.arquillian arquillian-liberty-managed-jakarta-junit - 2.0.2 + 2.1.0 pom test diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml index b4db4b968..08a87fa73 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml @@ -3,7 +3,7 @@ cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 diff --git a/http/restful-ws-jakarta/pom.xml b/http/restful-ws-jakarta/pom.xml index b4909068f..6d64b836c 100644 --- a/http/restful-ws-jakarta/pom.xml +++ b/http/restful-ws-jakarta/pom.xml @@ -21,7 +21,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../../pom.xml From de32e18974b6289758bdbfe81f27d462d620a7ca Mon Sep 17 00:00:00 2001 From: alex-butcher Date: Fri, 19 Aug 2022 11:07:13 +0100 Subject: [PATCH 13/19] Initial commit - replace javax restful-ws namespace usage with jakarata in own module Add microprofile with openliberty example using new jar Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- .gitignore | 1 + examples/pom.xml | 1 + .../restful-ws-microprofile-ee9/README.md | 140 +++++++++++++ examples/restful-ws-microprofile-ee9/pom.xml | 184 ++++++++++++++++++ .../microprofile/CloudEventsApplication.java | 9 + .../microprofile/CloudEventsJaxrsService.java | 56 ++++++ .../src/main/liberty/config/server.xml | 25 +++ .../ws/{ => jakarta}/jersey/TestJersey.java | 2 +- .../{ => jakarta}/resteasy/TestResteasy.java | 2 +- .../pom.xml | 27 +++ .../restful-ws-jakarta-common/pom.xml | 39 ++++ .../cloudevents/http/restful/ws/BaseTest.java | 103 ++++++++++ .../http/restful/ws/TestResource.java | 67 +++++++ .../restful-ws-microprofile/pom.xml | 16 ++ .../restful-ws-resteasy/pom.xml | 44 +++++ .../ws/jakarta/resteasy/TestResteasy.java | 62 ++++++ http/restful-ws-jakarta/pom.xml | 96 +++++++++ pom.xml | 2 + 18 files changed, 874 insertions(+), 2 deletions(-) create mode 100644 examples/restful-ws-microprofile-ee9/README.md create mode 100644 examples/restful-ws-microprofile-ee9/pom.xml create mode 100644 examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java create mode 100644 examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java create mode 100644 examples/restful-ws-microprofile-ee9/src/main/liberty/config/server.xml rename http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/{ => jakarta}/jersey/TestJersey.java (97%) rename http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/{ => jakarta}/resteasy/TestResteasy.java (97%) create mode 100644 http/restful-ws-jakarta-integration-tests/pom.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/BaseTest.java create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/TestResource.java create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java create mode 100644 http/restful-ws-jakarta/pom.xml diff --git a/.gitignore b/.gitignore index 4320cfaa4..dfd7df02e 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ _site/ # MacOS *.DS_Store +/http/restful-ws-jakarta/src/main/java/ diff --git a/examples/pom.xml b/examples/pom.xml index 4f384d36a..d1955230a 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -21,6 +21,7 @@ kafka restful-ws-quarkus + restful-ws-microprofile-ee9 vertx basic-http restful-ws-spring-boot diff --git a/examples/restful-ws-microprofile-ee9/README.md b/examples/restful-ws-microprofile-ee9/README.md new file mode 100644 index 000000000..6e6db680e --- /dev/null +++ b/examples/restful-ws-microprofile-ee9/README.md @@ -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-ee9` 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 +``` + + diff --git a/examples/restful-ws-microprofile-ee9/pom.xml b/examples/restful-ws-microprofile-ee9/pom.xml new file mode 100644 index 000000000..9fb4cabe5 --- /dev/null +++ b/examples/restful-ws-microprofile-ee9/pom.xml @@ -0,0 +1,184 @@ + + + cloudevents-examples + io.cloudevents + 2.4.0-SNAPSHOT + ../ + + 4.0.0 + cloudevents-restful-ws-microprofile-example + war + + + 3.5.1 + cloudevents-microprofile + + + cloudeventsServer + 9080 + 9443 + + cloudeventsexperiments + ${project.build.directory}/${app.name}.zip + UTF-8 + + + + + runnable + + ${project.build.directory}/${app.name}.jar + runnable + + + + + + + org.eclipse.microprofile + microprofile + 5.0 + pom + provided + + + io.cloudevents + cloudevents-http-restful-ws-ee9 + ${project.parent.version} + + + io.projectreactor + reactor-core + 3.4.21 + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + false + pom.xml + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.10 + + + copy-server-files + package + + copy-dependencies + + + server-snippet + true + + ${project.build.directory}/wlp/usr/servers/${wlpServerName}/configDropins/defaults + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.7 + + + copy-app + package + + copy-resources + + + ${project.build.directory}/wlp/usr/servers/${wlpServerName}/dropins + + + + ${project.build.directory} + + ${project.artifactId}-${project.version}.war + + + + + + + + + + io.openliberty.tools + liberty-maven-plugin + ${openliberty.maven.version} + + + package-server + package + + create + install-feature + deploy + package + + + target/wlp-package + + + + + runnable + ${final.name} + + ${final.name} + https://server.example.com + / + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.18.1 + + + integration-test + integration-test + + integration-test + + + + **/it/** + + + ${testServerHttpPort} + ${warContext} + ${running.bluemix} + ${cf.context.root} + + + + + verify-results + + verify + + + + + ${project.build.directory}/test-reports/it/failsafe-summary.xml + ${project.build.directory}/test-reports/it + + + + + diff --git a/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java b/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java new file mode 100644 index 000000000..fc212316f --- /dev/null +++ b/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java @@ -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 { + +} diff --git a/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java b/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java new file mode 100644 index 000000000..eef7fe882 --- /dev/null +++ b/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java @@ -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(); + } + + +} diff --git a/examples/restful-ws-microprofile-ee9/src/main/liberty/config/server.xml b/examples/restful-ws-microprofile-ee9/src/main/liberty/config/server.xml new file mode 100644 index 000000000..eaac3901f --- /dev/null +++ b/examples/restful-ws-microprofile-ee9/src/main/liberty/config/server.xml @@ -0,0 +1,25 @@ + + + + + microProfile-5.0 + + + + + + + + + + + + + + + + + + diff --git a/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jersey/TestJersey.java b/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java similarity index 97% rename from http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jersey/TestJersey.java rename to http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java index 6c17e0505..772cc90b4 100644 --- a/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jersey/TestJersey.java +++ b/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java @@ -15,7 +15,7 @@ * */ -package io.cloudevents.http.restful.ws.jersey; +package io.cloudevents.http.restful.ws.jakarta.jersey; import com.github.hanleyt.JerseyExtension; import io.cloudevents.core.mock.CSVFormat; diff --git a/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/resteasy/TestResteasy.java b/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java similarity index 97% rename from http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/resteasy/TestResteasy.java rename to http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java index cba075146..3bbcf02bb 100644 --- a/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/resteasy/TestResteasy.java +++ b/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java @@ -16,7 +16,7 @@ * */ -package io.cloudevents.http.restful.ws.resteasy; +package io.cloudevents.http.restful.ws.jakarta.resteasy; import io.cloudevents.core.mock.CSVFormat; import io.cloudevents.core.provider.EventFormatProvider; diff --git a/http/restful-ws-jakarta-integration-tests/pom.xml b/http/restful-ws-jakarta-integration-tests/pom.xml new file mode 100644 index 000000000..40f5288a7 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/pom.xml @@ -0,0 +1,27 @@ + + + + cloudevents-parent + io.cloudevents + 2.4.0-SNAPSHOT + ../ + + 4.0.0 + + restful-ws-jakarta-integration-tests + pom + + + + true + + + + restful-ws-jakarta-common + restful-ws-microprofile + restful-ws-resteasy + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml new file mode 100644 index 000000000..16f4f04b9 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml @@ -0,0 +1,39 @@ + + + restful-ws-jakarta-integration-tests + io.cloudevents + 2.4.0-SNAPSHOT + ../ + + 4.0.0 + cloudevents-http-restful-ws-jakarta-integration-tests-common + CloudEvents - JAX-RS Jakarta Integration Tests - Common + jar + + + + io.cloudevents + cloudevents-http-restful-ws-ee9 + ${project.parent.version} + + + io.cloudevents + cloudevents-core + tests + test-jar + ${project.version} + + + + org.assertj + assertj-core + ${assertj-core.version} + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/BaseTest.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/BaseTest.java new file mode 100644 index 000000000..ea5cc7569 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/BaseTest.java @@ -0,0 +1,103 @@ +/* + * Copyright 2018-Present The CloudEvents Authors + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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); + } +} diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/TestResource.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/TestResource.java new file mode 100644 index 000000000..923a8572d --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/src/main/java/io/cloudevents/http/restful/ws/TestResource.java @@ -0,0 +1,67 @@ +/* + * Copyright 2018-Present The CloudEvents Authors + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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(); + } +} diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml new file mode 100644 index 000000000..595e1e3a5 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml @@ -0,0 +1,16 @@ + + + + restful-ws-jakarta-integration-tests + io.cloudevents + 2.4.0-SNAPSHOT + ../ + + 4.0.0 + + cloudevents-http-restful-ws-jakarta-integration-tests-microprofile + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml new file mode 100644 index 000000000..f29f7eaf4 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml @@ -0,0 +1,44 @@ + + + restful-ws-jakarta-integration-tests + io.cloudevents + 2.4.0-SNAPSHOT + + 4.0.0 + + cloudevents-http-restful-ws-jakarta-integration-tests-resteasy + CloudEvents - JAX-RS Jakarta Integration Tests - RESTEasy + jar + + + + 4.3.3 + 6.0.3.Final + + + + + + io.cloudevents + cloudevents-http-restful-ws-jakarta-integration-tests-common + ${project.version} + test + + + + io.vertx + vertx-core + ${vertx.version} + test + + + org.jboss.resteasy + resteasy-vertx + ${resteasy.version} + test + + + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java new file mode 100644 index 000000000..5cac8fdff --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java @@ -0,0 +1,62 @@ + +/* + * Copyright 2018-Present The CloudEvents Authors + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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(); + } + +} diff --git a/http/restful-ws-jakarta/pom.xml b/http/restful-ws-jakarta/pom.xml new file mode 100644 index 000000000..e09b36905 --- /dev/null +++ b/http/restful-ws-jakarta/pom.xml @@ -0,0 +1,96 @@ + + + + 4.0.0 + + io.cloudevents + cloudevents-parent + 2.4.0-SNAPSHOT + ../../pom.xml + + + cloudevents-http-restful-ws-ee9 + CloudEvents - Jakarta EE9 RESTful Web Services Http Binding + jar + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + default + + true + + + + + + 3.0.0 + 2.30.1 + 3.9.0 + 4.5.3.Final + io.cloudevents.http.restfulws + + + + + io.cloudevents + cloudevents-core + ${project.version} + + + jakarta.ws.rs + jakarta.ws.rs-api + ${jakarta-ee.version} + + + + + + + maven-antrun-plugin + 3.0.0 + + + generate-sources + + + + + + + + + + + + + + + run + + + + + + + + diff --git a/pom.xml b/pom.xml index 1071d3792..9644480af 100644 --- a/pom.xml +++ b/pom.xml @@ -74,10 +74,12 @@ http/basic http/vertx http/restful-ws + http/restful-ws-jakarta kafka spring sql bom + http/restful-ws-jakarta-integration-tests From 837ff896f51d5f92c1209374fad0ab414113fad6 Mon Sep 17 00:00:00 2001 From: alex-butcher <21243172+abutch3r@users.noreply.github.com> Date: Fri, 19 Aug 2022 11:18:24 +0100 Subject: [PATCH 14/19] update gitignore to cover all copied directories Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index dfd7df02e..9cc77463c 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,5 @@ _site/ # MacOS *.DS_Store -/http/restful-ws-jakarta/src/main/java/ +/http/restful-ws-jakarta/src/main/* + From 31e2b6c4bd4f977d63a7b7a21c0e56909cd2617b Mon Sep 17 00:00:00 2001 From: alex-butcher <21243172+abutch3r@users.noreply.github.com> Date: Mon, 12 Sep 2022 12:17:41 +0100 Subject: [PATCH 15/19] Update Jersey Version to support jakarta.* namespace packages Port jersey integration tests from javax.* to jakarta.* Includes port of jersey-junit to support jakarta as no current version exists that does. Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- .../pom.xml | 1 + .../restful-ws-jakarta-jersey/pom.xml | 68 ++++++++++ .../com/github/hanleyt/JerseyExtension.java | 128 ++++++++++++++++++ .../restful/ws/jakarta/jersey/TestJersey.java | 68 ++++++++++ http/restful-ws-jakarta/pom.xml | 2 +- 5 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java diff --git a/http/restful-ws-jakarta-integration-tests/pom.xml b/http/restful-ws-jakarta-integration-tests/pom.xml index 40f5288a7..ddc086b1c 100644 --- a/http/restful-ws-jakarta-integration-tests/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/pom.xml @@ -22,6 +22,7 @@ restful-ws-jakarta-common restful-ws-microprofile restful-ws-resteasy + restful-ws-jakarta-jersey diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml new file mode 100644 index 000000000..32a6d4881 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml @@ -0,0 +1,68 @@ + + + + + + restful-ws-jakarta-integration-tests + io.cloudevents + 2.4.0-SNAPSHOT + ../ + + 4.0.0 + + cloudevents-http-restful-ws-jakarta-integration-tests-jersey + CloudEvents - JAX-RS Integration Tests - Jersey + jar + + + 3.0.0 + + + + + + io.cloudevents + cloudevents-http-restful-ws-jakarta-integration-tests-common + ${project.version} + test + + + jakarta.ws.rs + jakarta.ws.rs-api + ${jakarta-ee.version} + + + org.glassfish.jersey.test-framework.providers + jersey-test-framework-provider-jetty + ${jersey.version} + + + org.glassfish.jersey.inject + jersey-hk2 + ${jersey.version} + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java new file mode 100644 index 000000000..b1453c87e --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java @@ -0,0 +1,128 @@ +/* + * Ported from https://github.com/hanleyt/jersey-junit as no version support Jesery versions >=3.0.0 + */ + +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> INJECTABLE_PARAMETER_TYPES = Arrays.asList(Client.class, WebTarget.class, URI.class); + + private final Function testContainerFactoryProvider; + private final Function deploymentContextProvider; + private final BiFunction configProvider; + + private JerseyExtension() { + throw new IllegalStateException("JerseyExtension must be registered programmatically"); + } + + public JerseyExtension(Supplier applicationSupplier) { + this((unused) -> applicationSupplier.get(), null); + } + + public JerseyExtension(Supplier applicationSupplier, + BiFunction configProvider) { + this((unused) -> applicationSupplier.get(), configProvider); + } + + public JerseyExtension(Function applicationProvider) { + this(applicationProvider, null); + } + + public JerseyExtension(Function applicationProvider, + BiFunction configProvider) { + this(null, (context) -> DeploymentContext.builder(applicationProvider.apply(context)).build(), configProvider); + } + + public JerseyExtension(Function testContainerFactoryProvider, + Function deploymentContextProvider, + BiFunction 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); + } + +} diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java new file mode 100644 index 000000000..fb54c3164 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java @@ -0,0 +1,68 @@ +/* + * Copyright 2018-Present The CloudEvents Authors + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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); + } + +} diff --git a/http/restful-ws-jakarta/pom.xml b/http/restful-ws-jakarta/pom.xml index e09b36905..97ee6caa7 100644 --- a/http/restful-ws-jakarta/pom.xml +++ b/http/restful-ws-jakarta/pom.xml @@ -42,7 +42,7 @@ 3.0.0 - 2.30.1 + 3.0.8 3.9.0 4.5.3.Final io.cloudevents.http.restfulws From b7d4d810754947feedbb01477754eaa839d88920 Mon Sep 17 00:00:00 2001 From: alex-butcher <21243172+abutch3r@users.noreply.github.com> Date: Mon, 12 Sep 2022 15:24:07 +0100 Subject: [PATCH 16/19] Undo changes to existing integration test package names fix file paths Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- .../http/restful/ws/{jakarta => }/jersey/TestJersey.java | 2 +- .../http/restful/ws/{jakarta => }/resteasy/TestResteasy.java | 2 +- http/restful-ws-jakarta-integration-tests/pom.xml | 2 +- .../{restful-ws-jakarta-jersey => restful-ws-jersey}/pom.xml | 1 + .../src/main/java/com/github/hanleyt/JerseyExtension.java | 0 .../cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java | 0 6 files changed, 4 insertions(+), 3 deletions(-) rename http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/{jakarta => }/jersey/TestJersey.java (97%) rename http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/{jakarta => }/resteasy/TestResteasy.java (97%) rename http/restful-ws-jakarta-integration-tests/{restful-ws-jakarta-jersey => restful-ws-jersey}/pom.xml (98%) rename http/restful-ws-jakarta-integration-tests/{restful-ws-jakarta-jersey => restful-ws-jersey}/src/main/java/com/github/hanleyt/JerseyExtension.java (100%) rename http/restful-ws-jakarta-integration-tests/{restful-ws-jakarta-jersey => restful-ws-jersey}/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java (100%) diff --git a/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java b/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jersey/TestJersey.java similarity index 97% rename from http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java rename to http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jersey/TestJersey.java index 772cc90b4..6c17e0505 100644 --- a/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java +++ b/http/restful-ws-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jersey/TestJersey.java @@ -15,7 +15,7 @@ * */ -package io.cloudevents.http.restful.ws.jakarta.jersey; +package io.cloudevents.http.restful.ws.jersey; import com.github.hanleyt.JerseyExtension; import io.cloudevents.core.mock.CSVFormat; diff --git a/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java b/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/resteasy/TestResteasy.java similarity index 97% rename from http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java rename to http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/resteasy/TestResteasy.java index 3bbcf02bb..cba075146 100644 --- a/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/jakarta/resteasy/TestResteasy.java +++ b/http/restful-ws-integration-tests/restful-ws-resteasy/src/test/java/io/cloudevents/http/restful/ws/resteasy/TestResteasy.java @@ -16,7 +16,7 @@ * */ -package io.cloudevents.http.restful.ws.jakarta.resteasy; +package io.cloudevents.http.restful.ws.resteasy; import io.cloudevents.core.mock.CSVFormat; import io.cloudevents.core.provider.EventFormatProvider; diff --git a/http/restful-ws-jakarta-integration-tests/pom.xml b/http/restful-ws-jakarta-integration-tests/pom.xml index ddc086b1c..5347893db 100644 --- a/http/restful-ws-jakarta-integration-tests/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/pom.xml @@ -22,7 +22,7 @@ restful-ws-jakarta-common restful-ws-microprofile restful-ws-resteasy - restful-ws-jakarta-jersey + restful-ws-jersey diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml similarity index 98% rename from http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml rename to http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml index 32a6d4881..2da17db2d 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml @@ -32,6 +32,7 @@ jar + 3.0.8 3.0.0 diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java similarity index 100% rename from http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java rename to http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java similarity index 100% rename from http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java rename to http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/test/java/io/cloudevents/http/restful/ws/jakarta/jersey/TestJersey.java From e0df55117dd366fe36aef7bc101d1ef8465ce20e Mon Sep 17 00:00:00 2001 From: alex-butcher <21243172+abutch3r@users.noreply.github.com> Date: Fri, 16 Sep 2022 16:09:00 +0100 Subject: [PATCH 17/19] Add Integration test for Microprofile/Liberty for Jee9 package Tidy-up pom files and filepaths Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- examples/pom.xml | 2 +- .../README.md | 2 +- .../pom.xml | 4 +- .../microprofile/CloudEventsApplication.java | 0 .../microprofile/CloudEventsJaxrsService.java | 0 .../src/main/liberty/config/server.xml | 0 .../pom.xml | 5 +- .../restful-ws-jakarta-common/pom.xml | 7 +- .../restful-ws-jersey/pom.xml | 8 +- .../com/github/hanleyt/JerseyExtension.java | 4 +- .../restful-ws-liberty/pom.xml | 164 ++++++++++++++++++ .../cloudevents/restful/mp/test/MpCEApp.java | 9 + .../restful/mp/test/TestResource.java | 60 +++++++ .../src/main/liberty/config/server.xml | 18 ++ .../microprofile/TestMicroprofile.java | 123 +++++++++++++ .../restful-ws-microprofile/pom.xml | 16 -- .../restful-ws-resteasy/pom.xml | 5 +- http/restful-ws-jakarta/pom.xml | 15 +- pom.xml | 2 +- 19 files changed, 405 insertions(+), 39 deletions(-) rename examples/{restful-ws-microprofile-ee9 => restful-ws-microprofile-liberty}/README.md (98%) rename examples/{restful-ws-microprofile-ee9 => restful-ws-microprofile-liberty}/pom.xml (98%) rename examples/{restful-ws-microprofile-ee9 => restful-ws-microprofile-liberty}/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java (100%) rename examples/{restful-ws-microprofile-ee9 => restful-ws-microprofile-liberty}/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java (100%) rename examples/{restful-ws-microprofile-ee9 => restful-ws-microprofile-liberty}/src/main/liberty/config/server.xml (100%) rename http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/{main => test}/java/com/github/hanleyt/JerseyExtension.java (97%) create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/MpCEApp.java create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/TestResource.java create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/liberty/config/server.xml create mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/test/java/io/cloudevents/http/restful/ws/jakarta/microprofile/TestMicroprofile.java delete mode 100644 http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml diff --git a/examples/pom.xml b/examples/pom.xml index d1955230a..a706a51e2 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -21,7 +21,7 @@ kafka restful-ws-quarkus - restful-ws-microprofile-ee9 + restful-ws-microprofile-liberty vertx basic-http restful-ws-spring-boot diff --git a/examples/restful-ws-microprofile-ee9/README.md b/examples/restful-ws-microprofile-liberty/README.md similarity index 98% rename from examples/restful-ws-microprofile-ee9/README.md rename to examples/restful-ws-microprofile-liberty/README.md index 6e6db680e..a5a320222 100644 --- a/examples/restful-ws-microprofile-ee9/README.md +++ b/examples/restful-ws-microprofile-liberty/README.md @@ -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 diff --git a/examples/restful-ws-microprofile-ee9/pom.xml b/examples/restful-ws-microprofile-liberty/pom.xml similarity index 98% rename from examples/restful-ws-microprofile-ee9/pom.xml rename to examples/restful-ws-microprofile-liberty/pom.xml index 9fb4cabe5..8a4338cd1 100644 --- a/examples/restful-ws-microprofile-ee9/pom.xml +++ b/examples/restful-ws-microprofile-liberty/pom.xml @@ -7,7 +7,7 @@ ../ 4.0.0 - cloudevents-restful-ws-microprofile-example + cloudevents-restful-ws-microprofile-liberty-example war @@ -44,7 +44,7 @@ io.cloudevents - cloudevents-http-restful-ws-ee9 + cloudevents-http-restful-ws-jakarta ${project.parent.version} diff --git a/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java b/examples/restful-ws-microprofile-liberty/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java similarity index 100% rename from examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java rename to examples/restful-ws-microprofile-liberty/src/main/java/io/cloudevents/examples/microprofile/CloudEventsApplication.java diff --git a/examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java b/examples/restful-ws-microprofile-liberty/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java similarity index 100% rename from examples/restful-ws-microprofile-ee9/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java rename to examples/restful-ws-microprofile-liberty/src/main/java/io/cloudevents/examples/microprofile/CloudEventsJaxrsService.java diff --git a/examples/restful-ws-microprofile-ee9/src/main/liberty/config/server.xml b/examples/restful-ws-microprofile-liberty/src/main/liberty/config/server.xml similarity index 100% rename from examples/restful-ws-microprofile-ee9/src/main/liberty/config/server.xml rename to examples/restful-ws-microprofile-liberty/src/main/liberty/config/server.xml diff --git a/http/restful-ws-jakarta-integration-tests/pom.xml b/http/restful-ws-jakarta-integration-tests/pom.xml index 5347893db..4d813060e 100644 --- a/http/restful-ws-jakarta-integration-tests/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/pom.xml @@ -10,7 +10,8 @@ 4.0.0 - restful-ws-jakarta-integration-tests + cloudevents-http-restful-ws-jakarta-integration-tests + CloudEvents - JAX-RS Jakarta EE9+ Web Http Binding Integration Tests pom @@ -20,9 +21,9 @@ restful-ws-jakarta-common - restful-ws-microprofile restful-ws-resteasy restful-ws-jersey + restful-ws-liberty diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml index 16f4f04b9..0845b89a2 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml @@ -1,20 +1,20 @@ - restful-ws-jakarta-integration-tests + cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents 2.4.0-SNAPSHOT ../ 4.0.0 cloudevents-http-restful-ws-jakarta-integration-tests-common - CloudEvents - JAX-RS Jakarta Integration Tests - Common + CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - Common jar io.cloudevents - cloudevents-http-restful-ws-ee9 + cloudevents-http-restful-ws-jakarta ${project.parent.version} @@ -24,7 +24,6 @@ test-jar ${project.version} - org.assertj assertj-core diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml index 2da17db2d..5480c4ae9 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml @@ -20,7 +20,7 @@ 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"> - restful-ws-jakarta-integration-tests + cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents 2.4.0-SNAPSHOT ../ @@ -28,7 +28,7 @@ 4.0.0 cloudevents-http-restful-ws-jakarta-integration-tests-jersey - CloudEvents - JAX-RS Integration Tests - Jersey + CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - Jersey jar @@ -48,21 +48,25 @@ jakarta.ws.rs jakarta.ws.rs-api ${jakarta-ee.version} + test org.glassfish.jersey.test-framework.providers jersey-test-framework-provider-jetty ${jersey.version} + test org.glassfish.jersey.inject jersey-hk2 ${jersey.version} + test org.junit.jupiter junit-jupiter-api ${junit-jupiter.version} + test diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/test/java/com/github/hanleyt/JerseyExtension.java similarity index 97% rename from http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java rename to http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/test/java/com/github/hanleyt/JerseyExtension.java index b1453c87e..066535c05 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/main/java/com/github/hanleyt/JerseyExtension.java +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/src/test/java/com/github/hanleyt/JerseyExtension.java @@ -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; diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml new file mode 100644 index 000000000..81d1098fa --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml @@ -0,0 +1,164 @@ + + + + cloudevents-http-restful-ws-jakarta-integration-tests + io.cloudevents + 2.4.0-SNAPSHOT + ../ + + 4.0.0 + + cloudevents-http-restful-ws-jakarta-integration-tests-microprofile + CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - Microprofile and Liberty + + + UTF-8 + UTF-8 + 1.8 + 1.8 + + 9080 + 9443 + + microprofile-test + + + + + + org.jboss.arquillian + arquillian-bom + 1.6.0.Final + pom + import + + + + + + + + jakarta.platform + jakarta.jakartaee-api + 9.1.0 + provided + + + org.eclipse.microprofile + microprofile + 5.0 + pom + provided + + + io.cloudevents + cloudevents-http-restful-ws-jakarta + ${project.version} + + + io.cloudevents + cloudevents-core + tests + test-jar + ${project.version} + + + org.jboss.resteasy + resteasy-client + 6.0.0.Final + test + + + org.jboss.resteasy + resteasy-json-binding-provider + 6.0.0.Final + test + + + org.glassfish + jakarta.json + 2.0.1 + test + + + + javax.xml.bind + jaxb-api + 2.3.1 + + + javax.activation + activation + 1.1.1 + + + io.openliberty.arquillian + arquillian-liberty-managed-jakarta-junit + 2.0.2 + pom + test + + + org.jboss.shrinkwrap + shrinkwrap-api + test + + + + + ${project.artifactId} + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + pom.xml + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.22.2 + + + ${arquillian.war.name}.war + + + + + test + + integration-test + + + + + + io.openliberty.tools + liberty-maven-plugin + 3.5.1 + + + + -Dsystem.context.root=/${arquillian.war.name} + + + + + + arquillian-configuration + generate-test-resources + + create + install-feature + configure-arquillian + + + + + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/MpCEApp.java b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/MpCEApp.java new file mode 100644 index 000000000..279cdb3e4 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/MpCEApp.java @@ -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 { + +} diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/TestResource.java b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/TestResource.java new file mode 100644 index 000000000..5a73efeb6 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/java/io/cloudevents/restful/mp/test/TestResource.java @@ -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(); + } +} diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/liberty/config/server.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/liberty/config/server.xml new file mode 100644 index 000000000..9725cb9c8 --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/main/liberty/config/server.xml @@ -0,0 +1,18 @@ + + + + microProfile-5.0 + + localConnector-1.0 + servlet-5.0 + + + + + + + + + + diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/test/java/io/cloudevents/http/restful/ws/jakarta/microprofile/TestMicroprofile.java b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/test/java/io/cloudevents/http/restful/ws/jakarta/microprofile/TestMicroprofile.java new file mode 100644 index 000000000..184fa2c8d --- /dev/null +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/src/test/java/io/cloudevents/http/restful/ws/jakarta/microprofile/TestMicroprofile.java @@ -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()); + } +} diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml deleted file mode 100644 index 595e1e3a5..000000000 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-microprofile/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - restful-ws-jakarta-integration-tests - io.cloudevents - 2.4.0-SNAPSHOT - ../ - - 4.0.0 - - cloudevents-http-restful-ws-jakarta-integration-tests-microprofile - - - diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml index f29f7eaf4..b4db4b968 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml @@ -1,14 +1,15 @@ - restful-ws-jakarta-integration-tests + cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents 2.4.0-SNAPSHOT + ../ 4.0.0 cloudevents-http-restful-ws-jakarta-integration-tests-resteasy - CloudEvents - JAX-RS Jakarta Integration Tests - RESTEasy + CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - RESTEasy jar diff --git a/http/restful-ws-jakarta/pom.xml b/http/restful-ws-jakarta/pom.xml index 97ee6caa7..b4909068f 100644 --- a/http/restful-ws-jakarta/pom.xml +++ b/http/restful-ws-jakarta/pom.xml @@ -25,8 +25,8 @@ ../../pom.xml - cloudevents-http-restful-ws-ee9 - CloudEvents - Jakarta EE9 RESTful Web Services Http Binding + cloudevents-http-restful-ws-jakarta + CloudEvents - Jakarta EE 9+ - Jakarta RESTful Web Services Http Binding jar @@ -43,8 +43,8 @@ 3.0.0 3.0.8 - 3.9.0 - 4.5.3.Final + 4.4.3 + 6.0.3.Final io.cloudevents.http.restfulws @@ -79,9 +79,10 @@ - + + + + diff --git a/pom.xml b/pom.xml index 9644480af..c959a6441 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,6 @@ spring sql bom - http/restful-ws-jakarta-integration-tests @@ -211,6 +210,7 @@ benchmarks http/restful-ws-integration-tests + http/restful-ws-jakarta-integration-tests examples From 455ccdd4258d261e9a74ec08550a819b286c4904 Mon Sep 17 00:00:00 2001 From: alex-butcher <21243172+abutch3r@users.noreply.github.com> Date: Tue, 20 Sep 2022 11:48:19 +0100 Subject: [PATCH 18/19] Add documentation for new Jakarta package Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- docs/http-jakarta-restful-ws-jakarta.md | 137 ++++++++++++++++++++++++ docs/http-jakarta-restful-ws.md | 4 +- docs/index.md | 8 +- http/restful-ws-jakarta/README.md | 7 ++ 4 files changed, 152 insertions(+), 4 deletions(-) create mode 100644 docs/http-jakarta-restful-ws-jakarta.md create mode 100644 http/restful-ws-jakarta/README.md diff --git a/docs/http-jakarta-restful-ws-jakarta.md b/docs/http-jakarta-restful-ws-jakarta.md new file mode 100644 index 000000000..e9f8c8280 --- /dev/null +++ b/docs/http-jakarta-restful-ws-jakarta.md @@ -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 + +[![Javadocs](https://www.javadoc.io/badge/io.cloudevents/cloudevents-http-restful-ws.svg?color=green)](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 + + io.cloudevents + cloudevents-http-restful-ws-jakarta + 2.5.0-SNAPSHOT + +``` + +This integration is tested with Jersey, 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) + diff --git a/docs/http-jakarta-restful-ws.md b/docs/http-jakarta-restful-ws.md index a7f08fefb..6cc179944 100644 --- a/docs/http-jakarta-restful-ws.md +++ b/docs/http-jakarta-restful-ws.md @@ -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 [![Javadocs](http://www.javadoc.io/badge/io.cloudevents/cloudevents-http-restful-ws.svg?color=green)](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 diff --git a/docs/index.md b/docs/index.md index ea4552f3a..07664c2ee 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 diff --git a/http/restful-ws-jakarta/README.md b/http/restful-ws-jakarta/README.md new file mode 100644 index 000000000..8f676ce2e --- /dev/null +++ b/http/restful-ws-jakarta/README.md @@ -0,0 +1,7 @@ +# HTTP Protocol Binding for Jakarta EE9+ - Jakarta RESTful Web Services + +Javadocs: [![Javadocs](http://www.javadoc.io/badge/io.cloudevents/cloudevents-http-restful-ws.svg?color=green)](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.` From 6500b848cf63499898cf08fa9e0018c338fe868b Mon Sep 17 00:00:00 2001 From: alex-butcher <21243172+abutch3r@users.noreply.github.com> Date: Wed, 21 Sep 2022 15:01:48 +0100 Subject: [PATCH 19/19] Update new package version to match new version Disable new Jakarta EE 9 + Jersey test case as requires builidng SDK version to be 11 or greater Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com> --- docs/http-jakarta-restful-ws-jakarta.md | 2 +- examples/restful-ws-microprofile-liberty/pom.xml | 2 +- http/restful-ws-jakarta-integration-tests/pom.xml | 7 ++++--- .../restful-ws-jakarta-common/pom.xml | 4 ++-- .../restful-ws-jersey/pom.xml | 2 +- .../restful-ws-liberty/pom.xml | 13 +++++-------- .../restful-ws-resteasy/pom.xml | 2 +- http/restful-ws-jakarta/pom.xml | 2 +- 8 files changed, 16 insertions(+), 18 deletions(-) diff --git a/docs/http-jakarta-restful-ws-jakarta.md b/docs/http-jakarta-restful-ws-jakarta.md index e9f8c8280..0eb4f43da 100644 --- a/docs/http-jakarta-restful-ws-jakarta.md +++ b/docs/http-jakarta-restful-ws-jakarta.md @@ -18,7 +18,7 @@ RESTful Web Services Binding for Jakarta EE 9+: ``` -This integration is tested with Jersey, RestEasy & Microprofile Liberty. +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. diff --git a/examples/restful-ws-microprofile-liberty/pom.xml b/examples/restful-ws-microprofile-liberty/pom.xml index 8a4338cd1..fa62353c0 100644 --- a/examples/restful-ws-microprofile-liberty/pom.xml +++ b/examples/restful-ws-microprofile-liberty/pom.xml @@ -3,7 +3,7 @@ cloudevents-examples io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 diff --git a/http/restful-ws-jakarta-integration-tests/pom.xml b/http/restful-ws-jakarta-integration-tests/pom.xml index 4d813060e..11e49266c 100644 --- a/http/restful-ws-jakarta-integration-tests/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/pom.xml @@ -5,8 +5,8 @@ cloudevents-parent io.cloudevents - 2.4.0-SNAPSHOT - ../ + 2.5.0-SNAPSHOT + ../../pom.xml 4.0.0 @@ -22,7 +22,8 @@ restful-ws-jakarta-common restful-ws-resteasy - restful-ws-jersey + + restful-ws-liberty diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml index 0845b89a2..d9d63d571 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jakarta-common/pom.xml @@ -3,7 +3,7 @@ cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 @@ -15,7 +15,7 @@ io.cloudevents cloudevents-http-restful-ws-jakarta - ${project.parent.version} + ${project.version} io.cloudevents diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml index 5480c4ae9..fdf8bd9f5 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-jersey/pom.xml @@ -22,7 +22,7 @@ cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml index 81d1098fa..1789438fb 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-liberty/pom.xml @@ -5,19 +5,16 @@ cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 cloudevents-http-restful-ws-jakarta-integration-tests-microprofile CloudEvents - JAX-RS Jakarta EE9+ Integration Tests - Microprofile and Liberty + war - UTF-8 - UTF-8 - 1.8 - 1.8 9080 9443 @@ -67,13 +64,13 @@ org.jboss.resteasy resteasy-client - 6.0.0.Final + 6.0.3.Final test org.jboss.resteasy resteasy-json-binding-provider - 6.0.0.Final + 6.0.3.Final test @@ -96,7 +93,7 @@ io.openliberty.arquillian arquillian-liberty-managed-jakarta-junit - 2.0.2 + 2.1.0 pom test diff --git a/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml index b4db4b968..08a87fa73 100644 --- a/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml +++ b/http/restful-ws-jakarta-integration-tests/restful-ws-resteasy/pom.xml @@ -3,7 +3,7 @@ cloudevents-http-restful-ws-jakarta-integration-tests io.cloudevents - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../ 4.0.0 diff --git a/http/restful-ws-jakarta/pom.xml b/http/restful-ws-jakarta/pom.xml index b4909068f..6d64b836c 100644 --- a/http/restful-ws-jakarta/pom.xml +++ b/http/restful-ws-jakarta/pom.xml @@ -21,7 +21,7 @@ io.cloudevents cloudevents-parent - 2.4.0-SNAPSHOT + 2.5.0-SNAPSHOT ../../pom.xml