From 750c5972255161f9314b0fea5d2141f6f49bf4bb Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 6 Sep 2023 11:57:03 -0700 Subject: [PATCH] Polish 'Add Pulsar ConnectionDetails support' See gh-37197 --- .../spring-boot-autoconfigure/build.gradle | 1 - .../PropertiesPulsarConnectionDetails.java | 4 +- .../pulsar/PulsarConfiguration.java | 18 +------- .../pulsar/PulsarConnectionDetails.java | 12 ++--- .../pulsar/PulsarPropertiesMapper.java | 9 ++-- ...ropertiesPulsarConnectionDetailsTests.java | 20 ++++----- .../pulsar/PulsarConfigurationTests.java | 45 +++---------------- .../pulsar/PulsarPropertiesMapperTests.java | 35 +++++++++++++-- ...DockerComposeConnectionDetailsFactory.java | 14 +++--- ...nectionDetailsFactoryIntegrationTests.java | 4 +- .../spring-boot-testcontainers/build.gradle | 5 --- ...lsarContainerConnectionDetailsFactory.java | 4 +- .../pulsar/SamplePulsarApplicationTests.java | 1 - 13 files changed, 74 insertions(+), 98 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/build.gradle b/spring-boot-project/spring-boot-autoconfigure/build.gradle index f88acc52ee..b48da7b7bf 100644 --- a/spring-boot-project/spring-boot-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-autoconfigure/build.gradle @@ -277,5 +277,4 @@ tasks.named("checkSpringConfigurationMetadata").configure { test { jvmArgs += "--add-opens=java.base/java.net=ALL-UNNAMED" - jvmArgs += "--add-opens=java.base/sun.net=ALL-UNNAMED" } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PropertiesPulsarConnectionDetails.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PropertiesPulsarConnectionDetails.java index 6865e3a5e6..51ed0fadc3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PropertiesPulsarConnectionDetails.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PropertiesPulsarConnectionDetails.java @@ -30,12 +30,12 @@ class PropertiesPulsarConnectionDetails implements PulsarConnectionDetails { } @Override - public String getPulsarBrokerUrl() { + public String getBrokerUrl() { return this.pulsarProperties.getClient().getServiceUrl(); } @Override - public String getPulsarAdminUrl() { + public String getAdminUrl() { return this.pulsarProperties.getAdmin().getServiceUrl(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarConfiguration.java index 6a5baf469f..64efd410cc 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarConfiguration.java @@ -82,20 +82,13 @@ class PulsarConfiguration { DefaultPulsarClientFactory pulsarClientFactory(PulsarConnectionDetails connectionDetails, ObjectProvider customizersProvider) { List allCustomizers = new ArrayList<>(); - allCustomizers.add(this.propertiesMapper::customizeClientBuilder); - allCustomizers.add((clientBuilder) -> this.applyConnectionDetails(connectionDetails, clientBuilder)); + allCustomizers.add((builder) -> this.propertiesMapper.customizeClientBuilder(builder, connectionDetails)); allCustomizers.addAll(customizersProvider.orderedStream().toList()); DefaultPulsarClientFactory clientFactory = new DefaultPulsarClientFactory( (clientBuilder) -> applyClientBuilderCustomizers(allCustomizers, clientBuilder)); return clientFactory; } - private void applyConnectionDetails(PulsarConnectionDetails connectionDetails, ClientBuilder clientBuilder) { - if (connectionDetails.getPulsarBrokerUrl() != null) { - clientBuilder.serviceUrl(connectionDetails.getPulsarBrokerUrl()); - } - } - private void applyClientBuilderCustomizers(List customizers, ClientBuilder clientBuilder) { customizers.forEach((customizer) -> customizer.customize(clientBuilder)); @@ -112,18 +105,11 @@ class PulsarConfiguration { PulsarAdministration pulsarAdministration(PulsarConnectionDetails connectionDetails, ObjectProvider pulsarAdminBuilderCustomizers) { List allCustomizers = new ArrayList<>(); - allCustomizers.add(this.propertiesMapper::customizeAdminBuilder); - allCustomizers.add((adminBuilder) -> this.applyConnectionDetails(connectionDetails, adminBuilder)); + allCustomizers.add((builder) -> this.propertiesMapper.customizeAdminBuilder(builder, connectionDetails)); allCustomizers.addAll(pulsarAdminBuilderCustomizers.orderedStream().toList()); return new PulsarAdministration((adminBuilder) -> applyAdminBuilderCustomizers(allCustomizers, adminBuilder)); } - private void applyConnectionDetails(PulsarConnectionDetails connectionDetails, PulsarAdminBuilder adminBuilder) { - if (connectionDetails.getPulsarAdminUrl() != null) { - adminBuilder.serviceHttpUrl(connectionDetails.getPulsarAdminUrl()); - } - } - private void applyAdminBuilderCustomizers(List customizers, PulsarAdminBuilder adminBuilder) { customizers.forEach((customizer) -> customizer.customize(adminBuilder)); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarConnectionDetails.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarConnectionDetails.java index 567134b77a..1d21f5802e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarConnectionDetails.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarConnectionDetails.java @@ -27,15 +27,15 @@ import org.springframework.boot.autoconfigure.service.connection.ConnectionDetai public interface PulsarConnectionDetails extends ConnectionDetails { /** - * Returns the Pulsar service URL for the broker. - * @return the Pulsar service URL for the broker + * URL used to connect to the broker. + * @return the service URL */ - String getPulsarBrokerUrl(); + String getBrokerUrl(); /** - * Returns the Pulsar web URL for the admin endpoint. - * @return the Pulsar web URL for the admin endpoint + * URL user to connect to the admin endpoint. + * @return the admin URL */ - String getPulsarAdminUrl(); + String getAdminUrl(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapper.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapper.java index 77a6b63212..04246d0e91 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapper.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapper.java @@ -49,21 +49,20 @@ final class PulsarPropertiesMapper { this.properties = properties; } - void customizeClientBuilder(ClientBuilder clientBuilder) { + void customizeClientBuilder(ClientBuilder clientBuilder, PulsarConnectionDetails connectionDetails) { PulsarProperties.Client properties = this.properties.getClient(); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); - map.from(properties::getServiceUrl).to(clientBuilder::serviceUrl); - + map.from(connectionDetails::getBrokerUrl).to(clientBuilder::serviceUrl); map.from(properties::getConnectionTimeout).to(timeoutProperty(clientBuilder::connectionTimeout)); map.from(properties::getOperationTimeout).to(timeoutProperty(clientBuilder::operationTimeout)); map.from(properties::getLookupTimeout).to(timeoutProperty(clientBuilder::lookupTimeout)); customizeAuthentication(clientBuilder::authentication, properties.getAuthentication()); } - void customizeAdminBuilder(PulsarAdminBuilder adminBuilder) { + void customizeAdminBuilder(PulsarAdminBuilder adminBuilder, PulsarConnectionDetails connectionDetails) { PulsarProperties.Admin properties = this.properties.getAdmin(); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); - map.from(properties::getServiceUrl).to(adminBuilder::serviceHttpUrl); + map.from(connectionDetails::getAdminUrl).to(adminBuilder::serviceHttpUrl); map.from(properties::getConnectionTimeout).to(timeoutProperty(adminBuilder::connectionTimeout)); map.from(properties::getReadTimeout).to(timeoutProperty(adminBuilder::readTimeout)); map.from(properties::getRequestTimeout).to(timeoutProperty(adminBuilder::requestTimeout)); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PropertiesPulsarConnectionDetailsTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PropertiesPulsarConnectionDetailsTests.java index 8fed356282..3abff9be73 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PropertiesPulsarConnectionDetailsTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PropertiesPulsarConnectionDetailsTests.java @@ -28,19 +28,19 @@ import static org.assertj.core.api.Assertions.assertThat; class PropertiesPulsarConnectionDetailsTests { @Test - void pulsarBrokerUrlIsObtainedFromPulsarProperties() { - var pulsarProps = new PulsarProperties(); - pulsarProps.getClient().setServiceUrl("foo"); - var connectionDetails = new PropertiesPulsarConnectionDetails(pulsarProps); - assertThat(connectionDetails.getPulsarBrokerUrl()).isEqualTo("foo"); + void getClientServiceUrlReturnsValueFromProperties() { + PulsarProperties properties = new PulsarProperties(); + properties.getClient().setServiceUrl("foo"); + PulsarConnectionDetails connectionDetails = new PropertiesPulsarConnectionDetails(properties); + assertThat(connectionDetails.getBrokerUrl()).isEqualTo("foo"); } @Test - void pulsarAdminUrlIsObtainedFromPulsarProperties() { - var pulsarProps = new PulsarProperties(); - pulsarProps.getAdmin().setServiceUrl("foo"); - var connectionDetails = new PropertiesPulsarConnectionDetails(pulsarProps); - assertThat(connectionDetails.getPulsarAdminUrl()).isEqualTo("foo"); + void getAdminServiceHttpUrlReturnsValueFromProperties() { + PulsarProperties properties = new PulsarProperties(); + properties.getAdmin().setServiceUrl("foo"); + PulsarConnectionDetails connectionDetails = new PropertiesPulsarConnectionDetails(properties); + assertThat(connectionDetails.getAdminUrl()).isEqualTo("foo"); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarConfigurationTests.java index e014eabd9d..a1136b11ba 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarConfigurationTests.java @@ -96,36 +96,20 @@ class PulsarConfigurationTests { .run((context) -> assertThat(context).getBean(PulsarClient.class).isSameAs(customClient)); } - @Test - void whenConnectionDetailsAreNullTheyAreNotApplied() { - PulsarConnectionDetails connectionDetails = mock(PulsarConnectionDetails.class); - given(connectionDetails.getPulsarBrokerUrl()).willReturn(null); - PulsarConfigurationTests.this.contextRunner.withBean(PulsarConnectionDetails.class, () -> connectionDetails) - .withPropertyValues("spring.pulsar.client.service-url=fromPropsCustomizer") - .run((context) -> { - DefaultPulsarClientFactory clientFactory = context.getBean(DefaultPulsarClientFactory.class); - Customizers customizers = Customizers - .of(ClientBuilder.class, PulsarClientBuilderCustomizer::customize); - assertThat(customizers.fromField(clientFactory, "customizer")) - .callsInOrder(ClientBuilder::serviceUrl, "fromPropsCustomizer"); - }); - } - @Test void whenHasUserDefinedCustomizersAppliesInCorrectOrder() { PulsarConnectionDetails connectionDetails = mock(PulsarConnectionDetails.class); - given(connectionDetails.getPulsarBrokerUrl()).willReturn("fromConnectionDetailsCustomizer"); + given(connectionDetails.getBrokerUrl()).willReturn("connectiondetails"); PulsarConfigurationTests.this.contextRunner .withUserConfiguration(PulsarClientBuilderCustomizersConfig.class) .withBean(PulsarConnectionDetails.class, () -> connectionDetails) - .withPropertyValues("spring.pulsar.client.service-url=fromPropsCustomizer") + .withPropertyValues("spring.pulsar.client.service-url=properties") .run((context) -> { DefaultPulsarClientFactory clientFactory = context.getBean(DefaultPulsarClientFactory.class); Customizers customizers = Customizers .of(ClientBuilder.class, PulsarClientBuilderCustomizer::customize); assertThat(customizers.fromField(clientFactory, "customizer")).callsInOrder( - ClientBuilder::serviceUrl, "fromPropsCustomizer", "fromConnectionDetailsCustomizer", - "fromCustomizer1", "fromCustomizer2"); + ClientBuilder::serviceUrl, "connectiondetails", "fromCustomizer1", "fromCustomizer2"); }); } @@ -162,35 +146,20 @@ class PulsarConfigurationTests { .isSameAs(pulsarAdministration)); } - @Test - void whenConnectionDetailsAreNullTheyAreNotApplied() { - PulsarConnectionDetails connectionDetails = mock(PulsarConnectionDetails.class); - given(connectionDetails.getPulsarAdminUrl()).willReturn(null); - PulsarConfigurationTests.this.contextRunner.withBean(PulsarConnectionDetails.class, () -> connectionDetails) - .withPropertyValues("spring.pulsar.admin.service-url=fromPropsCustomizer") - .run((context) -> { - PulsarAdministration pulsarAdmin = context.getBean(PulsarAdministration.class); - Customizers customizers = Customizers - .of(PulsarAdminBuilder.class, PulsarAdminBuilderCustomizer::customize); - assertThat(customizers.fromField(pulsarAdmin, "adminCustomizers")) - .callsInOrder(PulsarAdminBuilder::serviceHttpUrl, "fromPropsCustomizer"); - }); - } - @Test void whenHasUserDefinedCustomizersAppliesInCorrectOrder() { PulsarConnectionDetails connectionDetails = mock(PulsarConnectionDetails.class); - given(connectionDetails.getPulsarAdminUrl()).willReturn("fromConnectionDetailsCustomizer"); + given(connectionDetails.getAdminUrl()).willReturn("connectiondetails"); this.contextRunner.withUserConfiguration(PulsarAdminBuilderCustomizersConfig.class) .withBean(PulsarConnectionDetails.class, () -> connectionDetails) - .withPropertyValues("spring.pulsar.admin.service-url=fromPropsCustomizer") + .withPropertyValues("spring.pulsar.admin.service-url=property") .run((context) -> { PulsarAdministration pulsarAdmin = context.getBean(PulsarAdministration.class); Customizers customizers = Customizers .of(PulsarAdminBuilder.class, PulsarAdminBuilderCustomizer::customize); assertThat(customizers.fromField(pulsarAdmin, "adminCustomizers")).callsInOrder( - PulsarAdminBuilder::serviceHttpUrl, "fromPropsCustomizer", - "fromConnectionDetailsCustomizer", "fromCustomizer1", "fromCustomizer2"); + PulsarAdminBuilder::serviceHttpUrl, "connectiondetails", "fromCustomizer1", + "fromCustomizer2"); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapperTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapperTests.java index 283e06c1d4..b168d4f713 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapperTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarPropertiesMapperTests.java @@ -41,6 +41,7 @@ import org.springframework.boot.autoconfigure.pulsar.PulsarProperties.Consumer; import org.springframework.pulsar.listener.PulsarContainerProperties; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; @@ -60,7 +61,8 @@ class PulsarPropertiesMapperTests { properties.getClient().setOperationTimeout(Duration.ofSeconds(2)); properties.getClient().setLookupTimeout(Duration.ofSeconds(3)); ClientBuilder builder = mock(ClientBuilder.class); - new PulsarPropertiesMapper(properties).customizeClientBuilder(builder); + new PulsarPropertiesMapper(properties).customizeClientBuilder(builder, + new PropertiesPulsarConnectionDetails(properties)); then(builder).should().serviceUrl("https://example.com"); then(builder).should().connectionTimeout(1000, TimeUnit.MILLISECONDS); then(builder).should().operationTimeout(2000, TimeUnit.MILLISECONDS); @@ -74,10 +76,22 @@ class PulsarPropertiesMapperTests { properties.getClient().getAuthentication().setPluginClassName("myclass"); properties.getClient().getAuthentication().setParam(params); ClientBuilder builder = mock(ClientBuilder.class); - new PulsarPropertiesMapper(properties).customizeClientBuilder(builder); + new PulsarPropertiesMapper(properties).customizeClientBuilder(builder, + new PropertiesPulsarConnectionDetails(properties)); then(builder).should().authentication("myclass", params); } + @Test + void customizeClientBuilderWhenHasConnectionDetails() { + PulsarProperties properties = new PulsarProperties(); + properties.getClient().setServiceUrl("https://ignored.example.com"); + ClientBuilder builder = mock(ClientBuilder.class); + PulsarConnectionDetails connectionDetails = mock(PulsarConnectionDetails.class); + given(connectionDetails.getBrokerUrl()).willReturn("https://used.example.com"); + new PulsarPropertiesMapper(properties).customizeClientBuilder(builder, connectionDetails); + then(builder).should().serviceUrl("https://used.example.com"); + } + @Test void customizeAdminBuilderWhenHasNoAuthentication() { PulsarProperties properties = new PulsarProperties(); @@ -86,7 +100,8 @@ class PulsarPropertiesMapperTests { properties.getAdmin().setReadTimeout(Duration.ofSeconds(2)); properties.getAdmin().setRequestTimeout(Duration.ofSeconds(3)); PulsarAdminBuilder builder = mock(PulsarAdminBuilder.class); - new PulsarPropertiesMapper(properties).customizeAdminBuilder(builder); + new PulsarPropertiesMapper(properties).customizeAdminBuilder(builder, + new PropertiesPulsarConnectionDetails(properties)); then(builder).should().serviceHttpUrl("https://example.com"); then(builder).should().connectionTimeout(1000, TimeUnit.MILLISECONDS); then(builder).should().readTimeout(2000, TimeUnit.MILLISECONDS); @@ -100,10 +115,22 @@ class PulsarPropertiesMapperTests { properties.getAdmin().getAuthentication().setPluginClassName("myclass"); properties.getAdmin().getAuthentication().setParam(params); PulsarAdminBuilder builder = mock(PulsarAdminBuilder.class); - new PulsarPropertiesMapper(properties).customizeAdminBuilder(builder); + new PulsarPropertiesMapper(properties).customizeAdminBuilder(builder, + new PropertiesPulsarConnectionDetails(properties)); then(builder).should().authentication("myclass", params); } + @Test + void customizeAdminBuilderWhenHasConnectionDetails() { + PulsarProperties properties = new PulsarProperties(); + properties.getAdmin().setServiceUrl("https://ignored.example.com"); + PulsarAdminBuilder builder = mock(PulsarAdminBuilder.class); + PulsarConnectionDetails connectionDetails = mock(PulsarConnectionDetails.class); + given(connectionDetails.getAdminUrl()).willReturn("https://used.example.com"); + new PulsarPropertiesMapper(properties).customizeAdminBuilder(builder, connectionDetails); + then(builder).should().serviceHttpUrl("https://used.example.com"); + } + @Test @SuppressWarnings("unchecked") void customizeProducerBuilder() { diff --git a/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/pulsar/PulsarDockerComposeConnectionDetailsFactory.java b/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/pulsar/PulsarDockerComposeConnectionDetailsFactory.java index c9817d3485..0568a98119 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/pulsar/PulsarDockerComposeConnectionDetailsFactory.java +++ b/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/pulsar/PulsarDockerComposeConnectionDetailsFactory.java @@ -17,6 +17,7 @@ package org.springframework.boot.docker.compose.service.connection.pulsar; import org.springframework.boot.autoconfigure.pulsar.PulsarConnectionDetails; +import org.springframework.boot.docker.compose.core.ConnectionPorts; import org.springframework.boot.docker.compose.core.RunningService; import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory; import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionSource; @@ -30,9 +31,9 @@ import org.springframework.boot.docker.compose.service.connection.DockerComposeC class PulsarDockerComposeConnectionDetailsFactory extends DockerComposeConnectionDetailsFactory { - private static final int PULSAR_BROKER_PORT = 6650; + private static final int BROKER_PORT = 6650; - private static final int PULSAR_ADMIN_PORT = 8080; + private static final int ADMIN_PORT = 8080; PulsarDockerComposeConnectionDetailsFactory() { super("apachepulsar/pulsar"); @@ -55,17 +56,18 @@ class PulsarDockerComposeConnectionDetailsFactory PulsarDockerComposeConnectionDetails(RunningService service) { super(service); - this.brokerUrl = "pulsar://%s:%s".formatted(service.host(), service.ports().get(PULSAR_BROKER_PORT)); - this.adminUrl = "http://%s:%s".formatted(service.host(), service.ports().get(PULSAR_ADMIN_PORT)); + ConnectionPorts ports = service.ports(); + this.brokerUrl = "pulsar://%s:%s".formatted(service.host(), ports.get(BROKER_PORT)); + this.adminUrl = "http://%s:%s".formatted(service.host(), ports.get(ADMIN_PORT)); } @Override - public String getPulsarBrokerUrl() { + public String getBrokerUrl() { return this.brokerUrl; } @Override - public String getPulsarAdminUrl() { + public String getAdminUrl() { return this.adminUrl; } diff --git a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/pulsar/PulsarDockerComposeConnectionDetailsFactoryIntegrationTests.java b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/pulsar/PulsarDockerComposeConnectionDetailsFactoryIntegrationTests.java index ed509613f5..c4c18d55ba 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/pulsar/PulsarDockerComposeConnectionDetailsFactoryIntegrationTests.java +++ b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/pulsar/PulsarDockerComposeConnectionDetailsFactoryIntegrationTests.java @@ -39,8 +39,8 @@ class PulsarDockerComposeConnectionDetailsFactoryIntegrationTests extends Abstra void runCreatesConnectionDetails() { PulsarConnectionDetails connectionDetails = run(PulsarConnectionDetails.class); assertThat(connectionDetails).isNotNull(); - assertThat(connectionDetails.getPulsarBrokerUrl()).matches("^pulsar:\\/\\/\\S+:\\d+"); - assertThat(connectionDetails.getPulsarAdminUrl()).matches("^http:\\/\\/\\S+:\\d+"); + assertThat(connectionDetails.getBrokerUrl()).matches("^pulsar:\\/\\/\\S+:\\d+"); + assertThat(connectionDetails.getAdminUrl()).matches("^http:\\/\\/\\S+:\\d+"); } } diff --git a/spring-boot-project/spring-boot-testcontainers/build.gradle b/spring-boot-project/spring-boot-testcontainers/build.gradle index 67fdb98603..d09e6d485f 100644 --- a/spring-boot-project/spring-boot-testcontainers/build.gradle +++ b/spring-boot-project/spring-boot-testcontainers/build.gradle @@ -56,8 +56,3 @@ dependencies { testRuntimeOnly("com.oracle.database.r2dbc:oracle-r2dbc") } - -test { - jvmArgs += "--add-opens=java.base/java.net=ALL-UNNAMED" - jvmArgs += "--add-opens=java.base/sun.net=ALL-UNNAMED" -} diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/pulsar/PulsarContainerConnectionDetailsFactory.java b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/pulsar/PulsarContainerConnectionDetailsFactory.java index 505a8e564e..836c1a127d 100644 --- a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/pulsar/PulsarContainerConnectionDetailsFactory.java +++ b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/pulsar/PulsarContainerConnectionDetailsFactory.java @@ -48,12 +48,12 @@ class PulsarContainerConnectionDetailsFactory } @Override - public String getPulsarBrokerUrl() { + public String getBrokerUrl() { return getContainer().getPulsarBrokerUrl(); } @Override - public String getPulsarAdminUrl() { + public String getAdminUrl() { return getContainer().getHttpServiceUrl(); } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar/src/test/java/smoketest/pulsar/SamplePulsarApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar/src/test/java/smoketest/pulsar/SamplePulsarApplicationTests.java index a7e6734e0d..c58c743cc8 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar/src/test/java/smoketest/pulsar/SamplePulsarApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar/src/test/java/smoketest/pulsar/SamplePulsarApplicationTests.java @@ -44,7 +44,6 @@ class SamplePulsarApplicationTests { @Container @ServiceConnection - @SuppressWarnings("unused") static final PulsarContainer container = new PulsarContainer(DockerImageNames.pulsar()).withStartupAttempts(2) .withStartupTimeout(Duration.ofMinutes(3));