Merge branch '2.6.x' into 2.7.x
Closes gh-29613
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -47,11 +47,10 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link Builder}.
|
||||
@@ -97,11 +96,13 @@ class BuilderTests {
|
||||
assertThat(out.toString()).contains("Running creator");
|
||||
assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
ArgumentCaptor<ImageArchive> archive = ArgumentCaptor.forClass(ImageArchive.class);
|
||||
verify(docker.image()).pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), isNull());
|
||||
verify(docker.image()).pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), isNull());
|
||||
verify(docker.image()).load(archive.capture(), any());
|
||||
verify(docker.image()).remove(archive.getValue().getTag(), true);
|
||||
verifyNoMoreInteractions(docker.image());
|
||||
then(docker.image()).should().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
isNull());
|
||||
then(docker.image()).should().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
isNull());
|
||||
then(docker.image()).should().load(archive.capture(), any());
|
||||
then(docker.image()).should().remove(archive.getValue().getTag(), true);
|
||||
then(docker.image()).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -125,15 +126,15 @@ class BuilderTests {
|
||||
assertThat(out.toString()).contains("Running creator");
|
||||
assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
ArgumentCaptor<ImageArchive> archive = ArgumentCaptor.forClass(ImageArchive.class);
|
||||
verify(docker.image()).pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
then(docker.image()).should().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()));
|
||||
verify(docker.image()).pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
then(docker.image()).should().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()));
|
||||
verify(docker.image()).push(eq(request.getName()), any(),
|
||||
then(docker.image()).should().push(eq(request.getName()), any(),
|
||||
eq(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()));
|
||||
verify(docker.image()).load(archive.capture(), any());
|
||||
verify(docker.image()).remove(archive.getValue().getTag(), true);
|
||||
verifyNoMoreInteractions(docker.image());
|
||||
then(docker.image()).should().load(archive.capture(), any());
|
||||
then(docker.image()).should().remove(archive.getValue().getTag(), true);
|
||||
then(docker.image()).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -152,8 +153,8 @@ class BuilderTests {
|
||||
assertThat(out.toString()).contains("Running creator");
|
||||
assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
ArgumentCaptor<ImageArchive> archive = ArgumentCaptor.forClass(ImageArchive.class);
|
||||
verify(docker.image()).load(archive.capture(), any());
|
||||
verify(docker.image()).remove(archive.getValue().getTag(), true);
|
||||
then(docker.image()).should().load(archive.capture(), any());
|
||||
then(docker.image()).should().remove(archive.getValue().getTag(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -173,8 +174,8 @@ class BuilderTests {
|
||||
assertThat(out.toString()).contains("Running creator");
|
||||
assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
ArgumentCaptor<ImageArchive> archive = ArgumentCaptor.forClass(ImageArchive.class);
|
||||
verify(docker.image()).load(archive.capture(), any());
|
||||
verify(docker.image()).remove(archive.getValue().getTag(), true);
|
||||
then(docker.image()).should().load(archive.capture(), any());
|
||||
then(docker.image()).should().remove(archive.getValue().getTag(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -193,8 +194,8 @@ class BuilderTests {
|
||||
assertThat(out.toString()).contains("Running creator");
|
||||
assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
ArgumentCaptor<ImageArchive> archive = ArgumentCaptor.forClass(ImageArchive.class);
|
||||
verify(docker.image()).load(archive.capture(), any());
|
||||
verify(docker.image()).remove(archive.getValue().getTag(), true);
|
||||
then(docker.image()).should().load(archive.capture(), any());
|
||||
then(docker.image()).should().remove(archive.getValue().getTag(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -217,10 +218,10 @@ class BuilderTests {
|
||||
assertThat(out.toString()).contains("Running creator");
|
||||
assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
ArgumentCaptor<ImageArchive> archive = ArgumentCaptor.forClass(ImageArchive.class);
|
||||
verify(docker.image()).load(archive.capture(), any());
|
||||
verify(docker.image()).remove(archive.getValue().getTag(), true);
|
||||
verify(docker.image(), never()).pull(any(), any());
|
||||
verify(docker.image(), times(2)).inspect(any());
|
||||
then(docker.image()).should().load(archive.capture(), any());
|
||||
then(docker.image()).should().remove(archive.getValue().getTag(), true);
|
||||
then(docker.image()).should(never()).pull(any(), any());
|
||||
then(docker.image()).should(times(2)).inspect(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -243,10 +244,10 @@ class BuilderTests {
|
||||
assertThat(out.toString()).contains("Running creator");
|
||||
assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
ArgumentCaptor<ImageArchive> archive = ArgumentCaptor.forClass(ImageArchive.class);
|
||||
verify(docker.image()).load(archive.capture(), any());
|
||||
verify(docker.image()).remove(archive.getValue().getTag(), true);
|
||||
verify(docker.image(), times(2)).pull(any(), any(), isNull());
|
||||
verify(docker.image(), never()).inspect(any());
|
||||
then(docker.image()).should().load(archive.capture(), any());
|
||||
then(docker.image()).should().remove(archive.getValue().getTag(), true);
|
||||
then(docker.image()).should(times(2)).pull(any(), any(), isNull());
|
||||
then(docker.image()).should(never()).inspect(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -271,10 +272,10 @@ class BuilderTests {
|
||||
assertThat(out.toString()).contains("Running creator");
|
||||
assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
ArgumentCaptor<ImageArchive> archive = ArgumentCaptor.forClass(ImageArchive.class);
|
||||
verify(docker.image()).load(archive.capture(), any());
|
||||
verify(docker.image()).remove(archive.getValue().getTag(), true);
|
||||
verify(docker.image(), times(2)).inspect(any());
|
||||
verify(docker.image(), times(2)).pull(any(), any(), isNull());
|
||||
then(docker.image()).should().load(archive.capture(), any());
|
||||
then(docker.image()).should().remove(archive.getValue().getTag(), true);
|
||||
then(docker.image()).should(times(2)).inspect(any());
|
||||
then(docker.image()).should(times(2)).pull(any(), any(), isNull());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -293,10 +294,10 @@ class BuilderTests {
|
||||
assertThat(out.toString()).contains("Running creator");
|
||||
assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
assertThat(out.toString()).contains("Successfully created image tag 'docker.io/library/my-application:1.2.3'");
|
||||
verify(docker.image()).tag(eq(request.getName()), eq(ImageReference.of("my-application:1.2.3")));
|
||||
then(docker.image()).should().tag(eq(request.getName()), eq(ImageReference.of("my-application:1.2.3")));
|
||||
ArgumentCaptor<ImageArchive> archive = ArgumentCaptor.forClass(ImageArchive.class);
|
||||
verify(docker.image()).load(archive.capture(), any());
|
||||
verify(docker.image()).remove(archive.getValue().getTag(), true);
|
||||
then(docker.image()).should().load(archive.capture(), any());
|
||||
then(docker.image()).should().remove(archive.getValue().getTag(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -321,19 +322,19 @@ class BuilderTests {
|
||||
assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
assertThat(out.toString()).contains("Successfully created image tag 'docker.io/library/my-application:1.2.3'");
|
||||
|
||||
verify(docker.image()).pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
then(docker.image()).should().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()));
|
||||
verify(docker.image()).pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
then(docker.image()).should().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()));
|
||||
verify(docker.image()).push(eq(request.getName()), any(),
|
||||
then(docker.image()).should().push(eq(request.getName()), any(),
|
||||
eq(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()));
|
||||
verify(docker.image()).tag(eq(request.getName()), eq(ImageReference.of("my-application:1.2.3")));
|
||||
verify(docker.image()).push(eq(ImageReference.of("my-application:1.2.3")), any(),
|
||||
then(docker.image()).should().tag(eq(request.getName()), eq(ImageReference.of("my-application:1.2.3")));
|
||||
then(docker.image()).should().push(eq(ImageReference.of("my-application:1.2.3")), any(),
|
||||
eq(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()));
|
||||
ArgumentCaptor<ImageArchive> archive = ArgumentCaptor.forClass(ImageArchive.class);
|
||||
verify(docker.image()).load(archive.capture(), any());
|
||||
verify(docker.image()).remove(archive.getValue().getTag(), true);
|
||||
verifyNoMoreInteractions(docker.image());
|
||||
then(docker.image()).should().load(archive.capture(), any());
|
||||
then(docker.image()).should().remove(archive.getValue().getTag(), true);
|
||||
then(docker.image()).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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,8 +54,8 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link Lifecycle}.
|
||||
@@ -150,7 +150,7 @@ class LifecycleTests {
|
||||
createLifecycle(request).execute();
|
||||
assertPhaseWasRun("creator", withExpectedConfig("lifecycle-creator-clean-cache.json"));
|
||||
VolumeName name = VolumeName.of("pack-cache-b35197ac41ea.build");
|
||||
verify(this.docker.volume()).delete(name, true);
|
||||
then(this.docker.volume()).should().delete(name, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -185,8 +185,8 @@ class LifecycleTests {
|
||||
@Test
|
||||
void closeClearsVolumes() throws Exception {
|
||||
createLifecycle().close();
|
||||
verify(this.docker.volume()).delete(VolumeName.of("pack-layers-aaaaaaaaaa"), true);
|
||||
verify(this.docker.volume()).delete(VolumeName.of("pack-app-aaaaaaaaaa"), true);
|
||||
then(this.docker.volume()).should().delete(VolumeName.of("pack-layers-aaaaaaaaaa"), true);
|
||||
then(this.docker.volume()).should().delete(VolumeName.of("pack-app-aaaaaaaaaa"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -280,9 +280,9 @@ class LifecycleTests {
|
||||
|
||||
private void assertPhaseWasRun(String name, IOConsumer<ContainerConfig> configConsumer) throws IOException {
|
||||
ContainerReference containerReference = ContainerReference.of("cnb-lifecycle-" + name);
|
||||
verify(this.docker.container()).start(containerReference);
|
||||
verify(this.docker.container()).logs(eq(containerReference), any());
|
||||
verify(this.docker.container()).remove(containerReference, true);
|
||||
then(this.docker.container()).should().start(containerReference);
|
||||
then(this.docker.container()).should().logs(eq(containerReference), any());
|
||||
then(this.docker.container()).should().remove(containerReference, true);
|
||||
configConsumer.accept(this.configs.get(containerReference.toString()));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -23,9 +23,8 @@ import org.springframework.boot.buildpack.platform.docker.type.ContainerConfig.U
|
||||
import org.springframework.boot.buildpack.platform.docker.type.VolumeName;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
/**
|
||||
* Tests for {@link Phase}.
|
||||
@@ -55,9 +54,9 @@ class PhaseTests {
|
||||
Phase phase = new Phase("test", false);
|
||||
Update update = mock(Update.class);
|
||||
phase.apply(update);
|
||||
verify(update).withCommand("/cnb/lifecycle/test", NO_ARGS);
|
||||
verify(update).withLabel("author", "spring-boot");
|
||||
verifyNoMoreInteractions(update);
|
||||
then(update).should().withCommand("/cnb/lifecycle/test", NO_ARGS);
|
||||
then(update).should().withLabel("author", "spring-boot");
|
||||
then(update).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -66,11 +65,11 @@ class PhaseTests {
|
||||
phase.withDaemonAccess();
|
||||
Update update = mock(Update.class);
|
||||
phase.apply(update);
|
||||
verify(update).withUser("root");
|
||||
verify(update).withBinding(Binding.from("/var/run/docker.sock", "/var/run/docker.sock"));
|
||||
verify(update).withCommand("/cnb/lifecycle/test", NO_ARGS);
|
||||
verify(update).withLabel("author", "spring-boot");
|
||||
verifyNoMoreInteractions(update);
|
||||
then(update).should().withUser("root");
|
||||
then(update).should().withBinding(Binding.from("/var/run/docker.sock", "/var/run/docker.sock"));
|
||||
then(update).should().withCommand("/cnb/lifecycle/test", NO_ARGS);
|
||||
then(update).should().withLabel("author", "spring-boot");
|
||||
then(update).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,9 +78,9 @@ class PhaseTests {
|
||||
phase.withLogLevelArg();
|
||||
Update update = mock(Update.class);
|
||||
phase.apply(update);
|
||||
verify(update).withCommand("/cnb/lifecycle/test", "-log-level", "debug");
|
||||
verify(update).withLabel("author", "spring-boot");
|
||||
verifyNoMoreInteractions(update);
|
||||
then(update).should().withCommand("/cnb/lifecycle/test", "-log-level", "debug");
|
||||
then(update).should().withLabel("author", "spring-boot");
|
||||
then(update).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,9 +89,9 @@ class PhaseTests {
|
||||
phase.withLogLevelArg();
|
||||
Update update = mock(Update.class);
|
||||
phase.apply(update);
|
||||
verify(update).withCommand("/cnb/lifecycle/test");
|
||||
verify(update).withLabel("author", "spring-boot");
|
||||
verifyNoMoreInteractions(update);
|
||||
then(update).should().withCommand("/cnb/lifecycle/test");
|
||||
then(update).should().withLabel("author", "spring-boot");
|
||||
then(update).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,9 +100,9 @@ class PhaseTests {
|
||||
phase.withArgs("a", "b", "c");
|
||||
Update update = mock(Update.class);
|
||||
phase.apply(update);
|
||||
verify(update).withCommand("/cnb/lifecycle/test", "a", "b", "c");
|
||||
verify(update).withLabel("author", "spring-boot");
|
||||
verifyNoMoreInteractions(update);
|
||||
then(update).should().withCommand("/cnb/lifecycle/test", "a", "b", "c");
|
||||
then(update).should().withLabel("author", "spring-boot");
|
||||
then(update).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,10 +112,10 @@ class PhaseTests {
|
||||
phase.withBinding(Binding.from(volumeName, "/test"));
|
||||
Update update = mock(Update.class);
|
||||
phase.apply(update);
|
||||
verify(update).withCommand("/cnb/lifecycle/test");
|
||||
verify(update).withLabel("author", "spring-boot");
|
||||
verify(update).withBinding(Binding.from(volumeName, "/test"));
|
||||
verifyNoMoreInteractions(update);
|
||||
then(update).should().withCommand("/cnb/lifecycle/test");
|
||||
then(update).should().withLabel("author", "spring-boot");
|
||||
then(update).should().withBinding(Binding.from(volumeName, "/test"));
|
||||
then(update).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,11 +125,11 @@ class PhaseTests {
|
||||
phase.withEnv("name2", "value2");
|
||||
Update update = mock(Update.class);
|
||||
phase.apply(update);
|
||||
verify(update).withCommand("/cnb/lifecycle/test");
|
||||
verify(update).withLabel("author", "spring-boot");
|
||||
verify(update).withEnv("name1", "value1");
|
||||
verify(update).withEnv("name2", "value2");
|
||||
verifyNoMoreInteractions(update);
|
||||
then(update).should().withCommand("/cnb/lifecycle/test");
|
||||
then(update).should().withLabel("author", "spring-boot");
|
||||
then(update).should().withEnv("name1", "value1");
|
||||
then(update).should().withEnv("name2", "value2");
|
||||
then(update).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -139,10 +138,10 @@ class PhaseTests {
|
||||
phase.withNetworkMode("test");
|
||||
Update update = mock(Update.class);
|
||||
phase.apply(update);
|
||||
verify(update).withCommand("/cnb/lifecycle/test");
|
||||
verify(update).withNetworkMode("test");
|
||||
verify(update).withLabel("author", "spring-boot");
|
||||
verifyNoMoreInteractions(update);
|
||||
then(update).should().withCommand("/cnb/lifecycle/test");
|
||||
then(update).should().withNetworkMode("test");
|
||||
then(update).should().withLabel("author", "spring-boot");
|
||||
then(update).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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,10 +61,10 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link DockerApi}.
|
||||
@@ -261,7 +261,7 @@ class DockerApiTests {
|
||||
ordered.verify(this.loadListener).onStart();
|
||||
ordered.verify(this.loadListener).onUpdate(any());
|
||||
ordered.verify(this.loadListener).onFinish();
|
||||
verify(http()).post(any(), any(), this.writer.capture());
|
||||
then(http()).should().post(any(), any(), this.writer.capture());
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
this.writer.getValue().accept(out);
|
||||
assertThat(out.toByteArray()).hasSizeGreaterThan(21000);
|
||||
@@ -281,7 +281,7 @@ class DockerApiTests {
|
||||
+ "/docker.io/library/ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
given(http().delete(removeUri)).willReturn(emptyResponse());
|
||||
this.api.remove(reference, false);
|
||||
verify(http()).delete(removeUri);
|
||||
then(http()).should().delete(removeUri);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -292,7 +292,7 @@ class DockerApiTests {
|
||||
+ "/docker.io/library/ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d?force=1");
|
||||
given(http().delete(removeUri)).willReturn(emptyResponse());
|
||||
this.api.remove(reference, true);
|
||||
verify(http()).delete(removeUri);
|
||||
then(http()).should().delete(removeUri);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -370,7 +370,7 @@ class DockerApiTests {
|
||||
URI tagURI = new URI(IMAGES_URL + "/localhost:5000/ubuntu/tag?repo=localhost%3A5000%2Fubuntu%3Atagged");
|
||||
given(http().post(tagURI)).willReturn(emptyResponse());
|
||||
this.api.tag(sourceReference, targetReference);
|
||||
verify(http()).post(tagURI);
|
||||
then(http()).should().post(tagURI);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -406,7 +406,7 @@ class DockerApiTests {
|
||||
.willReturn(responseOf("create-container-response.json"));
|
||||
ContainerReference containerReference = this.api.create(config);
|
||||
assertThat(containerReference.toString()).isEqualTo("e90e34656806");
|
||||
verify(http()).post(any(), any(), this.writer.capture());
|
||||
then(http()).should().post(any(), any(), this.writer.capture());
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
this.writer.getValue().accept(out);
|
||||
assertThat(out.toByteArray().length).isEqualTo(config.toString().length());
|
||||
@@ -428,11 +428,11 @@ class DockerApiTests {
|
||||
given(http().put(eq(uploadUri), eq("application/x-tar"), any())).willReturn(emptyResponse());
|
||||
ContainerReference containerReference = this.api.create(config, content);
|
||||
assertThat(containerReference.toString()).isEqualTo("e90e34656806");
|
||||
verify(http()).post(any(), any(), this.writer.capture());
|
||||
then(http()).should().post(any(), any(), this.writer.capture());
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
this.writer.getValue().accept(out);
|
||||
assertThat(out.toByteArray().length).isEqualTo(config.toString().length());
|
||||
verify(http()).put(any(), any(), this.writer.capture());
|
||||
then(http()).should().put(any(), any(), this.writer.capture());
|
||||
this.writer.getValue().accept(out);
|
||||
assertThat(out.toByteArray()).hasSizeGreaterThan(2000);
|
||||
}
|
||||
@@ -449,7 +449,7 @@ class DockerApiTests {
|
||||
URI startContainerUri = new URI(CONTAINERS_URL + "/e90e34656806/start");
|
||||
given(http().post(startContainerUri)).willReturn(emptyResponse());
|
||||
this.api.start(reference);
|
||||
verify(http()).post(startContainerUri);
|
||||
then(http()).should().post(startContainerUri);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -504,7 +504,7 @@ class DockerApiTests {
|
||||
URI removeUri = new URI(CONTAINERS_URL + "/e90e34656806");
|
||||
given(http().delete(removeUri)).willReturn(emptyResponse());
|
||||
this.api.remove(reference, false);
|
||||
verify(http()).delete(removeUri);
|
||||
then(http()).should().delete(removeUri);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -513,7 +513,7 @@ class DockerApiTests {
|
||||
URI removeUri = new URI(CONTAINERS_URL + "/e90e34656806?force=1");
|
||||
given(http().delete(removeUri)).willReturn(emptyResponse());
|
||||
this.api.remove(reference, true);
|
||||
verify(http()).delete(removeUri);
|
||||
then(http()).should().delete(removeUri);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -540,7 +540,7 @@ class DockerApiTests {
|
||||
URI removeUri = new URI(VOLUMES_URL + "/test");
|
||||
given(http().delete(removeUri)).willReturn(emptyResponse());
|
||||
this.api.delete(name, false);
|
||||
verify(http()).delete(removeUri);
|
||||
then(http()).should().delete(removeUri);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -549,7 +549,7 @@ class DockerApiTests {
|
||||
URI removeUri = new URI(VOLUMES_URL + "/test?force=1");
|
||||
given(http().delete(removeUri)).willReturn(emptyResponse());
|
||||
this.api.delete(name, true);
|
||||
verify(http()).delete(removeUri);
|
||||
then(http()).should().delete(removeUri);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
|
||||
/**
|
||||
* Tests for {@link HttpClientTransport}.
|
||||
@@ -103,7 +103,7 @@ class HttpClientTransportTests {
|
||||
given(this.entity.getContent()).willReturn(this.content);
|
||||
given(this.statusLine.getStatusCode()).willReturn(200);
|
||||
Response response = this.http.get(this.uri);
|
||||
verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
HttpUriRequest request = this.requestCaptor.getValue();
|
||||
assertThat(request).isInstanceOf(HttpGet.class);
|
||||
assertThat(request.getURI()).isEqualTo(this.uri);
|
||||
@@ -117,7 +117,7 @@ class HttpClientTransportTests {
|
||||
given(this.entity.getContent()).willReturn(this.content);
|
||||
given(this.statusLine.getStatusCode()).willReturn(200);
|
||||
Response response = this.http.post(this.uri);
|
||||
verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
HttpUriRequest request = this.requestCaptor.getValue();
|
||||
assertThat(request).isInstanceOf(HttpPost.class);
|
||||
assertThat(request.getURI()).isEqualTo(this.uri);
|
||||
@@ -132,7 +132,7 @@ class HttpClientTransportTests {
|
||||
given(this.entity.getContent()).willReturn(this.content);
|
||||
given(this.statusLine.getStatusCode()).willReturn(200);
|
||||
Response response = this.http.post(this.uri, "auth token");
|
||||
verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
HttpUriRequest request = this.requestCaptor.getValue();
|
||||
assertThat(request).isInstanceOf(HttpPost.class);
|
||||
assertThat(request.getURI()).isEqualTo(this.uri);
|
||||
@@ -147,7 +147,7 @@ class HttpClientTransportTests {
|
||||
given(this.entity.getContent()).willReturn(this.content);
|
||||
given(this.statusLine.getStatusCode()).willReturn(200);
|
||||
Response response = this.http.post(this.uri, "");
|
||||
verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
HttpUriRequest request = this.requestCaptor.getValue();
|
||||
assertThat(request).isInstanceOf(HttpPost.class);
|
||||
assertThat(request.getURI()).isEqualTo(this.uri);
|
||||
@@ -164,7 +164,7 @@ class HttpClientTransportTests {
|
||||
given(this.statusLine.getStatusCode()).willReturn(200);
|
||||
Response response = this.http.post(this.uri, APPLICATION_JSON,
|
||||
(out) -> StreamUtils.copy(content, StandardCharsets.UTF_8, out));
|
||||
verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
HttpUriRequest request = this.requestCaptor.getValue();
|
||||
HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
|
||||
assertThat(request).isInstanceOf(HttpPost.class);
|
||||
@@ -186,7 +186,7 @@ class HttpClientTransportTests {
|
||||
given(this.statusLine.getStatusCode()).willReturn(200);
|
||||
Response response = this.http.post(this.uri, APPLICATION_X_TAR,
|
||||
(out) -> StreamUtils.copy(content, StandardCharsets.UTF_8, out));
|
||||
verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
HttpUriRequest request = this.requestCaptor.getValue();
|
||||
HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
|
||||
assertThat(request).isInstanceOf(HttpPost.class);
|
||||
@@ -208,7 +208,7 @@ class HttpClientTransportTests {
|
||||
given(this.statusLine.getStatusCode()).willReturn(200);
|
||||
Response response = this.http.put(this.uri, APPLICATION_JSON,
|
||||
(out) -> StreamUtils.copy(content, StandardCharsets.UTF_8, out));
|
||||
verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
HttpUriRequest request = this.requestCaptor.getValue();
|
||||
HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
|
||||
assertThat(request).isInstanceOf(HttpPut.class);
|
||||
@@ -230,7 +230,7 @@ class HttpClientTransportTests {
|
||||
given(this.statusLine.getStatusCode()).willReturn(200);
|
||||
Response response = this.http.put(this.uri, APPLICATION_X_TAR,
|
||||
(out) -> StreamUtils.copy(content, StandardCharsets.UTF_8, out));
|
||||
verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
HttpUriRequest request = this.requestCaptor.getValue();
|
||||
HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
|
||||
assertThat(request).isInstanceOf(HttpPut.class);
|
||||
@@ -250,7 +250,7 @@ class HttpClientTransportTests {
|
||||
given(this.entity.getContent()).willReturn(this.content);
|
||||
given(this.statusLine.getStatusCode()).willReturn(200);
|
||||
Response response = this.http.delete(this.uri);
|
||||
verify(this.client).execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
then(this.client).should().execute(this.hostCaptor.capture(), this.requestCaptor.capture());
|
||||
HttpUriRequest request = this.requestCaptor.getValue();
|
||||
assertThat(request).isInstanceOf(HttpDelete.class);
|
||||
assertThat(request.getURI()).isEqualTo(this.uri);
|
||||
|
||||
Reference in New Issue
Block a user