Search in sources :

Example 56 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class PackagingDocumentationTests method bootBuildImageWithBuildpacks.

@TestTemplate
void bootBuildImageWithBuildpacks() {
    BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-buildpacks").build("bootBuildImageBuildpacks");
    assertThat(result.getOutput()).contains("file:///path/to/example-buildpack.tgz").contains("urn:cnb:builder:paketo-buildpacks/java");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 57 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class PackagingDocumentationTests method bootBuildImagePublish.

@TestTemplate
void bootBuildImagePublish() {
    BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-publish").build("bootBuildImagePublish");
    assertThat(result.getOutput()).contains("true");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 58 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class PackagingDocumentationTests method bootBuildImageWithCustomProxySettings.

@TestTemplate
void bootBuildImageWithCustomProxySettings() {
    BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-env-proxy").build("bootBuildImageEnvironment");
    assertThat(result.getOutput()).contains("HTTP_PROXY=http://proxy.example.com").contains("HTTPS_PROXY=https://proxy.example.com");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 59 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class PaketoBuilderTests method executableJarApp.

@Test
void executableJarApp() throws Exception {
    writeMainClass();
    String imageName = "paketo-integration/" + this.gradleBuild.getProjectDir().getName();
    ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
    BuildResult result = buildImage(imageName);
    assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
        container.waitingFor(Wait.forHttp("/test")).start();
        ContainerConfig config = container.getContainerInfo().getConfig();
        assertLabelsMatchManifestAttributes(config);
        ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
            metadata.buildpacks().contains("paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/executable-jar", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
            metadata.processOfType("web").extracting("command", "args").containsExactly("java", Collections.singletonList("org.springframework.boot.loader.JarLauncher"));
            metadata.processOfType("executable-jar").extracting("command", "args").containsExactly("java", Collections.singletonList("org.springframework.boot.loader.JarLauncher"));
        });
        assertImageHasSbomLayer(imageReference, config, "executable-jar");
        assertImageLayersMatchLayersIndex(imageReference, config);
    } finally {
        removeImage(imageReference);
    }
}
Also used : ContainerConfig(com.github.dockerjava.api.model.ContainerConfig) ImageReference(org.springframework.boot.buildpack.platform.docker.type.ImageReference) BuildResult(org.gradle.testkit.runner.BuildResult) Test(org.junit.jupiter.api.Test)

Example 60 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class PaketoBuilderTests method executableJarAppBuiltTwiceWithCaching.

@Test
void executableJarAppBuiltTwiceWithCaching() throws Exception {
    writeMainClass();
    String imageName = "paketo-integration/" + this.gradleBuild.getProjectDir().getName();
    ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
    BuildResult result = buildImage(imageName);
    assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
        container.waitingFor(Wait.forHttp("/test")).start();
        container.stop();
    }
    this.gradleBuild.expectDeprecationMessages("BOM table is deprecated in this buildpack api version");
    result = buildImage(imageName);
    assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
        container.waitingFor(Wait.forHttp("/test")).start();
    } finally {
        removeImage(imageReference);
    }
}
Also used : ImageReference(org.springframework.boot.buildpack.platform.docker.type.ImageReference) BuildResult(org.gradle.testkit.runner.BuildResult) Test(org.junit.jupiter.api.Test)

Aggregations

BuildResult (org.gradle.testkit.runner.BuildResult)143 File (java.io.File)62 TestTemplate (org.junit.jupiter.api.TestTemplate)60 Test (org.junit.Test)47 Test (org.junit.jupiter.api.Test)20 StringWriter (java.io.StringWriter)19 GradleRunner (org.gradle.testkit.runner.GradleRunner)17 Test (org.testng.annotations.Test)10 ImageReference (org.springframework.boot.buildpack.platform.docker.type.ImageReference)8 JarFile (java.util.jar.JarFile)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 TestHelpers.findFile (me.tatarka.TestHelpers.findFile)6 TestHelpers.writeFile (me.tatarka.TestHelpers.writeFile)6 ContainerConfig (com.github.dockerjava.api.model.ContainerConfig)5 FileWriter (java.io.FileWriter)5 IOException (java.io.IOException)5 PrintWriter (java.io.PrintWriter)5 Path (java.nio.file.Path)5 BufferedReader (java.io.BufferedReader)4