From adb4f692d933d0a7ec701cf7d39e22ed77b6c77e Mon Sep 17 00:00:00 2001 From: Arne Limburg Date: Mon, 7 Jun 2021 15:26:15 +0200 Subject: [PATCH 1/7] Update versions --- customer-service/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/customer-service/pom.xml b/customer-service/pom.xml index 527ac51..87ec53a 100644 --- a/customer-service/pom.xml +++ b/customer-service/pom.xml @@ -11,11 +11,11 @@ war - 1.8 - 1.8 + 11 + 11 false UTF-8 - 1.2.9 + 1.2.11 From 99bcf6418b1e4547c25aeb803a4a01e60a2473fa Mon Sep 17 00:00:00 2001 From: Arne Limburg Date: Mon, 7 Jun 2021 15:55:48 +0200 Subject: [PATCH 2/7] Remove arquillian --- customer-service/pom.xml | 58 ++++--------------- .../application/CustomerResource.java | 2 + .../customer/application/JaxRsActivator.java | 2 + .../CustomerResourceIntegrationTest.java | 56 ++++-------------- 4 files changed, 25 insertions(+), 93 deletions(-) diff --git a/customer-service/pom.xml b/customer-service/pom.xml index 87ec53a..55516f4 100644 --- a/customer-service/pom.xml +++ b/customer-service/pom.xml @@ -18,18 +18,6 @@ 1.2.11 - - - - org.jboss.arquillian - arquillian-bom - 1.2.0.Final - import - pom - - - - @@ -47,9 +35,9 @@ - org.apache.tomee - javaee-api - 8.0-2 + org.apache.meecrowave + meecrowave-specs-api + ${meecrowave.version} provided @@ -69,47 +57,21 @@ 3.9 - junit - junit - 4.12 - test - - - org.assertj - assertj-core - 3.6.2 - test - - - org.jboss.arquillian.junit - arquillian-junit-container - test - - - org.jboss.shrinkwrap.resolver - shrinkwrap-resolver-impl-maven + org.junit.jupiter + junit-jupiter + 5.7.2 test org.apache.meecrowave - meecrowave-arquillian + meecrowave-junit ${meecrowave.version} test - org.jboss.shrinkwrap.resolver - shrinkwrap-resolver-impl-maven - test - - - org.jboss.shrinkwrap.descriptors - shrinkwrap-descriptors-impl-javaee - test - - - org.apache.meecrowave - meecrowave-arquillian - ${meecrowave.version} + org.assertj + assertj-core + 3.6.2 test diff --git a/customer-service/src/main/java/de/openknowledge/sample/customer/application/CustomerResource.java b/customer-service/src/main/java/de/openknowledge/sample/customer/application/CustomerResource.java index 031e7ab..17d2e3c 100644 --- a/customer-service/src/main/java/de/openknowledge/sample/customer/application/CustomerResource.java +++ b/customer-service/src/main/java/de/openknowledge/sample/customer/application/CustomerResource.java @@ -21,6 +21,7 @@ import java.util.logging.Logger; import java.util.stream.Collectors; +import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -50,6 +51,7 @@ * A resource that provides access to the {@link Customer} entity. */ @Path("customers") +@ApplicationScoped public class CustomerResource { private static final Logger LOG = Logger.getLogger(CustomerResource.class.getName()); diff --git a/customer-service/src/main/java/de/openknowledge/sample/customer/application/JaxRsActivator.java b/customer-service/src/main/java/de/openknowledge/sample/customer/application/JaxRsActivator.java index f4e1b64..339c214 100644 --- a/customer-service/src/main/java/de/openknowledge/sample/customer/application/JaxRsActivator.java +++ b/customer-service/src/main/java/de/openknowledge/sample/customer/application/JaxRsActivator.java @@ -15,6 +15,7 @@ */ package de.openknowledge.sample.customer.application; +import javax.enterprise.context.ApplicationScoped; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; @@ -31,6 +32,7 @@ * JAX-RS Activator */ @ApplicationPath("api") +@ApplicationScoped @OpenAPIDefinition(info = @Info( title = "Customer Service", contact = @Contact( diff --git a/customer-service/src/test/java/de/openknowledge/sample/customer/application/CustomerResourceIntegrationTest.java b/customer-service/src/test/java/de/openknowledge/sample/customer/application/CustomerResourceIntegrationTest.java index a853edd..7cfdec7 100644 --- a/customer-service/src/test/java/de/openknowledge/sample/customer/application/CustomerResourceIntegrationTest.java +++ b/customer-service/src/test/java/de/openknowledge/sample/customer/application/CustomerResourceIntegrationTest.java @@ -21,9 +21,7 @@ import java.io.InputStream; import java.io.StringReader; -import java.net.URL; import java.util.List; -import java.util.logging.Level; import java.util.logging.Logger; import javax.json.Json; @@ -35,59 +33,27 @@ import javax.ws.rs.core.Response.Status; import org.apache.johnzon.jaxrs.jsonb.jaxrs.JsonbJaxrsProvider; -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.asset.EmptyAsset; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.jboss.shrinkwrap.resolver.api.maven.Maven; -import org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import de.openknowledge.sample.customer.domain.Customer; -import de.openknowledge.sample.customer.domain.CustomerNotFoundException; -import de.openknowledge.sample.customer.domain.CustomerRepository; -import de.openknowledge.sample.customer.domain.Gender; -import de.openknowledge.sample.customer.domain.Name; -import de.openknowledge.sample.customer.domain.TestCustomers; +import org.apache.meecrowave.Meecrowave; +import org.apache.meecrowave.junit5.MonoMeecrowaveConfig; +import org.apache.meecrowave.testing.ConfigurationInject; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** - * Arquillian test class for the rest resource {@link CustomerResource}. + * test class for the rest resource {@link CustomerResource}. */ -@RunAsClient -@RunWith(Arquillian.class) +@MonoMeecrowaveConfig public class CustomerResourceIntegrationTest { - private static final Logger LOG = Logger.getLogger(CustomerResourceIntegrationTest.class.getName()); - - @Deployment - public static WebArchive createDeployment() { - PomEquippedResolveStage pomFile = Maven.resolver().loadPomFromFile("pom.xml"); - - WebArchive archive = ShrinkWrap.create(WebArchive.class) - .addAsLibraries(pomFile.resolve("org.apache.commons:commons-lang3").withTransitivity().asFile()) - .addClasses(CustomerResource.class, CustomerResourceType.class, JaxRsActivator.class) - .addClasses(Customer.class, Name.class, CustomerRepository.class, CustomerNotFoundException.class, Gender.class) - .addClass(TestCustomers.class) - .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); - - LOG.log(Level.FINE, () -> archive.toString(true)); - return archive; - } - - @ArquillianResource - private URL baseURI; + @ConfigurationInject + private Meecrowave.Builder config; private WebTarget customerListTarget; - @Before + @BeforeEach public void initializeClient() { customerListTarget = ClientBuilder.newClient() .register(JsonbJaxrsProvider.class) - .target(baseURI.toString()) + .target("http://localhost:" + config.getHttpPort()) .path("api/customers"); } From 9a44ffb169e0f93297ec5b90d705f80a51bc6bc4 Mon Sep 17 00:00:00 2001 From: Arne Limburg Date: Mon, 7 Jun 2021 19:20:40 +0200 Subject: [PATCH 3/7] Add README --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..5cd2f1d --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Api Versioning +Showcase to demonstrate the implementation of backward-compatible APIs and versioning + +Run +``` +cd customer-service +mvn package meecrowave:run +``` +to run the sample. +After the server is running, you can access the Swagger UI at +http://localhost:8080/index.html + +The sample was used during a webinar of open knowledge GmbH. +The recording (in german) can be found here: https://youtu.be/4y6VJOq9jSY From dfe51a21c9f761458f07f679cd9ec8bc53a73fda Mon Sep 17 00:00:00 2001 From: Arne Limburg Date: Mon, 7 Jun 2021 19:18:58 +0200 Subject: [PATCH 4/7] Add Dockerfile --- README.md | 12 ++++++++- customer-service/Dockerfile | 15 +++++++++++ customer-service/pom.xml | 26 +++++++++++++++++++ .../customer/application/JaxRsActivator.java | 2 ++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 customer-service/Dockerfile diff --git a/README.md b/README.md index 5cd2f1d..2ad141f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,22 @@ # Api Versioning Showcase to demonstrate the implementation of backward-compatible APIs and versioning +## Run via Docker Run ``` +docker build -t customer-service customer-service/ +docker run -p8080:8080 customer-service +``` +to build and run the sample. + +## Run without Docker +You need Apache Maven installed to run the sample without Docker. Run +``` cd customer-service mvn package meecrowave:run ``` -to run the sample. + +## Accessing the UI After the server is running, you can access the Swagger UI at http://localhost:8080/index.html diff --git a/customer-service/Dockerfile b/customer-service/Dockerfile new file mode 100644 index 0000000..9a115b3 --- /dev/null +++ b/customer-service/Dockerfile @@ -0,0 +1,15 @@ +FROM maven:3.6.3-jdk-11-openj9 AS mvn + +WORKDIR /usr/src/customer-service +COPY pom.xml ./ +RUN mvn package dependency:go-offline # cache dependencies +COPY src ./src +RUN mvn clean package + +FROM openjdk:11 + +EXPOSE 8080 +COPY --from=mvn /usr/src/customer-service/target/runner/meecrowave-core-runner.jar /opt/meecrowave-runner.jar +COPY --from=mvn /usr/src/customer-service/target/customer-service.war /opt/customer-service.war + +ENTRYPOINT ["java", "--illegal-access=permit", "-Djava.net.preferIPv4Stack=true", "-jar", "/opt/meecrowave-runner.jar", "--webapp", "/opt/customer-service.war"] diff --git a/customer-service/pom.xml b/customer-service/pom.xml index 55516f4..077dca0 100644 --- a/customer-service/pom.xml +++ b/customer-service/pom.xml @@ -19,6 +19,7 @@ + customer-service org.apache.maven.plugins @@ -30,6 +31,31 @@ meecrowave-maven-plugin ${meecrowave.version} + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-runner + package + + copy + + + + + org.apache.meecrowave + meecrowave-core + ${meecrowave.version} + runner + + + ${project.build.directory}/runner + true + + + + diff --git a/customer-service/src/main/java/de/openknowledge/sample/customer/application/JaxRsActivator.java b/customer-service/src/main/java/de/openknowledge/sample/customer/application/JaxRsActivator.java index 339c214..7b28934 100644 --- a/customer-service/src/main/java/de/openknowledge/sample/customer/application/JaxRsActivator.java +++ b/customer-service/src/main/java/de/openknowledge/sample/customer/application/JaxRsActivator.java @@ -27,6 +27,7 @@ import org.eclipse.microprofile.openapi.annotations.media.Content; import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody; +import org.eclipse.microprofile.openapi.annotations.servers.Server; /** * JAX-RS Activator @@ -44,6 +45,7 @@ url = "http://www.apache.org/licenses/LICENSE-2.0"), version = "1", description = "A customer service"), + servers = @Server(url = "http://localhost:8080/api"), components = @Components(requestBodies = @RequestBody(name = "Customer", content = @Content(schema = @Schema(implementation = CustomerResourceType.class))))) public class JaxRsActivator extends Application { From cf686a2c5aab21bdf77c5004dcee37ddf1d57c71 Mon Sep 17 00:00:00 2001 From: Arne Limburg Date: Tue, 8 Jun 2021 08:38:38 +0200 Subject: [PATCH 5/7] Skip tests during build --- customer-service/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/customer-service/Dockerfile b/customer-service/Dockerfile index 9a115b3..fb066b9 100644 --- a/customer-service/Dockerfile +++ b/customer-service/Dockerfile @@ -4,7 +4,7 @@ WORKDIR /usr/src/customer-service COPY pom.xml ./ RUN mvn package dependency:go-offline # cache dependencies COPY src ./src -RUN mvn clean package +RUN mvn clean package -DskipTests FROM openjdk:11 From fdd06928e4988bd6d8e04355fc3ea3579dd388f9 Mon Sep 17 00:00:00 2001 From: Arne Limburg Date: Wed, 20 May 2020 16:02:37 +0200 Subject: [PATCH 6/7] Create Readme.md --- README.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/README.md b/README.md index 2ad141f..5cd2f1d 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,12 @@ # Api Versioning Showcase to demonstrate the implementation of backward-compatible APIs and versioning -## Run via Docker Run ``` -docker build -t customer-service customer-service/ -docker run -p8080:8080 customer-service -``` -to build and run the sample. - -## Run without Docker -You need Apache Maven installed to run the sample without Docker. Run -``` cd customer-service mvn package meecrowave:run ``` - -## Accessing the UI +to run the sample. After the server is running, you can access the Swagger UI at http://localhost:8080/index.html From c5ec76189d67e80435491af39d809f2b70c7b456 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Nov 2022 07:19:59 +0000 Subject: [PATCH 7/7] Bump jackson-databind from 2.10.0 to 2.12.7.1 in /customer-service Bumps [jackson-databind](https://github.com/FasterXML/jackson) from 2.10.0 to 2.12.7.1. - [Release notes](https://github.com/FasterXML/jackson/releases) - [Commits](https://github.com/FasterXML/jackson/commits) --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- customer-service/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/customer-service/pom.xml b/customer-service/pom.xml index b4f756f..5bf8be7 100644 --- a/customer-service/pom.xml +++ b/customer-service/pom.xml @@ -120,7 +120,7 @@ com.fasterxml.jackson.core jackson-databind - 2.10.0 + 2.12.7.1 runtime