Merge branch '3.1.x'

Closes gh-38405
This commit is contained in:
Phillip Webb
2023-11-20 16:27:46 -08:00
13 changed files with 123 additions and 32 deletions

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.testcontainers.service.connection;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory.ContainerConnectionDetailsFactoriesRuntimeHints;
public final class ContainerConnectionDetailsFactoryHints {
private ContainerConnectionDetailsFactoryHints() {
}
public static RuntimeHints getRegisteredHints(ClassLoader classLoader) {
RuntimeHints hints = new RuntimeHints();
new ContainerConnectionDetailsFactoriesRuntimeHints().registerHints(hints, classLoader);
return hints;
}
}

View File

@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactoryHints;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,8 +34,7 @@ class MongoContainerConnectionDetailsFactoryTests {
@Test
void shouldRegisterHints() {
RuntimeHints hints = new RuntimeHints();
new MongoContainerConnectionDetailsFactory().registerHints(hints, getClass().getClassLoader());
RuntimeHints hints = ContainerConnectionDetailsFactoryHints.getRegisteredHints(getClass().getClassLoader());
assertThat(RuntimeHintsPredicates.reflection().onType(ConnectionString.class)).accepts(hints);
}

View File

@@ -21,6 +21,7 @@ import org.neo4j.driver.AuthToken;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactoryHints;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,8 +34,7 @@ class Neo4jContainerConnectionDetailsFactoryTests {
@Test
void shouldRegisterHints() {
RuntimeHints hints = new RuntimeHints();
new Neo4jContainerConnectionDetailsFactory().registerHints(hints, getClass().getClassLoader());
RuntimeHints hints = ContainerConnectionDetailsFactoryHints.getRegisteredHints(getClass().getClassLoader());
assertThat(RuntimeHintsPredicates.reflection().onType(AuthToken.class)).accepts(hints);
}

View File

@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactoryHints;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,8 +34,7 @@ class MariaDbR2dbcContainerConnectionDetailsFactoryTests {
@Test
void shouldRegisterHints() {
RuntimeHints hints = new RuntimeHints();
new MariaDbR2dbcContainerConnectionDetailsFactory().registerHints(hints, getClass().getClassLoader());
RuntimeHints hints = ContainerConnectionDetailsFactoryHints.getRegisteredHints(getClass().getClassLoader());
assertThat(RuntimeHintsPredicates.reflection().onType(ConnectionFactoryOptions.class)).accepts(hints);
}

View File

@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactoryHints;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,8 +34,7 @@ class MySqlR2dbcContainerConnectionDetailsFactoryTests {
@Test
void shouldRegisterHints() {
RuntimeHints hints = new RuntimeHints();
new MySqlR2dbcContainerConnectionDetailsFactory().registerHints(hints, getClass().getClassLoader());
RuntimeHints hints = ContainerConnectionDetailsFactoryHints.getRegisteredHints(getClass().getClassLoader());
assertThat(RuntimeHintsPredicates.reflection().onType(ConnectionFactoryOptions.class)).accepts(hints);
}

View File

@@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration;
import org.springframework.boot.jdbc.DatabaseDriver;
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactoryHints;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.boot.testsupport.junit.DisabledOnOs;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
@@ -72,8 +73,7 @@ class OracleR2dbcContainerConnectionDetailsFactoryTests {
@Test
void shouldRegisterHints() {
RuntimeHints hints = new RuntimeHints();
new OracleR2dbcContainerConnectionDetailsFactory().registerHints(hints, getClass().getClassLoader());
RuntimeHints hints = ContainerConnectionDetailsFactoryHints.getRegisteredHints(getClass().getClassLoader());
assertThat(RuntimeHintsPredicates.reflection().onType(ConnectionFactoryOptions.class)).accepts(hints);
}

View File

@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactoryHints;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,8 +34,7 @@ class PostgresR2dbcContainerConnectionDetailsFactoryTests {
@Test
void shouldRegisterHints() {
RuntimeHints hints = new RuntimeHints();
new PostgresR2dbcContainerConnectionDetailsFactory().registerHints(hints, getClass().getClassLoader());
RuntimeHints hints = ContainerConnectionDetailsFactoryHints.getRegisteredHints(getClass().getClassLoader());
assertThat(RuntimeHintsPredicates.reflection().onType(ConnectionFactoryOptions.class)).accepts(hints);
}

View File

@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactoryHints;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,8 +34,7 @@ class SqlServerR2dbcContainerConnectionDetailsFactoryTests {
@Test
void shouldRegisterHints() {
RuntimeHints hints = new RuntimeHints();
new SqlServerR2dbcContainerConnectionDetailsFactory().registerHints(hints, getClass().getClassLoader());
RuntimeHints hints = ContainerConnectionDetailsFactoryHints.getRegisteredHints(getClass().getClassLoader());
assertThat(RuntimeHintsPredicates.reflection().onType(ConnectionFactoryOptions.class)).accepts(hints);
}

View File

@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinAutoConfiguration;
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactoryHints;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,8 +34,7 @@ class ZipkinContainerConnectionDetailsFactoryTests {
@Test
void shouldRegisterHints() {
RuntimeHints hints = new RuntimeHints();
new ZipkinContainerConnectionDetailsFactory().registerHints(hints, getClass().getClassLoader());
RuntimeHints hints = ContainerConnectionDetailsFactoryHints.getRegisteredHints(getClass().getClassLoader());
assertThat(RuntimeHintsPredicates.reflection().onType(ZipkinAutoConfiguration.class)).accepts(hints);
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.testcontainers.service.connection.zipkin;
import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactoryHints;
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link ZipkinContainerConnectionDetailsFactory}.
*
* @author Moritz Halbritter
*/
@ClassPathExclusions("spring-boot-actuator-*")
class ZipkinContainerConnectionDetailsFactoryWithoutActuatorTests {
@Test
void shouldRegisterHints() {
RuntimeHints hints = ContainerConnectionDetailsFactoryHints.getRegisteredHints(getClass().getClassLoader());
assertThat(hints).isNotNull();
}
}