Merge branch '3.4.x'

This commit is contained in:
Moritz Halbritter
2025-03-19 09:51:02 +01:00
5 changed files with 14 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -20,13 +20,11 @@ import java.sql.Driver;
import java.time.Duration;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.condition.OS;
import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.DockerComposeTest;
import org.springframework.boot.jdbc.DatabaseDriver;
import org.springframework.boot.testsupport.container.TestImage;
import org.springframework.boot.testsupport.junit.DisabledOnOs;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.SimpleDriverDataSource;
import org.springframework.util.ClassUtils;
@@ -38,8 +36,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Andy Wilkinson
*/
@DisabledOnOs(os = { OS.LINUX, OS.MAC }, architecture = "aarch64",
disabledReason = "The Oracle image has no ARM support")
class OracleFreeJdbcDockerComposeConnectionDetailsFactoryIntegrationTests {
@SuppressWarnings("unchecked")

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -21,13 +21,11 @@ import java.time.Duration;
import io.r2dbc.spi.ConnectionFactories;
import io.r2dbc.spi.ConnectionFactoryOptions;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.condition.OS;
import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.DockerComposeTest;
import org.springframework.boot.jdbc.DatabaseDriver;
import org.springframework.boot.testsupport.container.TestImage;
import org.springframework.boot.testsupport.junit.DisabledOnOs;
import org.springframework.r2dbc.core.DatabaseClient;
import static org.assertj.core.api.Assertions.assertThat;
@@ -37,8 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Andy Wilkinson
*/
@DisabledOnOs(os = { OS.LINUX, OS.MAC }, architecture = "aarch64",
disabledReason = "The Oracle image has no ARM support")
class OracleFreeR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests {
@DockerComposeTest(composeFile = "oracle-compose.yaml", image = TestImage.ORACLE_FREE)

View File

@@ -17,6 +17,7 @@
package org.springframework.boot.docker.compose.service.connection.test;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.LinkedHashMap;
@@ -63,9 +64,9 @@ class DockerComposeTestExtension implements BeforeTestExecutionCallback, AfterTe
Path workspace = Files.createTempDirectory("DockerComposeTestExtension-");
store.put(STORE_KEY_WORKSPACE, workspace);
try {
Path transformedComposeFile = prepareComposeFile(workspace, context);
Path composeFile = prepareComposeFile(workspace, context);
copyAdditionalResources(workspace, context);
SpringApplication application = prepareApplication(transformedComposeFile);
SpringApplication application = prepareApplication(composeFile);
store.put(STORE_KEY_APPLICATION_CONTEXT, application.run());
}
catch (Exception ex) {
@@ -84,11 +85,11 @@ class DockerComposeTestExtension implements BeforeTestExecutionCallback, AfterTe
private Path transformedComposeFile(Path workspace, Resource composeFileResource, TestImage image) {
try {
Path composeFile = composeFileResource.getFile().toPath();
String transformedContent = Files.readString(composeFile).replace("{imageName}", image.toString());
Path transformedComposeFile = workspace.resolve("compose.yaml");
Files.writeString(transformedComposeFile, transformedContent);
return transformedComposeFile;
String template = composeFileResource.getContentAsString(StandardCharsets.UTF_8);
String content = template.replace("{imageName}", image.toString());
Path composeFile = workspace.resolve("compose.yaml");
Files.writeString(composeFile, content);
return composeFile;
}
catch (IOException ex) {
fail("Error transforming Docker compose file '" + composeFileResource + "': " + ex.getMessage(), ex);
@@ -114,11 +115,11 @@ class DockerComposeTestExtension implements BeforeTestExecutionCallback, AfterTe
}
}
private SpringApplication prepareApplication(Path transformedComposeFile) {
private SpringApplication prepareApplication(Path composeFile) {
SpringApplication application = new SpringApplication(Config.class);
Map<String, Object> properties = new LinkedHashMap<>();
properties.put("spring.docker.compose.skip.in-tests", "false");
properties.put("spring.docker.compose.file", transformedComposeFile);
properties.put("spring.docker.compose.file", composeFile);
properties.put("spring.docker.compose.stop.command", "down");
application.setDefaultProperties(properties);
return application;