From 7c9fecef53c498e44dfde55e83ec2398c8401bc2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Nov 2023 07:51:52 +0000 Subject: [PATCH 1/5] chore(deps): Bump org.springframework.boot from 3.1.5 to 3.2.0 Bumps [org.springframework.boot](https://github.com/spring-projects/spring-boot) from 3.1.5 to 3.2.0. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.1.5...v3.2.0) --- updated-dependencies: - dependency-name: org.springframework.boot dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e80d66b13..aa1e3eafa 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { plugins { id 'ca.cutterslade.analyze' version '1.9.1' id 'io.spring.dependency-management' version '1.1.4' apply false - id 'org.springframework.boot' version '3.1.5' apply false + id 'org.springframework.boot' version '3.2.0' apply false id 'org.owasp.dependencycheck' version '8.4.3' id 'com.diffplug.spotless' version '6.22.0' id 'com.bmuschko.docker-spring-boot-application' version '9.3.7' apply false From 1e515b6ff9417ad067aa71c445a92ecaa89eb783 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Fri, 24 Nov 2023 09:53:03 +0100 Subject: [PATCH 2/5] chore: Add SSLBundle to required buildProperties method call --- .../springwolf/example/amqp/ApiSystemTest.java | 3 +-- .../cloudstream/ApiIntegrationTest.java | 15 ++++++--------- .../example/cloudstream/ApiSystemTest.java | 3 +-- .../example/kafka/ApiIntegrationTest.java | 18 ++++++------------ ...IntegrationWithActuatorIntegrationTest.java | 18 ++++++++---------- .../example/kafka/ApiSystemTest.java | 3 +-- .../example/kafka/ProducerSystemTest.java | 3 ++- .../example/sns/ApiIntegrationTest.java | 3 +-- .../springwolf/example/sns/ApiSystemTest.java | 3 +-- .../example/sqs/ApiIntegrationTest.java | 7 +------ .../springwolf/example/sqs/ApiSystemTest.java | 3 +-- .../SpringwolfKafkaTemplateFactory.java | 3 ++- .../SpringwolfKafkaTemplateFactoryTest.java | 4 +++- 13 files changed, 34 insertions(+), 52 deletions(-) diff --git a/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/amqp/ApiSystemTest.java b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/amqp/ApiSystemTest.java index 2a9679e32..2a1f25cdf 100644 --- a/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/amqp/ApiSystemTest.java +++ b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/amqp/ApiSystemTest.java @@ -1,7 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.example.amqp; -import org.json.JSONException; import org.junit.jupiter.api.Test; import org.springframework.web.client.RestTemplate; import org.testcontainers.containers.DockerComposeContainer; @@ -55,7 +54,7 @@ private String baseUrl() { } @Test - void asyncapiDocsShouldReturnTheCorrectJsonResponse() throws IOException, JSONException { + void asyncapiDocsShouldReturnTheCorrectJsonResponse() throws IOException { String url = baseUrl() + "/springwolf/docs"; String actual = restTemplate.getForObject(url, String.class); diff --git a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/cloudstream/ApiIntegrationTest.java b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/cloudstream/ApiIntegrationTest.java index 7102b2e11..7dddbeadf 100644 --- a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/cloudstream/ApiIntegrationTest.java +++ b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/cloudstream/ApiIntegrationTest.java @@ -1,7 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.example.cloudstream; -import org.json.JSONException; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -21,28 +20,26 @@ @SpringBootTest( classes = {SpringwolfCloudstreamExampleApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@EmbeddedKafka( - partitions = 1, - brokerProperties = {"listeners=PLAINTEXT://localhost:29092", "port=29092"}) +@EmbeddedKafka(partitions = 1) @DirtiesContext public class ApiIntegrationTest { @Autowired private TestRestTemplate restTemplate; - @Value("${server.port}") - public Integer serverPort; + @Value("${spring.kafka.bootstrap-servers}") + public String bootstrapServers; @Test - void asyncApiResourceArtifactTest() throws JSONException, IOException { + void asyncApiResourceArtifactTest() throws IOException { String url = "/springwolf/docs"; String actual = restTemplate.getForObject(url, String.class); Files.writeString(Path.of("src", "test", "resources", "asyncapi.actual.json"), actual); InputStream s = this.getClass().getResourceAsStream("/asyncapi.json"); String expectedWithoutServersKafkaUrlPatch = new String(s.readAllBytes(), StandardCharsets.UTF_8); - // When running with EmbeddedKafka, localhost is used as hostname - String expected = expectedWithoutServersKafkaUrlPatch.replace("kafka:29092", "127.0.0.1:29092"); + // When running with EmbeddedKafka, the kafka bootstrap server does run on random ports + String expected = expectedWithoutServersKafkaUrlPatch.replace("kafka:29092", bootstrapServers); assertEquals(expected, actual); } diff --git a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/cloudstream/ApiSystemTest.java b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/cloudstream/ApiSystemTest.java index 68b517625..a8c741984 100644 --- a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/cloudstream/ApiSystemTest.java +++ b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/cloudstream/ApiSystemTest.java @@ -1,7 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.example.cloudstream; -import org.json.JSONException; import org.junit.jupiter.api.Test; import org.springframework.web.client.RestTemplate; import org.testcontainers.containers.DockerComposeContainer; @@ -55,7 +54,7 @@ private String baseUrl() { } @Test - void asyncapiDocsShouldReturnTheCorrectJsonResponse() throws IOException, JSONException { + void asyncapiDocsShouldReturnTheCorrectJsonResponse() throws IOException { String url = baseUrl() + "/springwolf/docs"; String actual = restTemplate.getForObject(url, String.class); diff --git a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiIntegrationTest.java b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiIntegrationTest.java index 83df8ab7a..f11f309b0 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiIntegrationTest.java +++ b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiIntegrationTest.java @@ -1,7 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.example.kafka; -import org.json.JSONException; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -21,31 +20,26 @@ @SpringBootTest( classes = {SpringwolfKafkaExampleApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@EmbeddedKafka( - partitions = 1, - brokerProperties = { - "listeners=PLAINTEXT://localhost:9092", - "port=9092", - }) +@EmbeddedKafka(partitions = 1) @DirtiesContext public class ApiIntegrationTest { @Autowired private TestRestTemplate restTemplate; - @Value("${server.port}") - public Integer serverPort; + @Value("${spring.kafka.bootstrap-servers}") + public String bootstrapServers; @Test - void asyncApiResourceArtifactTest() throws JSONException, IOException { + void asyncApiResourceArtifactTest() throws IOException { String url = "/springwolf/docs"; String actual = restTemplate.getForObject(url, String.class); Files.writeString(Path.of("src", "test", "resources", "asyncapi.actual.json"), actual); InputStream s = this.getClass().getResourceAsStream("/asyncapi.json"); String expectedWithoutServersKafkaUrlPatch = new String(s.readAllBytes(), StandardCharsets.UTF_8); - // When running with EmbeddedKafka, localhost is used as hostname - String expected = expectedWithoutServersKafkaUrlPatch.replace("kafka:29092", "127.0.0.1:9092"); + // When running with EmbeddedKafka, the kafka bootstrap server does run on random ports + String expected = expectedWithoutServersKafkaUrlPatch.replace("kafka:29092", bootstrapServers); assertEquals(expected, actual); } diff --git a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiIntegrationWithActuatorIntegrationTest.java b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiIntegrationWithActuatorIntegrationTest.java index e3092aba2..0bae6f7ff 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiIntegrationWithActuatorIntegrationTest.java +++ b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiIntegrationWithActuatorIntegrationTest.java @@ -1,9 +1,9 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.example.kafka; -import org.json.JSONException; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.server.LocalServerPort; @@ -23,12 +23,7 @@ "springwolf.endpoint.actuator.enabled=true", "management.endpoints.web.exposure.include=springwolf" }) -@EmbeddedKafka( - partitions = 1, - brokerProperties = { - "listeners=PLAINTEXT://localhost:9092", - "port=9092", - }) +@EmbeddedKafka(partitions = 1) @DirtiesContext public class ApiIntegrationWithActuatorIntegrationTest { @@ -38,15 +33,18 @@ public class ApiIntegrationWithActuatorIntegrationTest { @LocalServerPort private int managementPort; + @Value("${spring.kafka.bootstrap-servers}") + public String bootstrapServers; + @Test - void asyncApiResourceArtifactTest() throws JSONException, IOException { + void asyncApiResourceArtifactTest() throws IOException { String url = "http://localhost:" + managementPort + "/actuator/springwolf/docs"; String actual = restTemplate.getForObject(url, String.class); InputStream s = this.getClass().getResourceAsStream("/asyncapi.json"); String expectedWithoutServersKafkaUrlPatch = new String(s.readAllBytes(), StandardCharsets.UTF_8); - // When running with EmbeddedKafka, localhost is used as hostname - String expected = expectedWithoutServersKafkaUrlPatch.replace("kafka:29092", "127.0.0.1:9092"); + // When running with EmbeddedKafka, the kafka bootstrap server does run on random ports + String expected = expectedWithoutServersKafkaUrlPatch.replace("kafka:29092", bootstrapServers); assertEquals(expected, actual); } diff --git a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiSystemTest.java b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiSystemTest.java index e66d10cc6..fc6a6b127 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiSystemTest.java +++ b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiSystemTest.java @@ -1,7 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.example.kafka; -import org.json.JSONException; import org.junit.jupiter.api.Test; import org.springframework.web.client.RestTemplate; import org.testcontainers.containers.DockerComposeContainer; @@ -55,7 +54,7 @@ private String baseUrl() { } @Test - void asyncapiDocsShouldReturnTheCorrectJsonResponse() throws IOException, JSONException { + void asyncapiDocsShouldReturnTheCorrectJsonResponse() throws IOException { String url = baseUrl() + "/springwolf/docs"; String actual = restTemplate.getForObject(url, String.class); diff --git a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ProducerSystemTest.java b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ProducerSystemTest.java index b7ae9ff4d..6a2bf7cd2 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ProducerSystemTest.java +++ b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ProducerSystemTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ssl.DefaultSslBundleRegistry; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.test.annotation.DirtiesContext; @@ -60,7 +61,7 @@ public class ProducerSystemTest { @Order(1) void verifyKafkaIsAvailable() { Map consumerProperties = - properties.getPublishing().getProducer().buildProperties(); + properties.getPublishing().getProducer().buildProperties(new DefaultSslBundleRegistry()); AdminClient adminClient = KafkaAdminClient.create(consumerProperties); await().atMost(60, SECONDS) .untilAsserted( diff --git a/springwolf-examples/springwolf-sns-example/src/test/java/io/github/stavshamir/springwolf/example/sns/ApiIntegrationTest.java b/springwolf-examples/springwolf-sns-example/src/test/java/io/github/stavshamir/springwolf/example/sns/ApiIntegrationTest.java index b3bc3eb12..345d5e8f3 100644 --- a/springwolf-examples/springwolf-sns-example/src/test/java/io/github/stavshamir/springwolf/example/sns/ApiIntegrationTest.java +++ b/springwolf-examples/springwolf-sns-example/src/test/java/io/github/stavshamir/springwolf/example/sns/ApiIntegrationTest.java @@ -1,7 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.example.sns; -import org.json.JSONException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; @@ -37,7 +36,7 @@ static void setUpTestContainers(DynamicPropertyRegistry registry) { public Integer serverPort; @Test - void asyncApiResourceArtifactTest() throws JSONException, IOException { + void asyncApiResourceArtifactTest() throws IOException { String url = "/springwolf/docs"; String actual = restTemplate.getForObject(url, String.class); Files.writeString(Path.of("src", "test", "resources", "asyncapi.actual.json"), actual); diff --git a/springwolf-examples/springwolf-sns-example/src/test/java/io/github/stavshamir/springwolf/example/sns/ApiSystemTest.java b/springwolf-examples/springwolf-sns-example/src/test/java/io/github/stavshamir/springwolf/example/sns/ApiSystemTest.java index ff7c8f5cf..364dd22af 100644 --- a/springwolf-examples/springwolf-sns-example/src/test/java/io/github/stavshamir/springwolf/example/sns/ApiSystemTest.java +++ b/springwolf-examples/springwolf-sns-example/src/test/java/io/github/stavshamir/springwolf/example/sns/ApiSystemTest.java @@ -2,7 +2,6 @@ package io.github.stavshamir.springwolf.example.sns; import lombok.extern.slf4j.Slf4j; -import org.json.JSONException; import org.junit.jupiter.api.Test; import org.springframework.web.client.RestTemplate; import org.testcontainers.containers.DockerComposeContainer; @@ -58,7 +57,7 @@ private String baseUrl() { } @Test - void asyncapiDocsShouldReturnTheCorrectJsonResponse() throws IOException, JSONException { + void asyncapiDocsShouldReturnTheCorrectJsonResponse() throws IOException { String url = baseUrl() + "/springwolf/docs"; String actual = restTemplate.getForObject(url, String.class); diff --git a/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/stavshamir/springwolf/example/sqs/ApiIntegrationTest.java b/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/stavshamir/springwolf/example/sqs/ApiIntegrationTest.java index a0a0545ad..e8f5c253e 100644 --- a/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/stavshamir/springwolf/example/sqs/ApiIntegrationTest.java +++ b/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/stavshamir/springwolf/example/sqs/ApiIntegrationTest.java @@ -1,11 +1,9 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.example.sqs; -import org.json.JSONException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.test.context.DynamicPropertyRegistry; @@ -33,11 +31,8 @@ static void setUpTestContainers(DynamicPropertyRegistry registry) { @Autowired private TestRestTemplate restTemplate; - @Value("${server.port}") - public Integer serverPort; - @Test - void asyncApiResourceArtifactTest() throws JSONException, IOException { + void asyncApiResourceArtifactTest() throws IOException { String url = "/springwolf/docs"; String actual = restTemplate.getForObject(url, String.class); Files.writeString(Path.of("src", "test", "resources", "asyncapi.actual.json"), actual); diff --git a/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/stavshamir/springwolf/example/sqs/ApiSystemTest.java b/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/stavshamir/springwolf/example/sqs/ApiSystemTest.java index 7ffa816ca..c19021483 100644 --- a/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/stavshamir/springwolf/example/sqs/ApiSystemTest.java +++ b/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/stavshamir/springwolf/example/sqs/ApiSystemTest.java @@ -1,7 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.example.sqs; -import org.json.JSONException; import org.junit.jupiter.api.Test; import org.springframework.web.client.RestTemplate; import org.testcontainers.containers.DockerComposeContainer; @@ -55,7 +54,7 @@ private String baseUrl() { } @Test - void asyncapiDocsShouldReturnTheCorrectJsonResponse() throws IOException, JSONException { + void asyncapiDocsShouldReturnTheCorrectJsonResponse() throws IOException { String url = baseUrl() + "/springwolf/docs"; String actual = restTemplate.getForObject(url, String.class); diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/producer/SpringwolfKafkaTemplateFactory.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/producer/SpringwolfKafkaTemplateFactory.java index be700e1bc..98224d5af 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/producer/SpringwolfKafkaTemplateFactory.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/stavshamir/springwolf/producer/SpringwolfKafkaTemplateFactory.java @@ -5,6 +5,7 @@ import io.github.stavshamir.springwolf.configuration.properties.SpringwolfKafkaConfigProperties; import lombok.RequiredArgsConstructor; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.ssl.DefaultSslBundleRegistry; import org.springframework.kafka.core.DefaultKafkaProducerFactory; import org.springframework.kafka.core.KafkaTemplate; @@ -25,7 +26,7 @@ public Optional> buildKafkaTemplate() { Map producerProperties = springWolfKafkaConfigProperties .getPublishing() .getProducer() - .buildProperties(); + .buildProperties(new DefaultSslBundleRegistry()); DefaultKafkaProducerFactory producerFactory = new DefaultKafkaProducerFactory<>(producerProperties); kafkaTemplate = Optional.of(new KafkaTemplate<>(producerFactory)); diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfKafkaTemplateFactoryTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfKafkaTemplateFactoryTest.java index fadd4e448..374636681 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfKafkaTemplateFactoryTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/stavshamir/springwolf/producer/SpringwolfKafkaTemplateFactoryTest.java @@ -4,6 +4,7 @@ import io.github.stavshamir.springwolf.configuration.properties.SpringwolfKafkaConfigProperties; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.kafka.KafkaProperties; +import org.springframework.boot.ssl.DefaultSslBundleRegistry; import org.springframework.kafka.core.KafkaTemplate; import java.util.Map; @@ -53,6 +54,7 @@ void kafkaTemplateShouldBeCreatedWithProducerConfiguration() { Map configurationProperties = kafkaTemplate.get().getProducerFactory().getConfigurationProperties(); - assertThat(configurationProperties).isEqualTo(new KafkaProperties.Producer().buildProperties()); + assertThat(configurationProperties) + .isEqualTo(new KafkaProperties.Producer().buildProperties(new DefaultSslBundleRegistry())); } } From cbd9d34d53964060a1c9d513a7ccb01b77e57243 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Fri, 24 Nov 2023 10:19:52 +0100 Subject: [PATCH 3/5] chore: remove unused dependency com.vaadin.external.google:android-json --- dependencies.gradle | 2 -- springwolf-core/build.gradle | 1 - .../DefaultAsyncApiSerializerServiceIntegrationTest.java | 5 ++--- springwolf-examples/springwolf-amqp-example/build.gradle | 2 -- .../springwolf-cloud-stream-example/build.gradle | 1 - springwolf-examples/springwolf-kafka-example/build.gradle | 2 -- springwolf-examples/springwolf-sns-example/build.gradle | 2 -- springwolf-examples/springwolf-sqs-example/build.gradle | 2 -- 8 files changed, 2 insertions(+), 15 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 70ce23cc8..d488f0b5e 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -25,8 +25,6 @@ * The dependencies are sorted alphabetically. */ ext { - androidJsonVersion = '0.0.20131108.vaadin1' - assertjCoreVersion = '3.24.2' asyncapiCoreVersion = '1.0.0-EAP-2' diff --git a/springwolf-core/build.gradle b/springwolf-core/build.gradle index 686276aba..78a6b6a98 100644 --- a/springwolf-core/build.gradle +++ b/springwolf-core/build.gradle @@ -47,7 +47,6 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter-params:${junitJupiterVersion}") testImplementation "org.assertj:assertj-core:${assertjCoreVersion}" testImplementation "org.awaitility:awaitility:${awaitilityVersion}" - testImplementation "com.vaadin.external.google:android-json:${androidJsonVersion}" testImplementation "org.mockito:mockito-core:${mockitoCoreVersion}" testImplementation "org.springframework.boot:spring-boot-test" testImplementation "org.springframework:spring-test" diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiSerializerServiceIntegrationTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiSerializerServiceIntegrationTest.java index 891748eae..d91b612f5 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiSerializerServiceIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiSerializerServiceIntegrationTest.java @@ -19,7 +19,6 @@ import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.StringSchema; import lombok.Data; -import org.json.JSONException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; @@ -106,7 +105,7 @@ private AsyncAPI getAsyncAPITestObject() { } @Test - void AsyncAPI_should_map_to_a_valid_asyncapi_json() throws IOException, JSONException { + void AsyncAPI_should_map_to_a_valid_asyncapi_json() throws IOException { var asyncapi = getAsyncAPITestObject(); String actual = serializer.toJsonString(asyncapi); InputStream s = this.getClass().getResourceAsStream("/asyncapi/asyncapi.json"); @@ -115,7 +114,7 @@ void AsyncAPI_should_map_to_a_valid_asyncapi_json() throws IOException, JSONExce } @Test - void AsyncAPI_should_map_to_a_valid_asyncapi_yaml() throws IOException, JSONException { + void AsyncAPI_should_map_to_a_valid_asyncapi_yaml() throws IOException { var asyncapi = getAsyncAPITestObject(); String actual = serializer.toYaml(asyncapi); InputStream s = this.getClass().getResourceAsStream("/asyncapi/asyncapi.yaml"); diff --git a/springwolf-examples/springwolf-amqp-example/build.gradle b/springwolf-examples/springwolf-amqp-example/build.gradle index c8b3aea71..62cd0d4b7 100644 --- a/springwolf-examples/springwolf-amqp-example/build.gradle +++ b/springwolf-examples/springwolf-amqp-example/build.gradle @@ -28,8 +28,6 @@ dependencies { testRuntimeOnly "org.junit.jupiter:junit-jupiter:${junitJupiterVersion}" - testImplementation "com.vaadin.external.google:android-json:${androidJsonVersion}" - testImplementation "org.assertj:assertj-core:${assertjCoreVersion}" testImplementation "org.awaitility:awaitility:${awaitilityVersion}" testImplementation "org.mockito:mockito-core:${mockitoCoreVersion}" diff --git a/springwolf-examples/springwolf-cloud-stream-example/build.gradle b/springwolf-examples/springwolf-cloud-stream-example/build.gradle index 2f188bf60..434448463 100644 --- a/springwolf-examples/springwolf-cloud-stream-example/build.gradle +++ b/springwolf-examples/springwolf-cloud-stream-example/build.gradle @@ -42,7 +42,6 @@ dependencies { testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" testRuntimeOnly "org.junit.jupiter:junit-jupiter:${junitJupiterVersion}" - testImplementation "com.vaadin.external.google:android-json:${androidJsonVersion}" testImplementation "org.assertj:assertj-core:${assertjCoreVersion}" testImplementation "org.springframework.boot:spring-boot-test" testImplementation "org.springframework:spring-test" diff --git a/springwolf-examples/springwolf-kafka-example/build.gradle b/springwolf-examples/springwolf-kafka-example/build.gradle index 9e95286d3..359602d0f 100644 --- a/springwolf-examples/springwolf-kafka-example/build.gradle +++ b/springwolf-examples/springwolf-kafka-example/build.gradle @@ -40,8 +40,6 @@ dependencies { testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" - testImplementation "com.vaadin.external.google:android-json:${androidJsonVersion}" - testImplementation "org.apache.kafka:kafka-clients:${kafkaClientsVersion}@jar" testImplementation "org.assertj:assertj-core:${assertjCoreVersion}" testImplementation "org.awaitility:awaitility:${awaitilityVersion}" diff --git a/springwolf-examples/springwolf-sns-example/build.gradle b/springwolf-examples/springwolf-sns-example/build.gradle index 9851c78f1..923121168 100644 --- a/springwolf-examples/springwolf-sns-example/build.gradle +++ b/springwolf-examples/springwolf-sns-example/build.gradle @@ -37,8 +37,6 @@ dependencies { testRuntimeOnly "org.junit.jupiter:junit-jupiter:${junitJupiterVersion}" - testImplementation "com.vaadin.external.google:android-json:${androidJsonVersion}" - testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" testImplementation "org.springframework.boot:spring-boot-test" diff --git a/springwolf-examples/springwolf-sqs-example/build.gradle b/springwolf-examples/springwolf-sqs-example/build.gradle index 3a35c5999..ef6689bd4 100644 --- a/springwolf-examples/springwolf-sqs-example/build.gradle +++ b/springwolf-examples/springwolf-sqs-example/build.gradle @@ -36,8 +36,6 @@ dependencies { testRuntimeOnly "org.junit.jupiter:junit-jupiter:${junitJupiterVersion}" - testImplementation "com.vaadin.external.google:android-json:${androidJsonVersion}" - testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" testImplementation "org.mockito:mockito-core:${mockitoCoreVersion}" From 95c3a110b541341949dbbc6cfc2d771ce1abda81 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Fri, 24 Nov 2023 13:13:49 +0100 Subject: [PATCH 4/5] test: Add application loggers to ApiSystemTest --- springwolf-examples/springwolf-amqp-example/build.gradle | 3 +++ .../stavshamir/springwolf/example/amqp/ApiSystemTest.java | 5 ++++- .../springwolf-cloud-stream-example/build.gradle | 3 +++ .../springwolf/example/cloudstream/ApiSystemTest.java | 5 ++++- springwolf-examples/springwolf-kafka-example/build.gradle | 3 +++ .../stavshamir/springwolf/example/kafka/ApiSystemTest.java | 5 ++++- springwolf-examples/springwolf-sqs-example/build.gradle | 3 +++ .../stavshamir/springwolf/example/sqs/ApiSystemTest.java | 5 ++++- 8 files changed, 28 insertions(+), 4 deletions(-) diff --git a/springwolf-examples/springwolf-amqp-example/build.gradle b/springwolf-examples/springwolf-amqp-example/build.gradle index 62cd0d4b7..c66d1e6eb 100644 --- a/springwolf-examples/springwolf-amqp-example/build.gradle +++ b/springwolf-examples/springwolf-amqp-example/build.gradle @@ -40,6 +40,9 @@ dependencies { testImplementation "org.testcontainers:testcontainers:${testcontainersVersion}" testImplementation "org.testcontainers:junit-jupiter:${testcontainersVersion}" + + testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}" + testCompileOnly "org.projectlombok:lombok:${lombokVersion}" } docker { diff --git a/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/amqp/ApiSystemTest.java b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/amqp/ApiSystemTest.java index 2a1f25cdf..964c5ee15 100644 --- a/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/amqp/ApiSystemTest.java +++ b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/stavshamir/springwolf/example/amqp/ApiSystemTest.java @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.example.amqp; +import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import org.springframework.web.client.RestTemplate; import org.testcontainers.containers.DockerComposeContainer; @@ -22,6 +23,7 @@ * While the assertion of this test is identical to ApiIntegrationTests, * the setup uses a full docker-compose context with a real kafka instance. */ +@Slf4j @Testcontainers // @Ignore("Uncomment this line if you have issues running this test on your local machine.") public class ApiSystemTest { @@ -45,7 +47,8 @@ public class ApiSystemTest { @Container public static DockerComposeContainer environment = new DockerComposeContainer<>(new File("docker-compose.yml")) .withExposedService(APP_NAME, APP_PORT) - .withEnv(ENV); + .withEnv(ENV) + .withLogConsumer(APP_NAME, l -> log.debug("APP: %s".formatted(l.getUtf8StringWithoutLineEnding()))); private String baseUrl() { String host = environment.getServiceHost(APP_NAME, APP_PORT); diff --git a/springwolf-examples/springwolf-cloud-stream-example/build.gradle b/springwolf-examples/springwolf-cloud-stream-example/build.gradle index 434448463..0559fd64c 100644 --- a/springwolf-examples/springwolf-cloud-stream-example/build.gradle +++ b/springwolf-examples/springwolf-cloud-stream-example/build.gradle @@ -51,6 +51,9 @@ dependencies { testImplementation "org.springframework.kafka:spring-kafka-test" testImplementation "org.testcontainers:testcontainers:${testcontainersVersion}" testImplementation "org.testcontainers:junit-jupiter:${testcontainersVersion}" + + testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}" + testCompileOnly "org.projectlombok:lombok:${lombokVersion}" } docker { diff --git a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/cloudstream/ApiSystemTest.java b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/cloudstream/ApiSystemTest.java index a8c741984..5b875acdc 100644 --- a/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/cloudstream/ApiSystemTest.java +++ b/springwolf-examples/springwolf-cloud-stream-example/src/test/java/io/github/stavshamir/springwolf/example/cloudstream/ApiSystemTest.java @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.example.cloudstream; +import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import org.springframework.web.client.RestTemplate; import org.testcontainers.containers.DockerComposeContainer; @@ -22,6 +23,7 @@ * While the assertion of this test is identical to ApiIntegrationTests, * the setup uses a full docker-compose context with a real kafka instance. */ +@Slf4j @Testcontainers // @Ignore("Uncomment this line if you have issues running this test on your local machine.") public class ApiSystemTest { @@ -45,7 +47,8 @@ public class ApiSystemTest { @Container public static DockerComposeContainer environment = new DockerComposeContainer<>(new File("docker-compose.yml")) .withExposedService(APP_NAME, APP_PORT) - .withEnv(ENV); + .withEnv(ENV) + .withLogConsumer(APP_NAME, l -> log.debug("APP: %s".formatted(l.getUtf8StringWithoutLineEnding()))); private String baseUrl() { String host = environment.getServiceHost(APP_NAME, APP_PORT); diff --git a/springwolf-examples/springwolf-kafka-example/build.gradle b/springwolf-examples/springwolf-kafka-example/build.gradle index 359602d0f..6b4b10e1c 100644 --- a/springwolf-examples/springwolf-kafka-example/build.gradle +++ b/springwolf-examples/springwolf-kafka-example/build.gradle @@ -58,6 +58,9 @@ dependencies { testImplementation("org.springframework.boot:spring-boot-starter-actuator") permitTestUnusedDeclared("org.springframework.boot:spring-boot-starter-actuator") + + testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}" + testCompileOnly "org.projectlombok:lombok:${lombokVersion}" } docker { diff --git a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiSystemTest.java b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiSystemTest.java index fc6a6b127..d6cd8da94 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiSystemTest.java +++ b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ApiSystemTest.java @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.example.kafka; +import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import org.springframework.web.client.RestTemplate; import org.testcontainers.containers.DockerComposeContainer; @@ -22,6 +23,7 @@ * While the assertion of this test is identical to ApiIntegrationTests, * the setup uses a full docker-compose context with a real kafka instance. */ +@Slf4j @Testcontainers // @Ignore("Uncomment this line if you have issues running this test on your local machine.") public class ApiSystemTest { @@ -45,7 +47,8 @@ public class ApiSystemTest { @Container public static DockerComposeContainer environment = new DockerComposeContainer<>(new File("docker-compose.yml")) .withExposedService(APP_NAME, APP_PORT) - .withEnv(ENV); + .withEnv(ENV) + .withLogConsumer(APP_NAME, l -> log.debug("APP: %s".formatted(l.getUtf8StringWithoutLineEnding()))); private String baseUrl() { String host = environment.getServiceHost(APP_NAME, APP_PORT); diff --git a/springwolf-examples/springwolf-sqs-example/build.gradle b/springwolf-examples/springwolf-sqs-example/build.gradle index ef6689bd4..71ee479cd 100644 --- a/springwolf-examples/springwolf-sqs-example/build.gradle +++ b/springwolf-examples/springwolf-sqs-example/build.gradle @@ -48,6 +48,9 @@ dependencies { testImplementation "org.testcontainers:testcontainers:${testcontainersVersion}" testImplementation "org.testcontainers:junit-jupiter:${testcontainersVersion}" testImplementation "org.testcontainers:localstack:${testcontainersVersion}" + + testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}" + testCompileOnly "org.projectlombok:lombok:${lombokVersion}" } docker { diff --git a/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/stavshamir/springwolf/example/sqs/ApiSystemTest.java b/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/stavshamir/springwolf/example/sqs/ApiSystemTest.java index c19021483..9957883a5 100644 --- a/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/stavshamir/springwolf/example/sqs/ApiSystemTest.java +++ b/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/stavshamir/springwolf/example/sqs/ApiSystemTest.java @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.example.sqs; +import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import org.springframework.web.client.RestTemplate; import org.testcontainers.containers.DockerComposeContainer; @@ -22,6 +23,7 @@ * While the assertion of this test is identical to ApiIntegrationTests, * the setup uses a full docker-compose context with a real sqs instance. */ +@Slf4j @Testcontainers // @Ignore("Uncomment this line if you have issues running this test on your local machine.") public class ApiSystemTest { @@ -45,7 +47,8 @@ public class ApiSystemTest { @Container public DockerComposeContainer environment = new DockerComposeContainer<>(new File("docker-compose.yml")) .withExposedService(APP_NAME, APP_PORT) - .withEnv(ENV); + .withEnv(ENV) + .withLogConsumer(APP_NAME, l -> log.debug("APP: %s".formatted(l.getUtf8StringWithoutLineEnding()))); private String baseUrl() { String host = environment.getServiceHost(APP_NAME, APP_PORT); From 416f33a006fef2b460a8c646e4dc168f462f7b2f Mon Sep 17 00:00:00 2001 From: Timon Back Date: Fri, 24 Nov 2023 13:15:24 +0100 Subject: [PATCH 5/5] test(kafka): ensure ProducerSystemTest can connect to kafka Without, the test connects to a kafka instance of a previous spring context instance - which is an embeddedkafka and not available --- .../springwolf/example/kafka/ProducerSystemTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ProducerSystemTest.java b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ProducerSystemTest.java index 6a2bf7cd2..fc46ec712 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ProducerSystemTest.java +++ b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ProducerSystemTest.java @@ -15,7 +15,7 @@ import org.springframework.boot.ssl.DefaultSslBundleRegistry; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.SpyBean; -import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.TestPropertySource; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; @@ -39,7 +39,7 @@ classes = {SpringwolfKafkaExampleApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @Testcontainers -@DirtiesContext +@TestPropertySource(properties = {"spring.kafka.bootstrap-servers=localhost:9092"}) @TestMethodOrder(OrderAnnotation.class) // @Ignore("Uncomment this line if you have issues running this test on your local machine.") public class ProducerSystemTest {