Skip to content

Commit 6567609

Browse files
committed
Merge branch '3.3.x' into 3.4.x
2 parents a4a88d9 + 80b6c59 commit 6567609

File tree

5 files changed

+30
-38
lines changed

5 files changed

+30
-38
lines changed

spring-boot-project/spring-boot-docker-compose/src/dockerTest/java/org/springframework/boot/docker/compose/service/connection/oracle/OracleFreeJdbcDockerComposeConnectionDetailsFactoryIntegrationTests.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,13 +20,11 @@
2020
import java.time.Duration;
2121

2222
import org.awaitility.Awaitility;
23-
import org.junit.jupiter.api.condition.OS;
2423

2524
import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
2625
import org.springframework.boot.docker.compose.service.connection.test.DockerComposeTest;
2726
import org.springframework.boot.jdbc.DatabaseDriver;
2827
import org.springframework.boot.testsupport.container.TestImage;
29-
import org.springframework.boot.testsupport.junit.DisabledOnOs;
3028
import org.springframework.jdbc.core.JdbcTemplate;
3129
import org.springframework.jdbc.datasource.SimpleDriverDataSource;
3230
import org.springframework.util.ClassUtils;
@@ -38,8 +36,6 @@
3836
*
3937
* @author Andy Wilkinson
4038
*/
41-
@DisabledOnOs(os = { OS.LINUX, OS.MAC }, architecture = "aarch64",
42-
disabledReason = "The Oracle image has no ARM support")
4339
class OracleFreeJdbcDockerComposeConnectionDetailsFactoryIntegrationTests {
4440

4541
@SuppressWarnings("unchecked")

spring-boot-project/spring-boot-docker-compose/src/dockerTest/java/org/springframework/boot/docker/compose/service/connection/oracle/OracleFreeR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
2121
import io.r2dbc.spi.ConnectionFactories;
2222
import io.r2dbc.spi.ConnectionFactoryOptions;
2323
import org.awaitility.Awaitility;
24-
import org.junit.jupiter.api.condition.OS;
2524

2625
import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
2726
import org.springframework.boot.docker.compose.service.connection.test.DockerComposeTest;
2827
import org.springframework.boot.jdbc.DatabaseDriver;
2928
import org.springframework.boot.testsupport.container.TestImage;
30-
import org.springframework.boot.testsupport.junit.DisabledOnOs;
3129
import org.springframework.r2dbc.core.DatabaseClient;
3230

3331
import static org.assertj.core.api.Assertions.assertThat;
@@ -37,8 +35,6 @@
3735
*
3836
* @author Andy Wilkinson
3937
*/
40-
@DisabledOnOs(os = { OS.LINUX, OS.MAC }, architecture = "aarch64",
41-
disabledReason = "The Oracle image has no ARM support")
4238
class OracleFreeR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests {
4339

4440
@DockerComposeTest(composeFile = "oracle-compose.yaml", image = TestImage.ORACLE_FREE)

spring-boot-project/spring-boot-docker-compose/src/dockerTest/java/org/springframework/boot/docker/compose/service/connection/test/DockerComposeTestExtension.java

+26-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717
package org.springframework.boot.docker.compose.service.connection.test;
1818

1919
import java.io.IOException;
20+
import java.nio.charset.StandardCharsets;
2021
import java.nio.file.Files;
2122
import java.nio.file.Path;
2223
import java.util.LinkedHashMap;
@@ -39,29 +40,32 @@
3940
import org.springframework.context.annotation.Configuration;
4041
import org.springframework.core.io.ClassPathResource;
4142
import org.springframework.core.io.Resource;
43+
import org.springframework.util.FileSystemUtils;
4244

4345
import static org.assertj.core.api.Assertions.fail;
4446

4547
/**
4648
* {@link Extension} for {@link DockerComposeTest @DockerComposeTest}.
4749
*
4850
* @author Andy Wilkinson
51+
* @author Moritz Halbritter
4952
*/
5053
class DockerComposeTestExtension implements BeforeTestExecutionCallback, AfterTestExecutionCallback, ParameterResolver {
5154

5255
private static final Namespace NAMESPACE = Namespace.create(DockerComposeTestExtension.class);
5356

54-
private static final String STORE_KEY_COMPOSE_FILE = "compose-file";
57+
private static final String STORE_KEY_WORKSPACE = "workspace";
5558

5659
private static final String STORE_KEY_APPLICATION_CONTEXT = "application-context";
5760

5861
@Override
5962
public void beforeTestExecution(ExtensionContext context) throws Exception {
60-
Path transformedComposeFile = prepareComposeFile(context);
6163
Store store = context.getStore(NAMESPACE);
62-
store.put(STORE_KEY_COMPOSE_FILE, transformedComposeFile);
64+
Path workspace = Files.createTempDirectory("DockerComposeTestExtension-");
65+
store.put(STORE_KEY_WORKSPACE, workspace);
6366
try {
64-
SpringApplication application = prepareApplication(transformedComposeFile);
67+
Path composeFile = prepareComposeFile(workspace, context);
68+
SpringApplication application = prepareApplication(composeFile);
6569
store.put(STORE_KEY_APPLICATION_CONTEXT, application.run());
6670
}
6771
catch (Exception ex) {
@@ -70,33 +74,33 @@ public void beforeTestExecution(ExtensionContext context) throws Exception {
7074
}
7175
}
7276

73-
private Path prepareComposeFile(ExtensionContext context) {
77+
private Path prepareComposeFile(Path workspace, ExtensionContext context) {
7478
DockerComposeTest dockerComposeTest = context.getRequiredTestMethod().getAnnotation(DockerComposeTest.class);
7579
TestImage image = dockerComposeTest.image();
7680
Resource composeResource = new ClassPathResource(dockerComposeTest.composeFile(),
7781
context.getRequiredTestClass());
78-
return transformedComposeFile(composeResource, image);
82+
return transformedComposeFile(workspace, composeResource, image);
7983
}
8084

81-
private Path transformedComposeFile(Resource composeFileResource, TestImage image) {
85+
private Path transformedComposeFile(Path workspace, Resource composeFileResource, TestImage image) {
8286
try {
83-
Path composeFile = composeFileResource.getFile().toPath();
84-
Path transformedComposeFile = Files.createTempFile("", "-" + composeFile.getFileName().toString());
85-
String transformedContent = Files.readString(composeFile).replace("{imageName}", image.toString());
86-
Files.writeString(transformedComposeFile, transformedContent);
87-
return transformedComposeFile;
87+
String template = composeFileResource.getContentAsString(StandardCharsets.UTF_8);
88+
String content = template.replace("{imageName}", image.toString());
89+
Path composeFile = workspace.resolve("compose.yaml");
90+
Files.writeString(composeFile, content);
91+
return composeFile;
8892
}
8993
catch (IOException ex) {
90-
fail("Error transforming Docker compose file '" + composeFileResource + "': " + ex.getMessage());
94+
fail("Error transforming Docker compose file '" + composeFileResource + "': " + ex.getMessage(), ex);
95+
return null;
9196
}
92-
return null;
9397
}
9498

95-
private SpringApplication prepareApplication(Path transformedComposeFile) {
99+
private SpringApplication prepareApplication(Path composeFile) {
96100
SpringApplication application = new SpringApplication(Config.class);
97101
Map<String, Object> properties = new LinkedHashMap<>();
98102
properties.put("spring.docker.compose.skip.in-tests", "false");
99-
properties.put("spring.docker.compose.file", transformedComposeFile);
103+
properties.put("spring.docker.compose.file", composeFile);
100104
properties.put("spring.docker.compose.stop.command", "down");
101105
application.setDefaultProperties(properties);
102106
return application;
@@ -110,18 +114,18 @@ public void afterTestExecution(ExtensionContext context) throws Exception {
110114
private void cleanUp(ExtensionContext context) throws Exception {
111115
Store store = context.getStore(NAMESPACE);
112116
runShutdownHandlers();
113-
deleteComposeFile(store);
117+
deleteWorkspace(store);
114118
}
115119

116120
private void runShutdownHandlers() {
117121
SpringApplicationShutdownHandlers shutdownHandlers = SpringApplication.getShutdownHandlers();
118122
((Runnable) shutdownHandlers).run();
119123
}
120124

121-
private void deleteComposeFile(Store store) throws IOException {
122-
Path composeFile = store.get(STORE_KEY_COMPOSE_FILE, Path.class);
123-
if (composeFile != null) {
124-
Files.delete(composeFile);
125+
private void deleteWorkspace(Store store) throws IOException {
126+
Path workspace = (Path) store.get(STORE_KEY_WORKSPACE);
127+
if (workspace != null) {
128+
FileSystemUtils.deleteRecursively(workspace);
125129
}
126130
}
127131

spring-boot-project/spring-boot-testcontainers/src/dockerTest/java/org/springframework/boot/testcontainers/service/connection/r2dbc/OracleFreeR2dbcContainerConnectionDetailsFactoryIntegrationTests.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
2020

2121
import io.r2dbc.spi.ConnectionFactory;
2222
import org.junit.jupiter.api.Test;
23-
import org.junit.jupiter.api.condition.OS;
2423
import org.testcontainers.junit.jupiter.Container;
2524
import org.testcontainers.junit.jupiter.Testcontainers;
2625
import org.testcontainers.oracle.OracleContainer;
@@ -31,7 +30,6 @@
3130
import org.springframework.boot.jdbc.DatabaseDriver;
3231
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
3332
import org.springframework.boot.testsupport.container.TestImage;
34-
import org.springframework.boot.testsupport.junit.DisabledOnOs;
3533
import org.springframework.context.annotation.Configuration;
3634
import org.springframework.r2dbc.core.DatabaseClient;
3735
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
@@ -45,8 +43,6 @@
4543
*/
4644
@SpringJUnitConfig
4745
@Testcontainers(disabledWithoutDocker = true)
48-
@DisabledOnOs(os = { OS.LINUX, OS.MAC }, architecture = "aarch64",
49-
disabledReason = "The Oracle image has no ARM support")
5046
class OracleFreeR2dbcContainerConnectionDetailsFactoryIntegrationTests {
5147

5248
@Container

spring-boot-project/spring-boot-tools/spring-boot-test-support-docker/src/main/java/org/springframework/boot/testsupport/container/TestImage.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public enum TestImage {
182182
/**
183183
* A container image suitable for testing Oracle Free.
184184
*/
185-
ORACLE_FREE("gvenzl/oracle-free", "23.3-slim", () -> org.testcontainers.oracle.OracleContainer.class,
185+
ORACLE_FREE("gvenzl/oracle-free", "23.6-slim", () -> org.testcontainers.oracle.OracleContainer.class,
186186
(container) -> ((org.testcontainers.oracle.OracleContainer) container)
187187
.withStartupTimeout(Duration.ofMinutes(2))),
188188

0 commit comments

Comments
 (0)