Search in sources :

Example 41 with BuildResult

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

the class MavenPublishingIntegrationTests method bootWarCanBePublished.

@TestTemplate
void bootWarCanBePublished() {
    BuildResult result = this.gradleBuild.build("publish");
    assertThat(result.task(":publish").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(artifactWithSuffix("war")).isFile();
    assertThat(artifactWithSuffix("pom")).is(pomWith().groupId("com.example").artifactId(this.gradleBuild.getProjectDir().getName()).version("1.0").packaging("war").noDependencies());
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 42 with BuildResult

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

the class BootBuildImageIntegrationTests method failsWithPublishMissingPublishRegistry.

@TestTemplate
void failsWithPublishMissingPublishRegistry() throws IOException {
    writeMainClass();
    writeLongNameResource();
    BuildResult result = this.gradleBuild.buildAndFail("bootBuildImage", "--publishImage");
    assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.FAILED);
    assertThat(result.getOutput()).contains("requires docker.publishRegistry");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 43 with BuildResult

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

the class BootBuildImageIntegrationTests method buildsImageWithTag.

@TestTemplate
void buildsImageWithTag() throws IOException {
    writeMainClass();
    writeLongNameResource();
    BuildResult result = this.gradleBuild.build("bootBuildImage", "--pullPolicy=IF_NOT_PRESENT");
    String projectName = this.gradleBuild.getProjectDir().getName();
    assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
    assertThat(result.getOutput()).contains("---> Test Info buildpack building");
    assertThat(result.getOutput()).contains("---> Test Info buildpack done");
    assertThat(result.getOutput()).contains("example.com/myapp:latest");
    removeImages(projectName, "example.com/myapp:latest");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 44 with BuildResult

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

the class BootBuildImageIntegrationTests method failsWithBuildpackNotInBuilder.

@TestTemplate
void failsWithBuildpackNotInBuilder() throws IOException {
    writeMainClass();
    writeLongNameResource();
    BuildResult result = this.gradleBuild.buildAndFail("bootBuildImage", "--pullPolicy=IF_NOT_PRESENT");
    assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.FAILED);
    assertThat(result.getOutput()).contains("'urn:cnb:builder:example/does-not-exist:0.0.1' not found in builder");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 45 with BuildResult

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

the class BootBuildImageIntegrationTests method buildsImageWithCustomName.

@TestTemplate
void buildsImageWithCustomName() throws IOException {
    writeMainClass();
    writeLongNameResource();
    BuildResult result = this.gradleBuild.build("bootBuildImage", "--pullPolicy=IF_NOT_PRESENT");
    assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.getOutput()).contains("example/test-image-name");
    assertThat(result.getOutput()).contains("---> Test Info buildpack building");
    assertThat(result.getOutput()).contains("---> Test Info buildpack done");
    removeImages("example/test-image-name");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Aggregations

BuildResult (org.gradle.testkit.runner.BuildResult)149 File (java.io.File)65 TestTemplate (org.junit.jupiter.api.TestTemplate)60 Test (org.junit.Test)47 Test (org.junit.jupiter.api.Test)21 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 BuildTask (org.gradle.testkit.runner.BuildTask)5