Search in sources :

Example 1 with IOBiConsumer

use of org.springframework.boot.buildpack.platform.io.IOBiConsumer in project spring-boot by spring-projects.

the class ImageBuildpackTests method withMockLayers.

private Object withMockLayers(InvocationOnMock invocation) {
    try {
        IOBiConsumer<String, TarArchive> consumer = invocation.getArgument(1);
        TarArchive archive = (out) -> {
            try (TarArchiveOutputStream tarOut = new TarArchiveOutputStream(out)) {
                tarOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
                writeTarEntry(tarOut, "/cnb/");
                writeTarEntry(tarOut, "/cnb/buildpacks/");
                writeTarEntry(tarOut, "/cnb/buildpacks/example_buildpack/");
                writeTarEntry(tarOut, "/cnb/buildpacks/example_buildpack/0.0.1/");
                writeTarEntry(tarOut, "/cnb/buildpacks/example_buildpack/0.0.1/buildpack.toml");
                writeTarEntry(tarOut, "/cnb/buildpacks/example_buildpack/0.0.1/" + this.longFilePath);
                tarOut.finish();
            }
        };
        consumer.accept("test", archive);
    } catch (IOException ex) {
        fail("Error writing mock layers", ex);
    }
    return null;
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TarArchiveInputStream(org.apache.commons.compress.archivers.tar.TarArchiveInputStream) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ImageReference(org.springframework.boot.buildpack.platform.docker.type.ImageReference) Random(java.util.Random) ArrayList(java.util.ArrayList) TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ByteArrayInputStream(java.io.ByteArrayInputStream) TarArchiveEntry(org.apache.commons.compress.archivers.tar.TarArchiveEntry) BDDMockito.given(org.mockito.BDDMockito.given) TarArchive(org.springframework.boot.buildpack.platform.io.TarArchive) Image(org.springframework.boot.buildpack.platform.docker.type.Image) Assertions.tuple(org.assertj.core.api.Assertions.tuple) IOException(java.io.IOException) IOBiConsumer(org.springframework.boot.buildpack.platform.io.IOBiConsumer) BDDMockito.willAnswer(org.mockito.BDDMockito.willAnswer) Test(org.junit.jupiter.api.Test) List(java.util.List) Assertions.fail(org.assertj.core.api.Assertions.fail) Assertions.assertThatIllegalArgumentException(org.assertj.core.api.Assertions.assertThatIllegalArgumentException) AbstractJsonTests(org.springframework.boot.buildpack.platform.json.AbstractJsonTests) Mockito.mock(org.mockito.Mockito.mock) TarArchive(org.springframework.boot.buildpack.platform.io.TarArchive) TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream) IOException(java.io.IOException)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Random (java.util.Random)1 TarArchiveEntry (org.apache.commons.compress.archivers.tar.TarArchiveEntry)1 TarArchiveInputStream (org.apache.commons.compress.archivers.tar.TarArchiveInputStream)1 TarArchiveOutputStream (org.apache.commons.compress.archivers.tar.TarArchiveOutputStream)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatIllegalArgumentException (org.assertj.core.api.Assertions.assertThatIllegalArgumentException)1 Assertions.fail (org.assertj.core.api.Assertions.fail)1 Assertions.tuple (org.assertj.core.api.Assertions.tuple)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)1 BDDMockito.given (org.mockito.BDDMockito.given)1 BDDMockito.willAnswer (org.mockito.BDDMockito.willAnswer)1 Mockito.mock (org.mockito.Mockito.mock)1