Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;

import org.springframework.boot.buildpack.platform.docker.DockerApi;
import org.springframework.boot.buildpack.platform.docker.DockerApi.ImageApi;
Expand All @@ -62,6 +63,7 @@
* @author Andy Wilkinson
* @author Scott Frederick
* @author Rafael Ceccone
* @author Yanming Zhou
*/
@GradleCompatibility(configurationCache = true)
@DisabledIfDockerUnavailable
Expand Down Expand Up @@ -318,7 +320,7 @@ void buildsImageWithVolumeCaches() throws IOException {
@TestTemplate
@EnabledOnOs(value = OS.LINUX, disabledReason = "Works with Docker Engine on Linux but is not reliable with "
+ "Docker Desktop on other OSs")
void buildsImageWithBindCaches() throws IOException {
void buildsImageWithBindCaches(@TempDir Path tempDir) throws IOException {
writeMainClass();
writeLongNameResource();
BuildResult result = this.gradleBuild.build("bootBuildImage");
Expand All @@ -328,9 +330,8 @@ void buildsImageWithBindCaches() throws IOException {
assertThat(result.getOutput()).contains("---> Test Info buildpack building");
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
removeImages(projectName);
String tempDir = System.getProperty("java.io.tmpdir");
Path buildCachePath = Paths.get(tempDir, "junit-image-cache-" + projectName + "-build");
Path launchCachePath = Paths.get(tempDir, "junit-image-cache-" + projectName + "-launch");
Path buildCachePath = tempDir.resolve("junit-image-cache-" + projectName + "-build");
Path launchCachePath = tempDir.resolve("junit-image-cache-" + projectName + "-launch");
assertThat(buildCachePath).exists().isDirectory();
assertThat(launchCachePath).exists().isDirectory();
cleanupCache(buildCachePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;

import org.springframework.boot.buildpack.platform.docker.DockerApi;
import org.springframework.boot.buildpack.platform.docker.DockerApi.ImageApi;
Expand All @@ -49,6 +50,7 @@
* @author Stephane Nicoll
* @author Scott Frederick
* @author Rafael Ceccone
* @author Yanming Zhou
*/
@ExtendWith(MavenBuildExtension.class)
@DisabledIfDockerUnavailable
Expand Down Expand Up @@ -443,7 +445,7 @@ void whenBuildImageIsInvokedWithVolumeCaches(MavenBuild mavenBuild) {
@TestTemplate
@EnabledOnOs(value = OS.LINUX, disabledReason = "Works with Docker Engine on Linux but is not reliable with "
+ "Docker Desktop on other OSs")
void whenBuildImageIsInvokedWithBindCaches(MavenBuild mavenBuild) {
void whenBuildImageIsInvokedWithBindCaches(MavenBuild mavenBuild, @TempDir Path tempDir) {
String testBuildId = randomString();
mavenBuild.project("dockerTest", "build-image-bind-caches")
.goals("package")
Expand All @@ -454,9 +456,8 @@ void whenBuildImageIsInvokedWithBindCaches(MavenBuild mavenBuild) {
.contains("docker.io/library/build-image-bind-caches:0.0.1.BUILD-SNAPSHOT")
.contains("Successfully built image");
removeImage("build-image-bind-caches", "0.0.1.BUILD-SNAPSHOT");
String tempDir = System.getProperty("java.io.tmpdir");
Path buildCachePath = Paths.get(tempDir, "junit-image-cache-" + testBuildId + "-build");
Path launchCachePath = Paths.get(tempDir, "junit-image-cache-" + testBuildId + "-launch");
Path buildCachePath = tempDir.resolve("junit-image-cache-" + testBuildId + "-build");
Path launchCachePath = tempDir.resolve("junit-image-cache-" + testBuildId + "-launch");
assertThat(buildCachePath).exists().isDirectory();
assertThat(launchCachePath).exists().isDirectory();
cleanupCache(buildCachePath);
Expand Down
Loading