Test Jax-rs integration with Resteasy & Spring Jersey (#152)
* Added test for resteasy Signed-off-by: Francesco Guardiani <francescoguard@gmail.com> * resteasy and jersey now don't conflict each other anymore Signed-off-by: Francesco Guardiani <francescoguard@gmail.com> * Small nits Signed-off-by: Francesco Guardiani <francescoguard@gmail.com> * Removed pom piece not needed Signed-off-by: Francesco Guardiani <francescoguard@gmail.com> * Little mistake Signed-off-by: Francesco Guardiani <francescoguard@gmail.com> * Trying to test spring Signed-off-by: Francesco Guardiani <francescoguard@gmail.com> * Fix spring package version mismatch Also updated calls from junit4 to junit5 Signed-off-by: Matej Vasek <mvasek@redhat.com> * Fix assertions in test Signed-off-by: Matej Vasek <mvasek@redhat.com> * Split restful-ws tests to sub-modules Managing test for multiple jax-rs implemetations using exclusions is not practical. Signed-off-by: Matej Vasek <mvasek@redhat.com> * Implement simpler solution Signed-off-by: Matej Vasek <mvasek@redhat.com> * Add exclusions for junit4 We are using junit5 Signed-off-by: Matej Vasek <mvasek@redhat.com> * Add name to integration test artifacts Signed-off-by: Matej Vasek <mvasek@redhat.com> * Add exclusions from deploy Signed-off-by: Matej Vasek <mvasek@redhat.com> * Update README.md Signed-off-by: Matej Vasek <mvasek@redhat.com> * Remove unused property Signed-off-by: Matej Vasek <mvasek@redhat.com> * Add copyright headers Signed-off-by: Matej Vasek <mvasek@redhat.com> * Rename property Signed-off-by: Matej Vasek <mvasek@redhat.com> Co-authored-by: slinkydeveloper <francescoguard@gmail.com>
This commit is contained in:
parent
199f8c02e0
commit
2ff79c06b6
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2018-Present The CloudEvents Authors
|
||||
~ <p>
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~ <p>
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~ <p>
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>cloudevents-parent</artifactId>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cloudevents-http-restful-ws-integration-tests</artifactId>
|
||||
<name>CloudEvents - JAX-RS Web Http Binding Integration Tests</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>restful-ws-common</module>
|
||||
<module>restful-ws-spring</module>
|
||||
<module>restful-ws-jersey</module>
|
||||
<module>restful-ws-resteasy</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- This is just a test package, there is no need to publish it -->
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2018-Present The CloudEvents Authors
|
||||
~ <p>
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~ <p>
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~ <p>
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>cloudevents-http-restful-ws-integration-tests</artifactId>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cloudevents-http-restful-ws-integration-tests-common</artifactId>
|
||||
<name>CloudEvents - JAX-RS Integration Tests - Common</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<artifactId>cloudevents-http-restful-ws</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<artifactId>cloudevents-api</artifactId>
|
||||
<classifier>tests</classifier>
|
||||
<type>test-jar</type>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj-core.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- This is just a test package, there is no need to publish it -->
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -15,54 +15,29 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package io.cloudevents.http.restful.ws.jersey;
|
||||
package io.cloudevents.http.restful.ws;
|
||||
|
||||
import com.github.hanleyt.JerseyExtension;
|
||||
import io.cloudevents.CloudEvent;
|
||||
import io.cloudevents.format.EventFormatProvider;
|
||||
import io.cloudevents.http.restful.ws.CloudEventsProvider;
|
||||
import io.cloudevents.http.restful.ws.TestResource;
|
||||
import io.cloudevents.mock.CSVFormat;
|
||||
import io.cloudevents.test.Data;
|
||||
import org.glassfish.jersey.client.ClientConfig;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.Application;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestServerJersey {
|
||||
public abstract class BaseTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
EventFormatProvider.getInstance().registerFormat(CSVFormat.INSTANCE);
|
||||
}
|
||||
|
||||
@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) {
|
||||
clientConfig.register(CloudEventsProvider.class);
|
||||
return clientConfig;
|
||||
}
|
||||
protected abstract WebTarget getWebTarget();
|
||||
|
||||
@Test
|
||||
void getMinEvent(WebTarget target) {
|
||||
Response res = target.path("getMinEvent").request().buildGet().invoke();
|
||||
void getMinEvent() {
|
||||
Response res = getWebTarget().path("getMinEvent").request().buildGet().invoke();
|
||||
|
||||
assertThat(res.getHeaderString("ce-specversion"))
|
||||
.isEqualTo("1.0");
|
||||
|
@ -73,8 +48,8 @@ public class TestServerJersey {
|
|||
}
|
||||
|
||||
@Test
|
||||
void getStructuredEvent(WebTarget target) {
|
||||
Response res = target.path("getStructuredEvent").request().buildGet().invoke();
|
||||
void getStructuredEvent() {
|
||||
Response res = getWebTarget().path("getStructuredEvent").request().buildGet().invoke();
|
||||
|
||||
CloudEvent outEvent = res.readEntity(CloudEvent.class);
|
||||
assertThat(outEvent)
|
||||
|
@ -84,8 +59,8 @@ public class TestServerJersey {
|
|||
}
|
||||
|
||||
@Test
|
||||
void getEvent(WebTarget target) {
|
||||
Response res = target.path("getEvent").request().buildGet().invoke();
|
||||
void getEvent() {
|
||||
Response res = getWebTarget().path("getEvent").request().buildGet().invoke();
|
||||
|
||||
CloudEvent outEvent = res.readEntity(CloudEvent.class);
|
||||
assertThat(outEvent)
|
||||
|
@ -93,8 +68,8 @@ public class TestServerJersey {
|
|||
}
|
||||
|
||||
@Test
|
||||
void postEventWithoutBody(WebTarget target) {
|
||||
Response res = target
|
||||
void postEventWithoutBody() {
|
||||
Response res = getWebTarget()
|
||||
.path("postEventWithoutBody")
|
||||
.request()
|
||||
.buildPost(Entity.entity(Data.V1_MIN, CloudEventsProvider.CLOUDEVENT_TYPE))
|
||||
|
@ -105,8 +80,8 @@ public class TestServerJersey {
|
|||
}
|
||||
|
||||
@Test
|
||||
void postEventStructured(WebTarget target) {
|
||||
Response res = target
|
||||
void postEventStructured() {
|
||||
Response res = getWebTarget()
|
||||
.path("postEventWithoutBody")
|
||||
.request()
|
||||
.buildPost(Entity.entity(Data.V1_MIN, "application/cloudevents+csv"))
|
||||
|
@ -117,8 +92,8 @@ public class TestServerJersey {
|
|||
}
|
||||
|
||||
@Test
|
||||
void postEvent(WebTarget target) {
|
||||
Response res = target
|
||||
void postEvent() {
|
||||
Response res = getWebTarget()
|
||||
.path("postEvent")
|
||||
.request()
|
||||
.buildPost(Entity.entity(Data.V1_WITH_JSON_DATA_WITH_EXT_STRING, CloudEventsProvider.CLOUDEVENT_TYPE))
|
||||
|
@ -127,6 +102,4 @@ public class TestServerJersey {
|
|||
assertThat(res.getStatus())
|
||||
.isEqualTo(200);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2018-Present The CloudEvents Authors
|
||||
~ <p>
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~ <p>
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~ <p>
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>cloudevents-http-restful-ws-integration-tests</artifactId>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cloudevents-http-restful-ws-integration-tests-jersey</artifactId>
|
||||
<name>CloudEvents - JAX-RS Integration Tests - Jersey</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<jersey.version>2.30.1</jersey.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<artifactId>cloudevents-http-restful-ws-integration-tests-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
|
||||
<artifactId>jersey-test-framework-provider-jetty</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.inject</groupId>
|
||||
<artifactId>jersey-hk2</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.hanleyt</groupId>
|
||||
<artifactId>jersey-junit</artifactId>
|
||||
<version>2.1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- This is just a test package, there is no need to publish it -->
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright 2018-Present The CloudEvents Authors
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package io.cloudevents.http.restful.ws.jersey;
|
||||
|
||||
import com.github.hanleyt.JerseyExtension;
|
||||
import io.cloudevents.format.EventFormatProvider;
|
||||
import io.cloudevents.http.restful.ws.BaseTest;
|
||||
import io.cloudevents.http.restful.ws.CloudEventsProvider;
|
||||
import io.cloudevents.http.restful.ws.TestResource;
|
||||
import io.cloudevents.mock.CSVFormat;
|
||||
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 javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.Application;
|
||||
|
||||
public class TestJersey extends BaseTest {
|
||||
|
||||
private WebTarget target;
|
||||
|
||||
@Override
|
||||
protected WebTarget getWebTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
EventFormatProvider.getInstance().registerFormat(CSVFormat.INSTANCE);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach(WebTarget target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@RegisterExtension
|
||||
JerseyExtension jerseyExtension = new JerseyExtension(this::configureJersey, this::configureJerseyClient);
|
||||
|
||||
private Application configureJersey() {
|
||||
return new ResourceConfig(TestResource.class)
|
||||
.register(CloudEventsProvider.class);
|
||||
}
|
||||
|
||||
private ClientConfig configureJerseyClient(ExtensionContext extensionContext, ClientConfig clientConfig) {
|
||||
return clientConfig
|
||||
.register(CloudEventsProvider.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2018-Present The CloudEvents Authors
|
||||
~ <p>
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~ <p>
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~ <p>
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>cloudevents-http-restful-ws-integration-tests</artifactId>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cloudevents-http-restful-ws-integration-tests-resteasy</artifactId>
|
||||
<name>CloudEvents - JAX-RS Integration Tests - RESTEasy</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<vertx.version>3.9.0</vertx.version>
|
||||
<resteasy.version>4.5.3.Final</resteasy.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<artifactId>cloudevents-http-restful-ws-integration-tests-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-core</artifactId>
|
||||
<version>${vertx.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-vertx</artifactId>
|
||||
<version>${resteasy.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- This is just a test package, there is no need to publish it -->
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,65 @@
|
|||
|
||||
/*
|
||||
* Copyright 2018-Present The CloudEvents Authors
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package io.cloudevents.http.restful.ws.resteasy;
|
||||
|
||||
import io.cloudevents.format.EventFormatProvider;
|
||||
import io.cloudevents.http.restful.ws.BaseTest;
|
||||
import io.cloudevents.http.restful.ws.CloudEventsProvider;
|
||||
import io.cloudevents.http.restful.ws.TestResource;
|
||||
import io.cloudevents.mock.CSVFormat;
|
||||
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 org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestResteasy extends BaseTest {
|
||||
|
||||
private static VertxResteasyDeployment resteasyDeployment;
|
||||
private static WebTarget target;
|
||||
|
||||
@Override
|
||||
protected WebTarget getWebTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeClass() throws Exception {
|
||||
EventFormatProvider.getInstance().registerFormat(CSVFormat.INSTANCE);
|
||||
|
||||
String base = TestPortProvider.generateBaseUrl();
|
||||
TestResteasy.resteasyDeployment = VertxContainer.start(base);
|
||||
TestResteasy.resteasyDeployment.getProviderFactory().register(CloudEventsProvider.class);
|
||||
TestResteasy.resteasyDeployment.getRegistry().addPerRequestResource(TestResource.class);
|
||||
|
||||
TestResteasy.target = ClientBuilder.newClient().register(CloudEventsProvider.class).target(base);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void after() throws Exception {
|
||||
TestResteasy.resteasyDeployment.stop();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2018-Present The CloudEvents Authors
|
||||
~ <p>
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~ <p>
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~ <p>
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>cloudevents-http-restful-ws-integration-tests</artifactId>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cloudevents-http-restful-ws-integration-tests-spring</artifactId>
|
||||
<name>CloudEvents - JAX-RS Integration Tests - Spring</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<spring-boot.version>2.3.0.RELEASE</spring-boot.version>
|
||||
<spring.version>5.2.6.RELEASE</spring.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-framework-bom</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<artifactId>cloudevents-http-restful-ws-integration-tests-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jersey</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- This is just a test package, there is no need to publish it -->
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2018-Present The CloudEvents Authors
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package io.cloudevents.http.restful.ws.spring;
|
||||
|
||||
import io.cloudevents.http.restful.ws.CloudEventsProvider;
|
||||
import io.cloudevents.http.restful.ws.TestResource;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.ws.rs.ApplicationPath;
|
||||
|
||||
@Configuration
|
||||
public class JerseyConfig extends ResourceConfig {
|
||||
public JerseyConfig() {
|
||||
registerClasses(CloudEventsProvider.class, TestResource.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright 2018-Present The CloudEvents Authors
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package io.cloudevents.http.restful.ws.spring;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = {"io.cloudevents.http.restful.ws.spring"})
|
||||
public class TestApplication extends SpringBootServletInitializer {
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright 2018-Present The CloudEvents Authors
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package io.cloudevents.http.restful.ws.spring;
|
||||
|
||||
import io.cloudevents.format.EventFormatProvider;
|
||||
import io.cloudevents.http.restful.ws.BaseTest;
|
||||
import io.cloudevents.http.restful.ws.CloudEventsProvider;
|
||||
import io.cloudevents.mock.CSVFormat;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import java.net.URI;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class TestSpringBootWithJersey extends BaseTest {
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
private WebTarget target;
|
||||
|
||||
@Override
|
||||
protected WebTarget getWebTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
target = ClientBuilder.newClient().register(CloudEventsProvider.class).target(URI.create("http://localhost:" + this.port + "/"));
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeAll() {
|
||||
EventFormatProvider.getInstance().registerFormat(CSVFormat.INSTANCE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
|
@ -10,6 +10,8 @@ For Maven based projects, use the following to configure the CloudEvents Jakarta
|
|||
</dependency>
|
||||
```
|
||||
|
||||
This integration is tested with Jersey, RestEasy & Spring Boot Jersey.
|
||||
|
||||
## Receiving CloudEvents
|
||||
|
||||
You need to configure the `CloudEventsProvider` to enable marshalling/unmarshalling of CloudEvents.
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<artifactId>cloudevents-parent</artifactId>
|
||||
|
@ -33,7 +32,6 @@
|
|||
<properties>
|
||||
<jakarta-ee.version>2.1.6</jakarta-ee.version>
|
||||
<jersey.version>2.30.1</jersey.version>
|
||||
<assertj-core.version>3.11.0</assertj-core.version>
|
||||
<vertx.version>3.9.0</vertx.version>
|
||||
<resteasy.version>4.5.3.Final</resteasy.version>
|
||||
</properties>
|
||||
|
@ -50,48 +48,6 @@
|
|||
<version>${jakarta-ee.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Test deps -->
|
||||
<dependency>
|
||||
<groupId>io.cloudevents</groupId>
|
||||
<artifactId>cloudevents-api</artifactId>
|
||||
<classifier>tests</classifier>
|
||||
<type>test-jar</type>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj-core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Jersey -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
|
||||
<artifactId>jersey-test-framework-provider-jetty</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.inject</groupId>
|
||||
<artifactId>jersey-hk2</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.hanleyt</groupId>
|
||||
<artifactId>jersey-junit</artifactId>
|
||||
<version>2.1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#
|
||||
# Copyright 2018-Present The CloudEvents Authors
|
||||
# <p>
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# <p>
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# <p>
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
io.cloudevents.http.restful.ws.CloudEventsProvider
|
|
@ -1 +1,17 @@
|
|||
#
|
||||
# Copyright 2018-Present The CloudEvents Authors
|
||||
# <p>
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# <p>
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# <p>
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
io.cloudevents.http.restful.ws.CloudEventsProvider
|
||||
|
|
|
@ -1 +1,17 @@
|
|||
#
|
||||
# Copyright 2018-Present The CloudEvents Authors
|
||||
# <p>
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# <p>
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# <p>
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
io.cloudevents.http.restful.ws.CloudEventsProvider
|
||||
|
|
Loading…
Reference in New Issue