Search in sources :

Example 36 with BuildResult

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

the class BootRunIntegrationTests method classesFromASecondarySourceSetCanBeOnTheClasspath.

@TestTemplate
void classesFromASecondarySourceSetCanBeOnTheClasspath() throws IOException {
    File output = new File(this.gradleBuild.getProjectDir(), "src/secondary/java/com/example/bootrun/main");
    output.mkdirs();
    FileSystemUtils.copyRecursively(new File("src/test/java/com/example/bootrun/main"), output);
    BuildResult result = this.gradleBuild.build("bootRun");
    assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.getOutput()).contains("com.example.bootrun.main.CustomMainClass");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) File(java.io.File) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 37 with BuildResult

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

the class BootRunIntegrationTests method jarTypeFilteringIsAppliedToTheClasspath.

@TestTemplate
void jarTypeFilteringIsAppliedToTheClasspath() throws IOException {
    copyClasspathApplication();
    File flatDirRepository = new File(this.gradleBuild.getProjectDir(), "repository");
    createDependenciesStarterJar(new File(flatDirRepository, "starter.jar"));
    createStandardJar(new File(flatDirRepository, "standard.jar"));
    BuildResult result = this.gradleBuild.build("bootRun");
    assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.getOutput()).contains("standard.jar").doesNotContain("starter.jar");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) File(java.io.File) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 38 with BuildResult

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

the class JavaPluginActionIntegrationTests method additionalMetadataLocationsConfiguredWhenProcessorIsPresent.

@TestTemplate
void additionalMetadataLocationsConfiguredWhenProcessorIsPresent() throws IOException {
    createMinimalMainSource();
    File libs = new File(this.gradleBuild.getProjectDir(), "libs");
    libs.mkdirs();
    new JarOutputStream(new FileOutputStream(new File(libs, "spring-boot-configuration-processor-1.2.3.jar"))).close();
    BuildResult result = this.gradleBuild.build("compileJava");
    assertThat(result.task(":compileJava").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.getOutput()).contains("compileJava compiler args: [-parameters, -Aorg.springframework.boot." + "configurationprocessor.additionalMetadataLocations=" + new File(this.gradleBuild.getProjectDir(), "src/main/resources").getCanonicalPath());
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) FileOutputStream(java.io.FileOutputStream) JarOutputStream(java.util.jar.JarOutputStream) File(java.io.File) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 39 with BuildResult

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

the class JavaPluginActionIntegrationTests method additionalMetadataLocationsNotConfiguredWhenProcessorIsAbsent.

@TestTemplate
void additionalMetadataLocationsNotConfiguredWhenProcessorIsAbsent() throws IOException {
    createMinimalMainSource();
    BuildResult result = this.gradleBuild.build("compileJava");
    assertThat(result.task(":compileJava").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.getOutput()).contains("compileJava compiler args: [-parameters]");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 40 with BuildResult

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

the class JavaPluginActionIntegrationTests method assembleRunsBootJarAndJar.

@TestTemplate
void assembleRunsBootJarAndJar() {
    BuildResult result = this.gradleBuild.build("assemble");
    assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.task(":jar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
    assertThat(buildLibs.listFiles()).containsExactlyInAnyOrder(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar"), new File(buildLibs, this.gradleBuild.getProjectDir().getName() + "-plain.jar"));
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) File(java.io.File) 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