Merge branch '3.3.x'

Closes gh-43270
This commit is contained in:
Andy Wilkinson 2024-11-22 15:40:51 +00:00
commit 32433e84f3
28 changed files with 184 additions and 129 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -54,6 +54,7 @@ class CassandraHealthContributorAutoConfigurationTests {
}
@Test
@SuppressWarnings("resource")
void runWithCqlSessionAndSpringDataAbsentShouldCreateDriverIndicator() {
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
.withClassLoader(new FilteredClassLoader("org.springframework.data"))

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -67,6 +67,7 @@ class CassandraReactiveHealthContributorAutoConfigurationTests {
}
@Test
@SuppressWarnings("resource")
void runWithCqlSessionAndSpringDataAbsentShouldCreateDriverIndicator() {
this.contextRunner.withBean(CqlSession.class, () -> mock(CqlSession.class))
.withClassLoader(new FilteredClassLoader("org.springframework.data"))

View File

@ -198,6 +198,7 @@ class ZipkinConfigurationsSenderConfigurationTests {
}
@Test
@SuppressWarnings("resource")
void shouldUseCustomHttpEndpointSupplierFactoryWhenReactive() {
this.reactiveContextRunner.withUserConfiguration(WebClientConfiguration.class)
.withClassLoader(new FilteredClassLoader(URLConnectionSender.class))
@ -207,6 +208,7 @@ class ZipkinConfigurationsSenderConfigurationTests {
}
@Test
@SuppressWarnings("resource")
void shouldUseCustomHttpEndpointSupplierFactoryWhenRestTemplate() {
this.contextRunner.withUserConfiguration(RestTemplateConfiguration.class)
.withClassLoader(new FilteredClassLoader(URLConnectionSender.class, WebClient.class))

View File

@ -102,6 +102,8 @@ class PulsarContainerFactoryCustomizersTests {
/**
* Test customizer that will match all {@link PulsarListenerContainerFactory}.
*
* @param <T> the container factory type
*/
static class TestCustomizer<T extends PulsarContainerFactory<?, ?>> implements PulsarContainerFactoryCustomizer<T> {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -51,32 +51,35 @@ abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
@Test
void singleManuallyConfiguredDataSourceIsNotClosed() throws Exception {
ConfigurableApplicationContext context = getContext(() -> createContext(SingleDataSourceConfiguration.class));
DataSource dataSource = context.getBean(DataSource.class);
Statement statement = configureDataSourceBehavior(dataSource);
then(statement).should(never()).execute("SHUTDOWN");
}
@Test
void multipleDataSourcesAreIgnored() throws Exception {
ConfigurableApplicationContext context = getContext(
() -> createContext(MultipleDataSourcesConfiguration.class));
Collection<DataSource> dataSources = context.getBeansOfType(DataSource.class).values();
for (DataSource dataSource : dataSources) {
try (ConfigurableApplicationContext context = getContext(
() -> createContext(SingleDataSourceConfiguration.class))) {
DataSource dataSource = context.getBean(DataSource.class);
Statement statement = configureDataSourceBehavior(dataSource);
then(statement).should(never()).execute("SHUTDOWN");
}
}
@Test
void multipleDataSourcesAreIgnored() throws Exception {
try (ConfigurableApplicationContext context = getContext(
() -> createContext(MultipleDataSourcesConfiguration.class))) {
Collection<DataSource> dataSources = context.getBeansOfType(DataSource.class).values();
for (DataSource dataSource : dataSources) {
Statement statement = configureDataSourceBehavior(dataSource);
then(statement).should(never()).execute("SHUTDOWN");
}
}
}
@Test
void emptyFactoryMethodMetadataIgnored() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
DataSource dataSource = mock(DataSource.class);
AnnotatedGenericBeanDefinition beanDefinition = new AnnotatedGenericBeanDefinition(dataSource.getClass());
context.registerBeanDefinition("dataSource", beanDefinition);
context.register(DevToolsDataSourceAutoConfiguration.class);
context.refresh();
context.close();
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
DataSource dataSource = mock(DataSource.class);
AnnotatedGenericBeanDefinition beanDefinition = new AnnotatedGenericBeanDefinition(dataSource.getClass());
context.registerBeanDefinition("dataSource", beanDefinition);
context.register(DevToolsDataSourceAutoConfiguration.class);
context.refresh();
}
}
protected final Statement configureDataSourceBehavior(DataSource dataSource) throws SQLException {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -61,88 +61,99 @@ class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDat
@Test
void autoConfiguredInMemoryDataSourceIsShutdown() throws Exception {
ConfigurableApplicationContext context = getContext(
() -> createContext(DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should().execute("SHUTDOWN");
try (ConfigurableApplicationContext context = getContext(
() -> createContext(DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class))) {
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should().execute("SHUTDOWN");
}
}
@Test
void autoConfiguredExternalDataSourceIsNotShutdown() throws Exception {
ConfigurableApplicationContext context = getContext(() -> createContext("org.postgresql.Driver",
DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should(never()).execute("SHUTDOWN");
try (ConfigurableApplicationContext context = getContext(() -> createContext("org.postgresql.Driver",
DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class))) {
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should(never()).execute("SHUTDOWN");
}
}
@Test
void h2ServerIsNotShutdown() throws Exception {
ConfigurableApplicationContext context = getContext(() -> createContext("org.h2.Driver",
"jdbc:h2:hsql://localhost", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should(never()).execute("SHUTDOWN");
try (ConfigurableApplicationContext context = getContext(() -> createContext("org.h2.Driver",
"jdbc:h2:hsql://localhost", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class))) {
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should(never()).execute("SHUTDOWN");
}
}
@Test
void inMemoryH2IsShutdown() throws Exception {
ConfigurableApplicationContext context = getContext(() -> createContext("org.h2.Driver", "jdbc:h2:mem:test",
DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should().execute("SHUTDOWN");
try (ConfigurableApplicationContext context = getContext(() -> createContext("org.h2.Driver",
"jdbc:h2:mem:test", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class))) {
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should().execute("SHUTDOWN");
}
}
@Test
void hsqlServerIsNotShutdown() throws Exception {
ConfigurableApplicationContext context = getContext(() -> createContext("org.hsqldb.jdbcDriver",
"jdbc:hsqldb:hsql://localhost", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should(never()).execute("SHUTDOWN");
try (ConfigurableApplicationContext context = getContext(() -> createContext("org.hsqldb.jdbcDriver",
"jdbc:hsqldb:hsql://localhost", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class))) {
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should(never()).execute("SHUTDOWN");
}
}
@Test
void inMemoryHsqlIsShutdown() throws Exception {
ConfigurableApplicationContext context = getContext(() -> createContext("org.hsqldb.jdbcDriver",
"jdbc:hsqldb:mem:test", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should().execute("SHUTDOWN");
try (ConfigurableApplicationContext context = getContext(() -> createContext("org.hsqldb.jdbcDriver",
"jdbc:hsqldb:mem:test", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class))) {
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should().execute("SHUTDOWN");
}
}
@Test
void derbyClientIsNotShutdown() throws Exception {
ConfigurableApplicationContext context = getContext(() -> createContext("org.apache.derby.jdbc.ClientDriver",
"jdbc:derby://localhost", DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should(never()).execute("SHUTDOWN");
try (ConfigurableApplicationContext context = getContext(
() -> createContext("org.apache.derby.jdbc.ClientDriver", "jdbc:derby://localhost",
DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class))) {
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.class));
context.close();
then(statement).should(never()).execute("SHUTDOWN");
}
}
@Test
void inMemoryDerbyIsShutdown() throws Exception {
ConfigurableApplicationContext context = getContext(
try (ConfigurableApplicationContext context = getContext(
() -> createContext("org.apache.derby.jdbc.EmbeddedDriver", "jdbc:derby:memory:test;create=true",
DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class));
HikariDataSource dataSource = context.getBean(HikariDataSource.class);
JdbcTemplate jdbc = new JdbcTemplate(dataSource);
jdbc.execute("SELECT 1 FROM SYSIBM.SYSDUMMY1");
HikariPoolMXBean pool = dataSource.getHikariPoolMXBean();
// Prevent a race between Hikari's initialization and Derby shutdown
Awaitility.await()
.atMost(Duration.ofSeconds(30))
.until(pool::getIdleConnections, (idle) -> idle == dataSource.getMinimumIdle());
context.close();
// Connect should fail as DB no longer exists
assertThatExceptionOfType(SQLException.class)
.isThrownBy(() -> new EmbeddedDriver().connect("jdbc:derby:memory:test", new Properties()))
.satisfies((ex) -> assertThat(ex.getSQLState()).isEqualTo("XJ004"));
// Shut Derby down fully so that it closes its log file
assertThatExceptionOfType(SQLException.class)
.isThrownBy(() -> new EmbeddedDriver().connect("jdbc:derby:;shutdown=true", new Properties()));
DataSourceAutoConfiguration.class, DataSourceSpyConfiguration.class))) {
HikariDataSource dataSource = context.getBean(HikariDataSource.class);
JdbcTemplate jdbc = new JdbcTemplate(dataSource);
jdbc.execute("SELECT 1 FROM SYSIBM.SYSDUMMY1");
HikariPoolMXBean pool = dataSource.getHikariPoolMXBean();
// Prevent a race between Hikari's initialization and Derby shutdown
Awaitility.await()
.atMost(Duration.ofSeconds(30))
.until(pool::getIdleConnections, (idle) -> idle == dataSource.getMinimumIdle());
context.close();
// Connect should fail as DB no longer exists
assertThatExceptionOfType(SQLException.class).isThrownBy(() -> connect("jdbc:derby:memory:test"))
.satisfies((ex) -> assertThat(ex.getSQLState()).isEqualTo("XJ004"));
// Shut Derby down fully so that it closes its log file
assertThatExceptionOfType(SQLException.class).isThrownBy(() -> connect("jdbc:derby:;shutdown=true"));
}
}
private void connect(String jdbcUrl) throws SQLException {
new EmbeddedDriver().connect(jdbcUrl, new Properties()).close();
}
}

View File

@ -71,28 +71,32 @@ class DevToolsR2dbcAutoConfigurationTests {
@Test
void nonEmbeddedConnectionFactoryIsNotShutdown() throws Exception {
ConfigurableApplicationContext context = getContext(() -> createContext("r2dbc:h2:file:///testdb"));
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
context.close();
assertThat(shutdowns).doesNotContain(connectionFactory);
try (ConfigurableApplicationContext context = getContext(() -> createContext("r2dbc:h2:file:///testdb"))) {
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
context.close();
assertThat(shutdowns).doesNotContain(connectionFactory);
}
}
@Test
void singleManuallyConfiguredConnectionFactoryIsNotClosed() throws Exception {
ConfigurableApplicationContext context = getContext(
() -> createContext(SingleConnectionFactoryConfiguration.class));
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
context.close();
assertThat(shutdowns).doesNotContain(connectionFactory);
try (ConfigurableApplicationContext context = getContext(
() -> createContext(SingleConnectionFactoryConfiguration.class))) {
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
context.close();
assertThat(shutdowns).doesNotContain(connectionFactory);
}
}
@Test
void multipleConnectionFactoriesAreIgnored() throws Exception {
ConfigurableApplicationContext context = getContext(
() -> createContext(MultipleConnectionFactoriesConfiguration.class));
Collection<ConnectionFactory> connectionFactory = context.getBeansOfType(ConnectionFactory.class).values();
context.close();
assertThat(shutdowns).doesNotContainAnyElementsOf(connectionFactory);
try (ConfigurableApplicationContext context = getContext(
() -> createContext(MultipleConnectionFactoriesConfiguration.class))) {
Collection<ConnectionFactory> connectionFactory = context.getBeansOfType(ConnectionFactory.class)
.values();
context.close();
assertThat(shutdowns).doesNotContainAnyElementsOf(connectionFactory);
}
}
@Test

View File

@ -403,7 +403,7 @@ public abstract class AbstractApplicationContextRunner<SELF extends AbstractAppl
}
}
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "resource" })
private A createAssertableContext(boolean refresh) {
ResolvableType resolvableType = ResolvableType.forClass(AbstractApplicationContextRunner.class, getClass());
Class<A> assertType = (Class<A>) resolvableType.resolveGeneric(1);

View File

@ -33,6 +33,7 @@ import static org.mockito.Mockito.withSettings;
class AssertableApplicationContextTests {
@Test
@SuppressWarnings("resource")
void getShouldReturnProxy() {
AssertableApplicationContext context = AssertableApplicationContext
.get(() -> mock(ConfigurableApplicationContext.class));
@ -41,12 +42,13 @@ class AssertableApplicationContextTests {
@Test
void getWhenHasAdditionalInterfaceShouldReturnProxy() {
AssertableApplicationContext context = AssertableApplicationContext.get(
try (AssertableApplicationContext context = AssertableApplicationContext.get(
() -> mock(ConfigurableApplicationContext.class,
withSettings().extraInterfaces(AdditionalContextInterface.class)),
AdditionalContextInterface.class);
assertThat(context).isInstanceOf(ConfigurableApplicationContext.class)
.isInstanceOf(AdditionalContextInterface.class);
AdditionalContextInterface.class)) {
assertThat(context).isInstanceOf(ConfigurableApplicationContext.class)
.isInstanceOf(AdditionalContextInterface.class);
}
}
}

View File

@ -33,6 +33,7 @@ import static org.mockito.Mockito.withSettings;
class AssertableReactiveWebApplicationContextTests {
@Test
@SuppressWarnings("resource")
void getShouldReturnProxy() {
AssertableReactiveWebApplicationContext context = AssertableReactiveWebApplicationContext
.get(() -> mock(ConfigurableReactiveWebApplicationContext.class));
@ -41,12 +42,13 @@ class AssertableReactiveWebApplicationContextTests {
@Test
void getWhenHasAdditionalInterfaceShouldReturnProxy() {
AssertableReactiveWebApplicationContext context = AssertableReactiveWebApplicationContext.get(
try (AssertableReactiveWebApplicationContext context = AssertableReactiveWebApplicationContext.get(
() -> mock(ConfigurableReactiveWebApplicationContext.class,
withSettings().extraInterfaces(AdditionalContextInterface.class)),
AdditionalContextInterface.class);
assertThat(context).isInstanceOf(ConfigurableReactiveWebApplicationContext.class)
.isInstanceOf(AdditionalContextInterface.class);
AdditionalContextInterface.class)) {
assertThat(context).isInstanceOf(ConfigurableReactiveWebApplicationContext.class)
.isInstanceOf(AdditionalContextInterface.class);
}
}
}

View File

@ -33,6 +33,7 @@ import static org.mockito.Mockito.withSettings;
class AssertableWebApplicationContextTests {
@Test
@SuppressWarnings("resource")
void getShouldReturnProxy() {
AssertableWebApplicationContext context = AssertableWebApplicationContext
.get(() -> mock(ConfigurableWebApplicationContext.class));
@ -41,12 +42,13 @@ class AssertableWebApplicationContextTests {
@Test
void getWhenHasAdditionalInterfaceShouldReturnProxy() {
ConfigurableWebApplicationContext context = AssertableWebApplicationContext.get(
try (ConfigurableWebApplicationContext context = AssertableWebApplicationContext.get(
() -> mock(ConfigurableWebApplicationContext.class,
withSettings().extraInterfaces(AdditionalContextInterface.class)),
AdditionalContextInterface.class);
assertThat(context).isInstanceOf(ConfigurableWebApplicationContext.class)
.isInstanceOf(AdditionalContextInterface.class);
AdditionalContextInterface.class)) {
assertThat(context).isInstanceOf(ConfigurableWebApplicationContext.class)
.isInstanceOf(AdditionalContextInterface.class);
}
}
}

View File

@ -600,7 +600,7 @@ class DockerApiTests {
}
@Test
void createWithPlatformAndInsufficientApiVersionThrowsException() throws Exception {
void createWithPlatformAndInsufficientApiVersionThrowsException() {
ImageReference imageReference = ImageReference.of("ubuntu:bionic");
ContainerConfig config = ContainerConfig.of(imageReference, (update) -> update.withCommand("/bin/bash"));
ImagePlatform platform = ImagePlatform.of("linux/arm64/v1");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -17,8 +17,10 @@
package org.springframework.boot.buildpack.platform.json;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;
@ -45,8 +47,13 @@ public abstract class AbstractJsonTests {
}
protected final String getContentAsString(String name) {
return new BufferedReader(new InputStreamReader(getContent(name), StandardCharsets.UTF_8)).lines()
.collect(Collectors.joining("\n"));
try (InputStream in = getContent(name)) {
return new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)).lines()
.collect(Collectors.joining("\n"));
}
catch (IOException ex) {
throw new UncheckedIOException(ex);
}
}
}

View File

@ -348,8 +348,11 @@ class BootZipCopyAction implements CopyAction {
private void writeJarModeLibrary(String location, JarModeLibrary library) throws IOException {
String name = location + library.getName();
writeEntry(name, ZipEntryContentWriter.fromInputStream(library.openStream()), false,
(entry) -> prepareStoredEntry(library.openStream(), entry));
writeEntry(name, ZipEntryContentWriter.fromInputStream(library.openStream()), false, (entry) -> {
try (InputStream in = library.openStream()) {
prepareStoredEntry(library.openStream(), entry);
}
});
if (BootZipCopyAction.this.layerResolver != null) {
Layer layer = BootZipCopyAction.this.layerResolver.getLayer(library);
this.layerIndex.add(layer, name);

View File

@ -122,9 +122,10 @@ class NativeImagePluginActionIntegrationTests {
BuildResult result = this.gradleBuild.build("bootJar");
assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
JarFile jarFile = new JarFile(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar"));
Manifest manifest = jarFile.getManifest();
assertThat(manifest.getMainAttributes().getValue("Spring-Boot-Native-Processed")).isEqualTo("true");
try (JarFile jarFile = new JarFile(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar"))) {
Manifest manifest = jarFile.getManifest();
assertThat(manifest.getMainAttributes().getValue("Spring-Boot-Native-Processed")).isEqualTo("true");
}
}
private String projectPath(String path) {

View File

@ -84,6 +84,7 @@ public class NestedFileSystemProvider extends FileSystemProvider {
}
@Override
@SuppressWarnings("resource")
public Path getPath(URI uri) {
NestedLocation location = NestedLocation.fromUri(uri);
synchronized (this.fileSystems) {

View File

@ -475,7 +475,6 @@ class BuildImageTests extends AbstractArchiveIntegrationTests {
@TestTemplate
void whenBuildImageIsInvokedWithCreatedDate(MavenBuild mavenBuild) {
String testBuildId = randomString();
mavenBuild.project("dockerTest", "build-image-created-date")
.goals("package")
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")

View File

@ -88,6 +88,7 @@ public enum TestImage {
* {@link org.testcontainers.containers.CassandraContainer}.
* @deprecated since 3.4.0 for removal in 3.6.0 in favor of {@link #CASSANDRA}
*/
@SuppressWarnings("deprecation")
@Deprecated(since = "3.4.0", forRemoval = true)
CASSANDRA_DEPRECATED("cassandra", "3.11.10", () -> org.testcontainers.containers.CassandraContainer.class,
(container) -> ((org.testcontainers.containers.CassandraContainer<?>) container)
@ -139,6 +140,7 @@ public enum TestImage {
* deprecated {@link org.testcontainers.containers.KafkaContainer}.
* @deprecated since 3.4.0 for removal in 3.6.0 in favor of {@link #CONFLUENT_KAFKA}
*/
@SuppressWarnings("deprecation")
@Deprecated(since = "3.4.0", forRemoval = true)
CONFLUENT_KAFKA_DEPRECATED("confluentinc/cp-kafka", "7.4.0",
() -> org.testcontainers.containers.KafkaContainer.class),

View File

@ -99,6 +99,7 @@ final class ModifiedClassPathClassLoader extends URLClassLoader {
return super.loadClass(name);
}
@SuppressWarnings("resource")
static ModifiedClassPathClassLoader get(Class<?> testClass, Method testMethod, List<Object> arguments) {
Set<AnnotatedElement> candidates = new LinkedHashSet<>();
candidates.add(testClass);

View File

@ -67,6 +67,7 @@ abstract class AbstractClientHttpRequestFactoriesTests<T extends ClientHttpReque
}
@Test
@SuppressWarnings("deprecation")
void getReturnsRequestFactoryOfExpectedType() {
ClientHttpRequestFactory requestFactory = ClientHttpRequestFactories
.get(ClientHttpRequestFactorySettings.DEFAULTS);
@ -74,6 +75,7 @@ abstract class AbstractClientHttpRequestFactoriesTests<T extends ClientHttpReque
}
@Test
@SuppressWarnings("deprecation")
void getOfGeneralTypeReturnsRequestFactoryOfExpectedType() {
ClientHttpRequestFactory requestFactory = ClientHttpRequestFactories.get(ClientHttpRequestFactory.class,
ClientHttpRequestFactorySettings.DEFAULTS);
@ -81,6 +83,7 @@ abstract class AbstractClientHttpRequestFactoriesTests<T extends ClientHttpReque
}
@Test
@SuppressWarnings("deprecation")
void getOfSpecificTypeReturnsRequestFactoryOfExpectedType() {
ClientHttpRequestFactory requestFactory = ClientHttpRequestFactories.get(this.requestFactoryType,
ClientHttpRequestFactorySettings.DEFAULTS);
@ -88,7 +91,7 @@ abstract class AbstractClientHttpRequestFactoriesTests<T extends ClientHttpReque
}
@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "deprecation", "unchecked" })
void getReturnsRequestFactoryWithConfiguredConnectTimeout() {
ClientHttpRequestFactory requestFactory = ClientHttpRequestFactories
.get(ClientHttpRequestFactorySettings.DEFAULTS.withConnectTimeout(Duration.ofSeconds(60)));
@ -96,7 +99,7 @@ abstract class AbstractClientHttpRequestFactoriesTests<T extends ClientHttpReque
}
@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "deprecation", "unchecked" })
void getReturnsRequestFactoryWithConfiguredReadTimeout() {
ClientHttpRequestFactory requestFactory = ClientHttpRequestFactories
.get(ClientHttpRequestFactorySettings.DEFAULTS.withReadTimeout(Duration.ofSeconds(120)));
@ -104,6 +107,7 @@ abstract class AbstractClientHttpRequestFactoriesTests<T extends ClientHttpReque
}
@Test
@SuppressWarnings("deprecation")
void shouldSetConnectTimeoutsWhenUsingReflective() {
Assumptions.assumeTrue(supportsSettingConnectTimeout());
ClientHttpRequestFactorySettings settings = ClientHttpRequestFactorySettings.DEFAULTS
@ -114,6 +118,7 @@ abstract class AbstractClientHttpRequestFactoriesTests<T extends ClientHttpReque
}
@Test
@SuppressWarnings("deprecation")
void shouldSetReadTimeoutsWhenUsingReflective() {
Assumptions.assumeTrue(supportsSettingReadTimeout());
ClientHttpRequestFactorySettings settings = ClientHttpRequestFactorySettings.DEFAULTS
@ -124,6 +129,7 @@ abstract class AbstractClientHttpRequestFactoriesTests<T extends ClientHttpReque
}
@ParameterizedTest
@SuppressWarnings("deprecation")
@ValueSource(strings = { "GET", "POST" })
void connectWithSslBundle(String httpMethod) throws Exception {
TomcatServletWebServerFactory webServerFactory = new TomcatServletWebServerFactory(0);

View File

@ -37,8 +37,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* Tests for {@link ClientHttpRequestFactories}.
*
* @author Andy Wilkinson
* @deprecated since 3.4.0 for removal in 3.6.0
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.4.0", forRemoval = true)
class ClientHttpRequestFactoriesTests {
@Test

View File

@ -29,8 +29,10 @@ import static org.mockito.Mockito.mock;
* Tests for {@link ClientHttpRequestFactorySettings}.
*
* @author Phillip Webb
* @deprecated since 3.4.0 for removal in 3.6.0
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.4.0", forRemoval = true)
class ClientHttpRequestFactorySettingsTests {
private static final Duration ONE_SECOND = Duration.ofSeconds(1);

View File

@ -570,19 +570,16 @@ public abstract class AbstractReactiveWebServerFactoryTests {
factory.setHttp2(http2);
this.webServer = factory.getWebServer(new EchoHandler());
this.webServer.start();
org.eclipse.jetty.client.HttpClient client = new org.eclipse.jetty.client.HttpClient(
new HttpClientTransportOverHTTP2(new HTTP2Client()));
client.start();
try {
try (org.eclipse.jetty.client.HttpClient client = new org.eclipse.jetty.client.HttpClient(
new HttpClientTransportOverHTTP2(new HTTP2Client()))) {
client.start();
ContentResponse response = client.POST("http://localhost:" + this.webServer.getPort())
.body(new StringRequestContent("text/plain", "Hello World"))
.send();
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
assertThat(response.getContentAsString()).isEqualTo("Hello World");
}
finally {
client.stop();
}
}
@Test

View File

@ -1288,17 +1288,13 @@ public abstract class AbstractServletWebServerFactoryTests {
factory.setHttp2(http2);
this.webServer = factory.getWebServer(exampleServletRegistration());
this.webServer.start();
org.eclipse.jetty.client.HttpClient client = new org.eclipse.jetty.client.HttpClient(
new HttpClientTransportOverHTTP2(new HTTP2Client()));
client.start();
try {
try (org.eclipse.jetty.client.HttpClient client = new org.eclipse.jetty.client.HttpClient(
new HttpClientTransportOverHTTP2(new HTTP2Client()))) {
client.start();
ContentResponse response = client.GET("http://localhost:" + this.webServer.getPort() + "/hello");
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
assertThat(response.getContentAsString()).isEqualTo("Hello World");
}
finally {
client.stop();
}
}
@Test

View File

@ -35,9 +35,11 @@ import static org.assertj.core.api.Assertions.assertThat;
* available and, therefore, Jetty's client is used instead.
*
* @author Stephane Nicoll
* @deprecated since 3.4.0 for removal in 3.6.0
*/
@ClassPathExclusions("httpclient5-*.jar")
@SuppressWarnings("removal")
@Deprecated(since = "3.4.0", forRemoval = true)
class HttpWebServiceMessageSenderBuilderJettyClientIntegrationTests {
private final HttpWebServiceMessageSenderBuilder builder = new HttpWebServiceMessageSenderBuilder();

View File

@ -36,9 +36,11 @@ import static org.assertj.core.api.Assertions.assertThat;
* predominant HTTP client.
*
* @author Andy Wilkinson
* @deprecated since 3.4.0 for removal in 3.6.0
*/
@ClassPathExclusions({ "httpclient5-*.jar", "jetty-client-*.jar" })
@SuppressWarnings("removal")
@Deprecated(since = "3.4.0", forRemoval = true)
class HttpWebServiceMessageSenderBuilderReactorClientIntegrationTests {
private final HttpWebServiceMessageSenderBuilder builder = new HttpWebServiceMessageSenderBuilder();

View File

@ -33,9 +33,11 @@ import static org.assertj.core.api.Assertions.assertThat;
* available
*
* @author Stephane Nicoll
* @deprecated since 3.4.0 for removal in 3.6.0
*/
@ClassPathExclusions({ "httpclient5-*.jar", "jetty-client-*.jar", "reactor-netty-http-*.jar" })
@SuppressWarnings("removal")
@Deprecated(since = "3.4.0", forRemoval = true)
class HttpWebServiceMessageSenderBuilderSimpleIntegrationTests {
private final HttpWebServiceMessageSenderBuilder builder = new HttpWebServiceMessageSenderBuilder();

View File

@ -33,8 +33,10 @@ import static org.mockito.Mockito.mock;
* Tests for {@link HttpWebServiceMessageSenderBuilder}.
*
* @author Stephane Nicoll
* @deprecated since 3.4.0 for removal in 3.6.0
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.4.0", forRemoval = true)
class HttpWebServiceMessageSenderBuilderTests {
@Test