Merge branch '2.7.x' into 3.0.x

This commit is contained in:
Phillip Webb
2023-02-21 23:15:40 -08:00
1890 changed files with 27173 additions and 21952 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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,12 +47,14 @@ class TaskConfigurationAvoidanceTests {
@ArchTest
void noApisThatCauseEagerTaskConfigurationShouldBeCalled(JavaClasses classes) {
ProhibitedMethods prohibited = new ProhibitedMethods();
prohibited.on(TaskContainer.class).methodsNamed("create", "findByPath, getByPath").method("withType",
Class.class, Action.class);
prohibited.on(TaskContainer.class)
.methodsNamed("create", "findByPath, getByPath")
.method("withType", Class.class, Action.class);
prohibited.on(TaskCollection.class).methodsNamed("findByName", "getByName");
ArchRuleDefinition.noClasses().should()
.callMethodWhere(DescribedPredicate.describe("it would cause eager task configuration", prohibited))
.check(classes);
ArchRuleDefinition.noClasses()
.should()
.callMethodWhere(DescribedPredicate.describe("it would cause eager task configuration", prohibited))
.check(classes);
}
static class DoNotIncludeTests implements ImportOption {
@@ -99,7 +101,7 @@ class TaskConfigurationAvoidanceTests {
private ProhibitedConfigurer method(String name, Class<?>... parameterTypes) {
ProhibitedMethods.this.prohibited
.add(new ProhibitMethod(this.type, name, Arrays.asList(parameterTypes)));
.add(new ProhibitMethod(this.type, name, Arrays.asList(parameterTypes)));
return this;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -44,13 +44,13 @@ class IntegratingWithActuatorDocumentationTests {
void basicBuildInfo() {
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-basic").build("bootBuildInfo");
assertThat(new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties"))
.isFile();
.isFile();
}
@TestTemplate
void buildInfoCustomValues() {
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-custom-values")
.build("bootBuildInfo");
.build("bootBuildInfo");
File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties");
assertThat(file).isFile();
Properties properties = buildInfoProperties(file);
@@ -64,7 +64,7 @@ class IntegratingWithActuatorDocumentationTests {
@TestTemplate
void buildInfoAdditional() {
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-additional")
.build("bootBuildInfo");
.build("bootBuildInfo");
File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties");
assertThat(file).isFile();
Properties properties = buildInfoProperties(file);
@@ -75,7 +75,7 @@ class IntegratingWithActuatorDocumentationTests {
@TestTemplate
void buildInfoExcludeTime() {
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-exclude-time")
.build("bootBuildInfo");
.build("bootBuildInfo");
File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties");
assertThat(file).isFile();
Properties properties = buildInfoProperties(file);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 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.
@@ -44,14 +44,16 @@ class ManagingDependenciesDocumentationTests {
@TestTemplate
void customManagedVersions() {
assertThat(this.gradleBuild.script("src/docs/gradle/managing-dependencies/custom-version").build("slf4jVersion")
.getOutput()).contains("1.7.20");
assertThat(this.gradleBuild.script("src/docs/gradle/managing-dependencies/custom-version")
.build("slf4jVersion")
.getOutput()).contains("1.7.20");
}
@TestTemplate
void dependencyManagementInIsolation() {
assertThat(this.gradleBuild.script("src/docs/gradle/managing-dependencies/configure-bom")
.build("dependencyManagement").getOutput()).contains("org.springframework.boot:spring-boot-starter ");
.build("dependencyManagement")
.getOutput()).contains("org.springframework.boot:spring-boot-starter ");
}
@TestTemplate
@@ -59,21 +61,23 @@ class ManagingDependenciesDocumentationTests {
assumingThat(this.gradleBuild.getDsl() == Dsl.KOTLIN,
() -> assertThat(
this.gradleBuild.script("src/docs/gradle/managing-dependencies/configure-bom-with-plugins")
.build("dependencyManagement").getOutput())
.contains("org.springframework.boot:spring-boot-starter TEST-SNAPSHOT"));
.build("dependencyManagement")
.getOutput())
.contains("org.springframework.boot:spring-boot-starter TEST-SNAPSHOT"));
}
@TestTemplate
void configurePlatform() {
assertThat(this.gradleBuild.script("src/docs/gradle/managing-dependencies/configure-platform")
.build("dependencies", "--configuration", "compileClasspath").getOutput())
.contains("org.springframework.boot:spring-boot-starter ");
.build("dependencies", "--configuration", "compileClasspath")
.getOutput()).contains("org.springframework.boot:spring-boot-starter ");
}
@TestTemplate
void customManagedVersionsWithPlatform() {
assertThat(this.gradleBuild.script("src/docs/gradle/managing-dependencies/custom-version-with-platform")
.build("dependencies", "--configuration", "compileClasspath").getOutput()).contains("1.7.20");
.build("dependencies", "--configuration", "compileClasspath")
.getOutput()).contains("1.7.20");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -63,7 +63,7 @@ class PackagingDocumentationTests {
assertThat(file).isFile();
try (JarFile jar = new JarFile(file)) {
assertThat(jar.getManifest().getMainAttributes().getValue("Start-Class"))
.isEqualTo("com.example.ExampleApplication");
.isEqualTo("com.example.ExampleApplication");
}
}
@@ -75,7 +75,7 @@ class PackagingDocumentationTests {
assertThat(file).isFile();
try (JarFile jar = new JarFile(file)) {
assertThat(jar.getManifest().getMainAttributes().getValue("Start-Class"))
.isEqualTo("com.example.ExampleApplication");
.isEqualTo("com.example.ExampleApplication");
}
}
@@ -87,7 +87,7 @@ class PackagingDocumentationTests {
assertThat(file).isFile();
try (JarFile jar = new JarFile(file)) {
assertThat(jar.getManifest().getMainAttributes().getValue("Start-Class"))
.isEqualTo("com.example.ExampleApplication");
.isEqualTo("com.example.ExampleApplication");
}
}
@@ -99,7 +99,7 @@ class PackagingDocumentationTests {
assertThat(file).isFile();
try (JarFile jar = new JarFile(file)) {
assertThat(jar.getManifest().getMainAttributes().getValue("Start-Class"))
.isEqualTo("com.example.ExampleApplication");
.isEqualTo("com.example.ExampleApplication");
}
}
@@ -166,7 +166,7 @@ class PackagingDocumentationTests {
assertThat(file).isFile();
try (JarFile jar = new JarFile(file)) {
assertThat(jar.getManifest().getMainAttributes().getValue("Main-Class"))
.isEqualTo("org.springframework.boot.loader.PropertiesLauncher");
.isEqualTo("org.springframework.boot.loader.PropertiesLauncher");
}
}
@@ -222,8 +222,10 @@ class PackagingDocumentationTests {
try (JarFile jar = new JarFile(file)) {
JarEntry entry = jar.getJarEntry("BOOT-INF/layers.idx");
assertThat(entry).isNotNull();
assertThat(Collections.list(jar.entries()).stream().map(JarEntry::getName)
.filter((name) -> name.startsWith("BOOT-INF/lib/spring-boot"))).isNotEmpty();
assertThat(Collections.list(jar.entries())
.stream()
.map(JarEntry::getName)
.filter((name) -> name.startsWith("BOOT-INF/lib/spring-boot"))).isNotEmpty();
}
}
@@ -236,100 +238,105 @@ class PackagingDocumentationTests {
try (JarFile jar = new JarFile(file)) {
JarEntry entry = jar.getJarEntry("BOOT-INF/layers.idx");
assertThat(entry).isNotNull();
assertThat(Collections.list(jar.entries()).stream().map(JarEntry::getName)
.filter((name) -> name.startsWith("BOOT-INF/lib/spring-boot"))).isEmpty();
assertThat(Collections.list(jar.entries())
.stream()
.map(JarEntry::getName)
.filter((name) -> name.startsWith("BOOT-INF/lib/spring-boot"))).isEmpty();
}
}
@TestTemplate
void bootBuildImageWithBuilder() {
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-builder")
.build("bootBuildImageBuilder");
.build("bootBuildImageBuilder");
assertThat(result.getOutput()).contains("builder=mine/java-cnb-builder").contains("runImage=mine/java-cnb-run");
}
@TestTemplate
void bootBuildImageWithCustomBuildpackJvmVersion() {
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-env")
.build("bootBuildImageEnvironment");
.build("bootBuildImageEnvironment");
assertThat(result.getOutput()).contains("BP_JVM_VERSION=17");
}
@TestTemplate
void bootBuildImageWithCustomProxySettings() {
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-env-proxy")
.build("bootBuildImageEnvironment");
.build("bootBuildImageEnvironment");
assertThat(result.getOutput()).contains("HTTP_PROXY=http://proxy.example.com")
.contains("HTTPS_PROXY=https://proxy.example.com");
.contains("HTTPS_PROXY=https://proxy.example.com");
}
@TestTemplate
void bootBuildImageWithCustomRuntimeConfiguration() {
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-env-runtime")
.build("bootBuildImageEnvironment");
.build("bootBuildImageEnvironment");
assertThat(result.getOutput()).contains("BPE_DELIM_JAVA_TOOL_OPTIONS= ")
.contains("BPE_APPEND_JAVA_TOOL_OPTIONS=-XX:+HeapDumpOnOutOfMemoryError");
.contains("BPE_APPEND_JAVA_TOOL_OPTIONS=-XX:+HeapDumpOnOutOfMemoryError");
}
@TestTemplate
void bootBuildImageWithCustomImageName() {
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-name")
.build("bootBuildImageName");
.build("bootBuildImageName");
assertThat(result.getOutput()).contains("example.com/library/" + this.gradleBuild.getProjectDir().getName());
}
@TestTemplate
void bootBuildImageWithDockerHostMinikube() {
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-docker-host")
.build("bootBuildImageDocker");
assertThat(result.getOutput()).contains("host=tcp://192.168.99.100:2376").contains("tlsVerify=true")
.contains("certPath=/home/user/.minikube/certs");
.build("bootBuildImageDocker");
assertThat(result.getOutput()).contains("host=tcp://192.168.99.100:2376")
.contains("tlsVerify=true")
.contains("certPath=/home/user/.minikube/certs");
}
@TestTemplate
void bootBuildImageWithDockerHostPodman() {
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-docker-host-podman")
.build("bootBuildImageDocker");
.build("bootBuildImageDocker");
assertThat(result.getOutput()).contains("host=unix:///run/user/1000/podman/podman.sock")
.contains("bindHostToBuilder=true");
.contains("bindHostToBuilder=true");
}
@TestTemplate
void bootBuildImageWithDockerUserAuth() {
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-docker-auth-user")
.build("bootBuildImageDocker");
assertThat(result.getOutput()).contains("username=user").contains("password=secret")
.contains("url=https://docker.example.com/v1/").contains("email=user@example.com");
.build("bootBuildImageDocker");
assertThat(result.getOutput()).contains("username=user")
.contains("password=secret")
.contains("url=https://docker.example.com/v1/")
.contains("email=user@example.com");
}
@TestTemplate
void bootBuildImageWithDockerTokenAuth() {
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-docker-auth-token")
.build("bootBuildImageDocker");
.build("bootBuildImageDocker");
assertThat(result.getOutput()).contains("token=9cbaf023786cd7...");
}
@TestTemplate
void bootBuildImagePublish() {
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-publish")
.build("bootBuildImagePublish");
.build("bootBuildImagePublish");
assertThat(result.getOutput()).contains("true");
}
@TestTemplate
void bootBuildImageWithBuildpacks() {
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-buildpacks")
.build("bootBuildImageBuildpacks");
.build("bootBuildImageBuildpacks");
assertThat(result.getOutput()).contains("file:///path/to/example-buildpack.tgz")
.contains("urn:cnb:builder:paketo-buildpacks/java");
.contains("urn:cnb:builder:paketo-buildpacks/java");
}
@TestTemplate
void bootBuildImageWithCaches() {
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-caches")
.build("bootBuildImageCaches");
.build("bootBuildImageCaches");
assertThat(result.getOutput()).containsPattern("buildCache=cache-gradle-[\\d]+.build")
.containsPattern("launchCache=cache-gradle-[\\d]+.launch");
.containsPattern("launchCache=cache-gradle-[\\d]+.launch");
}
protected void jarFile(File file) throws IOException {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 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.
@@ -37,8 +37,9 @@ class PublishingDocumentationTests {
@TestTemplate
void mavenPublish() {
assertThat(this.gradleBuild.script("src/docs/gradle/publishing/maven-publish").build("publishingConfiguration")
.getOutput()).contains("MavenPublication").contains("https://repo.example.com");
assertThat(this.gradleBuild.script("src/docs/gradle/publishing/maven-publish")
.build("publishingConfiguration")
.getOutput()).contains("MavenPublication").contains("https://repo.example.com");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -44,46 +44,51 @@ class RunningDocumentationTests {
void bootRunMain() throws IOException {
writeMainClass();
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-main").build("bootRun").getOutput())
.contains("com.example.ExampleApplication");
.contains("com.example.ExampleApplication");
}
@TestTemplate
void applicationPluginMainClassName() throws IOException {
writeMainClass();
assertThat(this.gradleBuild.script("src/docs/gradle/running/application-plugin-main-class-name")
.build("bootRun").getOutput()).contains("com.example.ExampleApplication");
.build("bootRun")
.getOutput()).contains("com.example.ExampleApplication");
}
@TestTemplate
void springBootDslMainClassName() throws IOException {
writeMainClass();
assertThat(this.gradleBuild.script("src/docs/gradle/running/spring-boot-dsl-main-class-name").build("bootRun")
.getOutput()).contains("com.example.ExampleApplication");
assertThat(this.gradleBuild.script("src/docs/gradle/running/spring-boot-dsl-main-class-name")
.build("bootRun")
.getOutput()).contains("com.example.ExampleApplication");
}
@TestTemplate
void bootRunSourceResources() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-source-resources")
.build("configuredClasspath").getOutput()).contains(new File("src/main/resources").getPath());
.build("configuredClasspath")
.getOutput()).contains(new File("src/main/resources").getPath());
}
@TestTemplate
void bootRunDisableOptimizedLaunch() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-disable-optimized-launch")
.build("optimizedLaunch").getOutput()).contains("false");
.build("optimizedLaunch")
.getOutput()).contains("false");
}
@TestTemplate
void bootRunSystemPropertyDefaultValue() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-system-property")
.build("configuredSystemProperties").getOutput()).contains("com.example.property = default");
.build("configuredSystemProperties")
.getOutput()).contains("com.example.property = default");
}
@TestTemplate
void bootRunSystemProperty() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-system-property")
.build("-Pexample=custom", "configuredSystemProperties").getOutput())
.contains("com.example.property = custom");
.build("-Pexample=custom", "configuredSystemProperties")
.getOutput()).contains("com.example.property = custom");
}
private void writeMainClass() throws IOException {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 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.
@@ -44,7 +44,7 @@ class BuildInfoDslIntegrationTests {
@TestTemplate
void basicJar() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
assertThat(properties).containsEntry("build.artifact", this.gradleBuild.getProjectDir().getName());
@@ -55,7 +55,7 @@ class BuildInfoDslIntegrationTests {
@TestTemplate
void jarWithCustomName() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
assertThat(properties).containsEntry("build.artifact", "foo");
@@ -66,7 +66,7 @@ class BuildInfoDslIntegrationTests {
@TestTemplate
void basicWar() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
assertThat(properties).containsEntry("build.artifact", this.gradleBuild.getProjectDir().getName());
@@ -77,7 +77,7 @@ class BuildInfoDslIntegrationTests {
@TestTemplate
void warWithCustomName() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
assertThat(properties).containsEntry("build.artifact", "foo");
@@ -88,7 +88,7 @@ class BuildInfoDslIntegrationTests {
@TestTemplate
void additionalProperties() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
assertThat(properties).containsEntry("build.artifact", this.gradleBuild.getProjectDir().getName());
@@ -101,7 +101,7 @@ class BuildInfoDslIntegrationTests {
@TestTemplate
void classesDependency() {
assertThat(this.gradleBuild.build("classes", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
}
private Properties buildInfoProperties() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -49,11 +49,12 @@ final class GradleCompatibilityExtension implements TestTemplateInvocationContex
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
Stream<String> gradleVersions = GRADLE_VERSIONS.stream();
GradleCompatibility gradleCompatibility = AnnotationUtils
.findAnnotation(context.getRequiredTestClass(), GradleCompatibility.class).get();
.findAnnotation(context.getRequiredTestClass(), GradleCompatibility.class)
.get();
if (StringUtils.hasText(gradleCompatibility.versionsLessThan())) {
GradleVersion upperExclusive = GradleVersion.version(gradleCompatibility.versionsLessThan());
gradleVersions = gradleVersions
.filter((version) -> GradleVersion.version(version).compareTo(upperExclusive) < 0);
.filter((version) -> GradleVersion.version(version).compareTo(upperExclusive) < 0);
}
return gradleVersions.flatMap((version) -> {
List<TestTemplateInvocationContext> invocationContexts = new ArrayList<>();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -55,37 +55,37 @@ class ApplicationPluginActionIntegrationTests {
@TestTemplate
void noBootDistributionWithoutApplicationPluginApplied() {
assertThat(this.gradleBuild.build("distributionExists", "-PdistributionName=boot").getOutput())
.contains("boot exists = false");
.contains("boot exists = false");
}
@TestTemplate
void applyingApplicationPluginCreatesBootDistribution() {
assertThat(this.gradleBuild.build("distributionExists", "-PdistributionName=boot", "-PapplyApplicationPlugin")
.getOutput()).contains("boot exists = true");
.getOutput()).contains("boot exists = true");
}
@TestTemplate
void noBootStartScriptsTaskWithoutApplicationPluginApplied() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootStartScripts").getOutput())
.contains("bootStartScripts exists = false");
.contains("bootStartScripts exists = false");
}
@TestTemplate
void applyingApplicationPluginCreatesBootStartScriptsTask() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootStartScripts", "-PapplyApplicationPlugin")
.getOutput()).contains("bootStartScripts exists = true");
.getOutput()).contains("bootStartScripts exists = true");
}
@TestTemplate
void createsBootStartScriptsTaskUsesApplicationPluginsDefaultJvmOpts() {
assertThat(this.gradleBuild.build("startScriptsDefaultJvmOpts", "-PapplyApplicationPlugin").getOutput())
.contains("bootStartScripts defaultJvmOpts = [-Dcom.example.a=alpha, -Dcom.example.b=bravo]");
.contains("bootStartScripts defaultJvmOpts = [-Dcom.example.a=alpha, -Dcom.example.b=bravo]");
}
@TestTemplate
void zipDistributionForJarCanBeBuilt() throws IOException {
assertThat(this.gradleBuild.build("bootDistZip").task(":bootDistZip").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
String name = this.gradleBuild.getProjectDir().getName();
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.zip");
assertThat(distribution).isFile();
@@ -97,7 +97,7 @@ class ApplicationPluginActionIntegrationTests {
@TestTemplate
void tarDistributionForJarCanBeBuilt() throws IOException {
assertThat(this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
String name = this.gradleBuild.getProjectDir().getName();
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.tar");
assertThat(distribution).isFile();
@@ -109,7 +109,7 @@ class ApplicationPluginActionIntegrationTests {
@TestTemplate
void zipDistributionForWarCanBeBuilt() throws IOException {
assertThat(this.gradleBuild.build("bootDistZip").task(":bootDistZip").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
String name = this.gradleBuild.getProjectDir().getName();
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.zip");
assertThat(distribution).isFile();
@@ -121,7 +121,7 @@ class ApplicationPluginActionIntegrationTests {
@TestTemplate
void tarDistributionForWarCanBeBuilt() throws IOException {
assertThat(this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
String name = this.gradleBuild.getProjectDir().getName();
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.tar");
assertThat(distribution).isFile();
@@ -133,7 +133,7 @@ class ApplicationPluginActionIntegrationTests {
@TestTemplate
void applicationNameCanBeUsedToCustomizeDistributionName() throws IOException {
assertThat(this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/custom-boot.tar");
assertThat(distribution).isFile();
String name = this.gradleBuild.getProjectDir().getName();
@@ -145,7 +145,7 @@ class ApplicationPluginActionIntegrationTests {
@TestTemplate
void scriptsHaveCorrectPermissions() throws IOException {
assertThat(this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
String name = this.gradleBuild.getProjectDir().getName();
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.tar");
assertThat(distribution).isFile();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 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.
@@ -37,14 +37,16 @@ class DependencyManagementPluginActionIntegrationTests {
@TestTemplate
void noDependencyManagementIsAppliedByDefault() {
assertThat(this.gradleBuild.build("doesNotHaveDependencyManagement").task(":doesNotHaveDependencyManagement")
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.build("doesNotHaveDependencyManagement")
.task(":doesNotHaveDependencyManagement")
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate
void bomIsImportedWhenDependencyManagementPluginIsApplied() {
assertThat(this.gradleBuild.build("hasDependencyManagement", "-PapplyDependencyManagementPlugin")
.task(":hasDependencyManagement").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
.task(":hasDependencyManagement")
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -48,52 +48,53 @@ class JavaPluginActionIntegrationTests {
@TestTemplate
void noBootJarTaskWithoutJavaPluginApplied() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootJar").getOutput())
.contains("bootJar exists = false");
.contains("bootJar exists = false");
}
@TestTemplate
void applyingJavaPluginCreatesBootJarTask() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootJar", "-PapplyJavaPlugin").getOutput())
.contains("bootJar exists = true");
.contains("bootJar exists = true");
}
@TestTemplate
void noBootRunTaskWithoutJavaPluginApplied() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootRun").getOutput())
.contains("bootRun exists = false");
.contains("bootRun exists = false");
}
@TestTemplate
void applyingJavaPluginCreatesBootRunTask() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootRun", "-PapplyJavaPlugin").getOutput())
.contains("bootRun exists = true");
.contains("bootRun exists = true");
}
@TestTemplate
void javaCompileTasksUseUtf8Encoding() {
assertThat(this.gradleBuild.build("javaCompileEncoding", "-PapplyJavaPlugin").getOutput())
.contains("compileJava = UTF-8").contains("compileTestJava = UTF-8");
.contains("compileJava = UTF-8")
.contains("compileTestJava = UTF-8");
}
@TestTemplate
void javaCompileTasksUseParametersCompilerFlagByDefault() {
assertThat(this.gradleBuild.build("javaCompileTasksCompilerArgs").getOutput())
.contains("compileJava compiler args: [-parameters]")
.contains("compileTestJava compiler args: [-parameters]");
.contains("compileJava compiler args: [-parameters]")
.contains("compileTestJava compiler args: [-parameters]");
}
@TestTemplate
void javaCompileTasksUseParametersAndAdditionalCompilerFlags() {
assertThat(this.gradleBuild.build("javaCompileTasksCompilerArgs").getOutput())
.contains("compileJava compiler args: [-parameters, -Xlint:all]")
.contains("compileTestJava compiler args: [-parameters, -Xlint:all]");
.contains("compileJava compiler args: [-parameters, -Xlint:all]")
.contains("compileTestJava compiler args: [-parameters, -Xlint:all]");
}
@TestTemplate
void javaCompileTasksCanOverrideDefaultParametersCompilerFlag() {
assertThat(this.gradleBuild.build("javaCompileTasksCompilerArgs").getOutput())
.contains("compileJava compiler args: [-Xlint:all]")
.contains("compileTestJava compiler args: [-Xlint:all]");
.contains("compileJava compiler args: [-Xlint:all]")
.contains("compileTestJava compiler args: [-Xlint:all]");
}
@TestTemplate
@@ -120,7 +121,7 @@ class JavaPluginActionIntegrationTests {
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();
.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."
@@ -139,27 +140,32 @@ class JavaPluginActionIntegrationTests {
@TestTemplate
void applyingJavaPluginCreatesDevelopmentOnlyConfiguration() {
assertThat(this.gradleBuild
.build("configurationExists", "-PconfigurationName=developmentOnly", "-PapplyJavaPlugin").getOutput())
.contains("developmentOnly exists = true");
.build("configurationExists", "-PconfigurationName=developmentOnly", "-PapplyJavaPlugin")
.getOutput()).contains("developmentOnly exists = true");
}
@TestTemplate
void productionRuntimeClasspathIsConfiguredWithAttributes() {
assertThat(this.gradleBuild
.build("configurationAttributes", "-PconfigurationName=productionRuntimeClasspath", "-PapplyJavaPlugin")
.getOutput()).contains("3 productionRuntimeClasspath attributes:")
.contains("org.gradle.usage: java-runtime").contains("org.gradle.libraryelements: jar")
.contains("org.gradle.dependency.bundling: external");
.build("configurationAttributes", "-PconfigurationName=productionRuntimeClasspath", "-PapplyJavaPlugin")
.getOutput()).contains("3 productionRuntimeClasspath attributes:")
.contains("org.gradle.usage: java-runtime")
.contains("org.gradle.libraryelements: jar")
.contains("org.gradle.dependency.bundling: external");
}
@TestTemplate
void productionRuntimeClasspathIsConfiguredWithResolvabilityAndConsumabilityThatMatchesRuntimeClasspath() {
String runtime = this.gradleBuild.build("configurationResolvabilityAndConsumability",
"-PconfigurationName=runtimeClasspath", "-PapplyJavaPlugin").getOutput();
String runtime = this.gradleBuild
.build("configurationResolvabilityAndConsumability", "-PconfigurationName=runtimeClasspath",
"-PapplyJavaPlugin")
.getOutput();
assertThat(runtime).contains("canBeResolved: true");
assertThat(runtime).contains("canBeConsumed: false");
String productionRuntime = this.gradleBuild.build("configurationResolvabilityAndConsumability",
"-PconfigurationName=productionRuntimeClasspath", "-PapplyJavaPlugin").getOutput();
String productionRuntime = this.gradleBuild
.build("configurationResolvabilityAndConsumability", "-PconfigurationName=productionRuntimeClasspath",
"-PapplyJavaPlugin")
.getOutput();
assertThat(productionRuntime).contains("canBeResolved: true");
assertThat(productionRuntime).contains("canBeConsumed: false");
}
@@ -177,7 +183,7 @@ class JavaPluginActionIntegrationTests {
}
}
if (!this.gradleBuild.isConfigurationCache() && GradleVersion.version(this.gradleBuild.getGradleVersion())
.compareTo(GradleVersion.version("7.3.3")) < 0) {
.compareTo(GradleVersion.version("7.3.3")) < 0) {
assertThat(configured).containsExactly("help");
}
else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -49,20 +49,22 @@ class KotlinPluginActionIntegrationTests {
@TestTemplate
void kotlinVersionPropertyIsSet() {
String output = this.gradleBuild.build("kotlinVersion", "dependencies", "--configuration", "compileClasspath")
.getOutput();
.getOutput();
assertThat(output).containsPattern("Kotlin version: [0-9]\\.[0-9]\\.[0-9]+");
}
@TestTemplate
void kotlinCompileTasksUseJavaParametersFlagByDefault() {
assertThat(this.gradleBuild.build("kotlinCompileTasksJavaParameters").getOutput())
.contains("compileKotlin java parameters: true").contains("compileTestKotlin java parameters: true");
.contains("compileKotlin java parameters: true")
.contains("compileTestKotlin java parameters: true");
}
@TestTemplate
void kotlinCompileTasksCanOverrideDefaultJavaParametersFlag() {
assertThat(this.gradleBuild.build("kotlinCompileTasksJavaParameters").getOutput())
.contains("compileKotlin java parameters: false").contains("compileTestKotlin java parameters: false");
.contains("compileKotlin java parameters: false")
.contains("compileTestKotlin java parameters: false");
}
@TestTemplate

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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 @@ class NativeImagePluginActionIntegrationTests {
@TestTemplate
void applyingNativeImagePluginAppliesAotPlugin() {
assertThat(this.gradleBuild.build("aotPluginApplied").getOutput())
.contains("org.springframework.boot.aot applied = true");
.contains("org.springframework.boot.aot applied = true");
}
@TestTemplate

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 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.
@@ -37,7 +37,7 @@ class OnlyDependencyManagementIntegrationTests {
@TestTemplate
void dependencyManagementCanBeConfiguredUsingCoordinatesConstant() {
assertThat(this.gradleBuild.build("dependencyManagement").getOutput())
.contains("org.springframework.boot:spring-boot-starter ");
.contains("org.springframework.boot:spring-boot-starter ");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -42,25 +42,25 @@ class SpringBootAotPluginIntegrationTests {
@TestTemplate
void noProcessAotTaskWithoutAotPluginApplied() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=processAot").getOutput())
.contains("processAot exists = false");
.contains("processAot exists = false");
}
@TestTemplate
void noProcessTestAotTaskWithoutAotPluginApplied() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=processTestAot").getOutput())
.contains("processTestAot exists = false");
.contains("processTestAot exists = false");
}
@TestTemplate
void applyingAotPluginCreatesProcessAotTask() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=processAot").getOutput())
.contains("processAot exists = true");
.contains("processAot exists = true");
}
@TestTemplate
void applyingAotPluginCreatesProcessTestAotTask() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=processTestAot").getOutput())
.contains("processTestAot exists = true");
.contains("processTestAot exists = true");
}
@TestTemplate
@@ -100,13 +100,13 @@ class SpringBootAotPluginIntegrationTests {
writeMainClass("org.springframework.boot", "SpringApplicationAotProcessor");
writeMainClass("com.example", "Main");
assertThat(this.gradleBuild.build("processAot").task(":processAot").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate
void processTestAotIsSkippedWhenProjectHasNoTestSource() {
assertThat(this.gradleBuild.build("processTestAot").task(":processTestAot").getOutcome())
.isEqualTo(TaskOutcome.NO_SOURCE);
.isEqualTo(TaskOutcome.NO_SOURCE);
}
private void writeMainClass(String packageName, String className) throws IOException {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -39,7 +39,7 @@ class SpringBootPluginIntegrationTests {
void failFastWithVersionOfGradle7LowerThanRequired() {
BuildResult result = this.gradleBuild.gradleVersion("7.3.3").buildAndFail();
assertThat(result.getOutput())
.contains("Spring Boot plugin requires Gradle 7.x (7.4 or later). The current version is Gradle 7.3.3");
.contains("Spring Boot plugin requires Gradle 7.x (7.4 or later). The current version is Gradle 7.3.3");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 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.
@@ -45,7 +45,7 @@ class SpringBootPluginTests {
Project project = GradleProjectBuilder.builder().withProjectDir(this.temp).build();
project.getPlugins().apply(SpringBootPlugin.class);
Configuration bootArchives = project.getConfigurations()
.getByName(SpringBootPlugin.BOOT_ARCHIVES_CONFIGURATION_NAME);
.getByName(SpringBootPlugin.BOOT_ARCHIVES_CONFIGURATION_NAME);
assertThat(bootArchives.isCanBeResolved()).isFalse();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -46,13 +46,13 @@ class WarPluginActionIntegrationTests {
@TestTemplate
void noBootWarTaskWithoutWarPluginApplied() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootWar").getOutput())
.contains("bootWar exists = false");
.contains("bootWar exists = false");
}
@TestTemplate
void applyingWarPluginCreatesBootWarTask() {
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootWar", "-PapplyWarPlugin").getOutput())
.contains("bootWar exists = true");
.contains("bootWar exists = true");
}
@TestTemplate

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -84,17 +84,21 @@ class BuildInfoIntegrationTests {
@TestTemplate
void upToDateWhenExecutedTwiceWithFixedTime() {
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo").getOutcome())
.isEqualTo(TaskOutcome.UP_TO_DATE);
.isEqualTo(TaskOutcome.UP_TO_DATE);
}
@TestTemplate
void notUpToDateWhenExecutedTwiceWithFixedTimeAndChangedProjectVersion() {
assertThat(this.gradleBuild.scriptProperty("projectVersion", "0.1.0").build("buildInfo").task(":buildInfo")
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("projectVersion", "0.2.0").build("buildInfo").task(":buildInfo")
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("projectVersion", "0.1.0")
.build("buildInfo")
.task(":buildInfo")
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("projectVersion", "0.2.0")
.build("buildInfo")
.task(":buildInfo")
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate
@@ -111,13 +115,13 @@ class BuildInfoIntegrationTests {
@TestTemplate
void reproducibleOutputWithFixedTime() throws IOException, InterruptedException {
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
File buildInfoProperties = new File(this.gradleBuild.getProjectDir(), "build/buildInfo/build-info.properties");
String firstHash = FileUtils.sha1Hash(buildInfoProperties);
assertThat(buildInfoProperties.delete()).isTrue();
Thread.sleep(1500);
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
String secondHash = FileUtils.sha1Hash(buildInfoProperties);
assertThat(firstHash).isEqualTo(secondHash);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -168,14 +168,15 @@ class BuildInfoTests {
void nullAdditionalPropertyProducesInformativeFailure() {
BuildInfo task = createTask(createProject("test"));
assertThatThrownBy(() -> task.getProperties().getAdditional().put("a", null))
.hasMessage("Cannot add an entry with a null value to a property of type Map.");
.hasMessage("Cannot add an entry with a null value to a property of type Map.");
}
private Project createProject(String projectName) {
File projectDir = new File(this.temp, projectName);
Project project = GradleProjectBuilder.builder().withProjectDir(projectDir).withName(projectName).build();
((ProjectInternal) project).getServices().get(GradlePropertiesController.class)
.loadGradlePropertiesFrom(projectDir);
((ProjectInternal) project).getServices()
.get(GradlePropertiesController.class)
.loadGradlePropertiesFrom(projectDir);
return project;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -85,18 +85,18 @@ abstract class AbstractBootArchiveIntegrationTests {
@TestTemplate
void basicBuild() {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate
void reproducibleArchive() throws IOException, InterruptedException {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
File jar = new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0];
String firstHash = FileUtils.sha1Hash(jar);
Thread.sleep(1500);
assertThat(this.gradleBuild.build("clean", this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
String secondHash = FileUtils.sha1Hash(jar);
assertThat(firstHash).isEqualTo(secondHash);
}
@@ -104,67 +104,81 @@ abstract class AbstractBootArchiveIntegrationTests {
@TestTemplate
void upToDateWhenBuiltTwice() {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.UP_TO_DATE);
.isEqualTo(TaskOutcome.UP_TO_DATE);
}
@TestTemplate
void upToDateWhenBuiltTwiceWithLaunchScriptIncluded() {
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName).task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName).task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
}
@TestTemplate
void notUpToDateWhenLaunchScriptWasNotIncludedAndThenIsIncluded() {
assertThat(this.gradleBuild.scriptProperty("launchScript", "").build(this.taskName).task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("launchScript", "launchScript()").build(this.taskName)
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("launchScript", "")
.build(this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("launchScript", "launchScript()")
.build(this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate
void notUpToDateWhenLaunchScriptWasIncludedAndThenIsNotIncluded() {
assertThat(this.gradleBuild.scriptProperty("launchScript", "launchScript()").build(this.taskName)
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("launchScript", "").build(this.taskName).task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("launchScript", "launchScript()")
.build(this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("launchScript", "")
.build(this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate
void notUpToDateWhenLaunchScriptPropertyChanges() {
assertThat(this.gradleBuild.scriptProperty("launchScriptProperty", "alpha").build(this.taskName)
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("launchScriptProperty", "bravo").build(this.taskName)
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("launchScriptProperty", "alpha")
.build(this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("launchScriptProperty", "bravo")
.build(this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate
void applicationPluginMainClassNameIsUsed() throws IOException {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class"))
.isEqualTo("com.example.CustomMain");
.isEqualTo("com.example.CustomMain");
}
}
@TestTemplate
void springBootExtensionMainClassNameIsUsed() throws IOException {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class"))
.isEqualTo("com.example.CustomMain");
.isEqualTo("com.example.CustomMain");
}
}
@TestTemplate
void duplicatesAreHandledGracefully() {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate
@@ -173,13 +187,17 @@ abstract class AbstractBootArchiveIntegrationTests {
srcMainResources.mkdirs();
new File(srcMainResources, "resource").createNewFile();
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
Stream<String> libEntryNames = jarFile.stream().filter((entry) -> !entry.isDirectory())
.map(JarEntry::getName).filter((name) -> name.startsWith(this.libPath));
Stream<String> libEntryNames = jarFile.stream()
.filter((entry) -> !entry.isDirectory())
.map(JarEntry::getName)
.filter((name) -> name.startsWith(this.libPath));
assertThat(libEntryNames).containsExactly(this.libPath + "commons-io-2.6.jar");
Stream<String> classesEntryNames = jarFile.stream().filter((entry) -> !entry.isDirectory())
.map(JarEntry::getName).filter((name) -> name.startsWith(this.classesPath));
Stream<String> classesEntryNames = jarFile.stream()
.filter((entry) -> !entry.isDirectory())
.map(JarEntry::getName)
.filter((name) -> name.startsWith(this.classesPath));
assertThat(classesEntryNames).containsExactly(this.classesPath + "resource");
}
}
@@ -187,10 +205,12 @@ abstract class AbstractBootArchiveIntegrationTests {
@TestTemplate
void developmentOnlyDependenciesCanBeIncludedInTheArchive() throws IOException {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
Stream<String> libEntryNames = jarFile.stream().filter((entry) -> !entry.isDirectory())
.map(JarEntry::getName).filter((name) -> name.startsWith(this.libPath));
Stream<String> libEntryNames = jarFile.stream()
.filter((entry) -> !entry.isDirectory())
.map(JarEntry::getName)
.filter((name) -> name.startsWith(this.libPath));
assertThat(libEntryNames).containsExactly(this.libPath + "commons-io-2.6.jar",
this.libPath + "commons-lang3-3.9.jar");
}
@@ -202,10 +222,12 @@ abstract class AbstractBootArchiveIntegrationTests {
createDependenciesStarterJar(new File(flatDirRepository, "starter.jar"));
createStandardJar(new File(flatDirRepository, "standard.jar"));
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
Stream<String> libEntryNames = jarFile.stream().filter((entry) -> !entry.isDirectory())
.map(JarEntry::getName).filter((name) -> name.startsWith(this.libPath));
Stream<String> libEntryNames = jarFile.stream()
.filter((entry) -> !entry.isDirectory())
.map(JarEntry::getName)
.filter((name) -> name.startsWith(this.libPath));
assertThat(libEntryNames).containsExactly(this.libPath + "standard.jar");
}
}
@@ -214,44 +236,56 @@ abstract class AbstractBootArchiveIntegrationTests {
void startClassIsSetByResolvingTheMainClass() throws IOException {
copyMainClassApplication();
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
Attributes mainAttributes = jarFile.getManifest().getMainAttributes();
assertThat(mainAttributes.getValue("Start-Class"))
.isEqualTo("com.example." + this.taskName.toLowerCase(Locale.ENGLISH) + ".main.CustomMainClass");
.isEqualTo("com.example." + this.taskName.toLowerCase(Locale.ENGLISH) + ".main.CustomMainClass");
}
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.UP_TO_DATE);
.isEqualTo(TaskOutcome.UP_TO_DATE);
}
@TestTemplate
void upToDateWhenBuiltWithDefaultLayeredAndThenWithExplicitLayered() {
assertThat(this.gradleBuild.scriptProperty("layered", "").build("" + this.taskName).task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("layered", "layered {}").build("" + this.taskName)
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
assertThat(this.gradleBuild.scriptProperty("layered", "")
.build("" + this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("layered", "layered {}")
.build("" + this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
}
@TestTemplate
void notUpToDateWhenBuiltWithoutLayersAndThenWithLayers() {
assertThat(this.gradleBuild.scriptProperty("layerEnablement", "enabled = false").build(this.taskName)
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("layerEnablement", "enabled = true").build(this.taskName)
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("layerEnablement", "enabled = false")
.build(this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("layerEnablement", "enabled = true")
.build(this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate
void notUpToDateWhenBuiltWithLayerToolsAndThenWithoutLayerTools() {
assertThat(this.gradleBuild.scriptProperty("layerTools", "").build(this.taskName).task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("layerTools", "includeLayerTools = false").build(this.taskName)
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("layerTools", "")
.build(this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("layerTools", "includeLayerTools = false")
.build(this.taskName)
.task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate
void layersWithCustomSourceSet() {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate
@@ -259,7 +293,7 @@ abstract class AbstractBootArchiveIntegrationTests {
writeMainClass();
writeResource();
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
Map<String, List<String>> indexedLayers;
String layerToolsJar = this.libPath + JarModeLibrary.LAYER_TOOLS.getName();
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
@@ -293,7 +327,7 @@ abstract class AbstractBootArchiveIntegrationTests {
assertThat(indexedLayers.get("spring-boot-loader")).containsExactly("org/");
assertThat(indexedLayers.get("snapshot-dependencies")).containsExactlyElementsOf(expectedSnapshotDependencies);
assertThat(indexedLayers.get("application"))
.containsExactly(getExpectedApplicationLayerContents(this.classesPath));
.containsExactly(getExpectedApplicationLayerContents(this.classesPath));
BuildResult listLayers = this.gradleBuild.build("listLayers");
assertThat(listLayers.task(":listLayers").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
String listLayersOutput = listLayers.getOutput();
@@ -311,7 +345,7 @@ abstract class AbstractBootArchiveIntegrationTests {
writeMainClass();
writeResource();
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
Map<String, List<String>> indexedLayers;
String layerToolsJar = this.libPath + JarModeLibrary.LAYER_TOOLS.getName();
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
@@ -341,8 +375,8 @@ abstract class AbstractBootArchiveIntegrationTests {
assertThat(indexedLayers.get("spring-boot-loader")).containsExactly("org/");
assertThat(indexedLayers.get("snapshot-dependencies")).containsExactlyElementsOf(expectedSnapshotDependencies);
assertThat(indexedLayers.get("application"))
.containsExactly(getExpectedApplicationLayerContents(this.classesPath, this.libPath + "alpha-1.2.3.jar",
this.libPath + "bravo-1.2.3.jar", this.libPath + "charlie-1.2.3.jar"));
.containsExactly(getExpectedApplicationLayerContents(this.classesPath, this.libPath + "alpha-1.2.3.jar",
this.libPath + "bravo-1.2.3.jar", this.libPath + "charlie-1.2.3.jar"));
BuildResult listLayers = this.gradleBuild.build("listLayers");
assertThat(listLayers.task(":listLayers").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
String listLayersOutput = listLayers.getOutput();
@@ -435,7 +469,7 @@ abstract class AbstractBootArchiveIntegrationTests {
expectedSnapshotDependencies.add(this.libPath + "library-1.0-SNAPSHOT.jar");
(layerToolsJar.contains("SNAPSHOT") ? expectedSnapshotDependencies : expectedDependencies).add(layerToolsJar);
assertThat(indexedLayers.get("subproject-dependencies"))
.containsExactlyElementsOf(expectedSubprojectDependencies);
.containsExactlyElementsOf(expectedSubprojectDependencies);
assertThat(indexedLayers.get("dependencies")).containsExactlyElementsOf(expectedDependencies);
assertThat(indexedLayers.get("commons-dependencies")).containsExactly(this.libPath + "commons-lang3-3.9.jar");
assertThat(indexedLayers.get("snapshot-dependencies")).containsExactlyElementsOf(expectedSnapshotDependencies);
@@ -471,8 +505,10 @@ abstract class AbstractBootArchiveIntegrationTests {
BuildResult build = this.gradleBuild.build(this.taskName);
assertThat(build.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
Stream<String> classesEntryNames = jarFile.stream().filter((entry) -> !entry.isDirectory())
.map(JarEntry::getName).filter((name) -> name.startsWith(this.classesPath));
Stream<String> classesEntryNames = jarFile.stream()
.filter((entry) -> !entry.isDirectory())
.map(JarEntry::getName)
.filter((name) -> name.startsWith(this.classesPath));
assertThat(classesEntryNames).containsExactly(this.classesPath + "example/Main.class",
this.classesPath + "example/Secondary.class");
}
@@ -551,8 +587,9 @@ abstract class AbstractBootArchiveIntegrationTests {
private void writeResource() {
try {
Path path = this.gradleBuild.getProjectDir().toPath()
.resolve(Paths.get("src", "main", "resources", "static", "file.txt"));
Path path = this.gradleBuild.getProjectDir()
.toPath()
.resolve(Paths.get("src", "main", "resources", "static", "file.txt"));
Files.createDirectories(path.getParent());
Files.createFile(path);
}
@@ -587,8 +624,11 @@ abstract class AbstractBootArchiveIntegrationTests {
assertThat(layer).isDirectory();
List<String> files;
try (Stream<Path> pathStream = Files.walk(layer.toPath())) {
files = pathStream.filter((path) -> path.toFile().isFile()).map(layer.toPath()::relativize)
.map(Path::toString).map(StringUtils::cleanPath).toList();
files = pathStream.filter((path) -> path.toFile().isFile())
.map(layer.toPath()::relativize)
.map(Path::toString)
.map(StringUtils::cleanPath)
.toList();
}
extractedLayers.put(layerName, files);
}

View File

@@ -129,11 +129,11 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class")).isEqualTo(this.launcherClass);
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class")).isEqualTo("com.example.Main");
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Classes"))
.isEqualTo(this.classesPath);
.isEqualTo(this.classesPath);
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Lib")).isEqualTo(this.libPath);
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Version")).isNotNull();
assertThat(jarFile.getManifest().getMainAttributes().getValue("Implementation-Title"))
.isEqualTo(this.project.getName());
.isEqualTo(this.project.getName());
assertThat(jarFile.getManifest().getMainAttributes().getValue("Implementation-Version")).isNull();
}
}
@@ -145,7 +145,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
executeTask();
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Implementation-Title"))
.isEqualTo("Customized");
.isEqualTo("Customized");
}
}
@@ -167,7 +167,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
executeTask();
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Implementation-Version"))
.isEqualTo("Customized");
.isEqualTo("Customized");
}
}
@@ -177,10 +177,12 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this.task.classpath(jarFile("one.jar"), jarFile("two.jar"));
executeTask();
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
assertThat(jarFile.getEntry(this.libPath + "one.jar")).isNotNull().extracting(ZipEntry::getMethod)
.isEqualTo(ZipEntry.STORED);
assertThat(jarFile.getEntry(this.libPath + "two.jar")).isNotNull().extracting(ZipEntry::getMethod)
.isEqualTo(ZipEntry.STORED);
assertThat(jarFile.getEntry(this.libPath + "one.jar")).isNotNull()
.extracting(ZipEntry::getMethod)
.isEqualTo(ZipEntry.STORED);
assertThat(jarFile.getEntry(this.libPath + "two.jar")).isNotNull()
.extracting(ZipEntry::getMethod)
.isEqualTo(ZipEntry.STORED);
}
}
@@ -314,7 +316,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
properties.put("initInfoDescription", this.project.getDescription());
File archiveFile = this.task.getArchiveFile().get().getAsFile();
assertThat(Files.readAllBytes(archiveFile.toPath()))
.startsWith(new DefaultLaunchScript(null, properties).toByteArray());
.startsWith(new DefaultLaunchScript(null, properties).toByteArray());
try (ZipFile zipFile = new ZipFile(archiveFile)) {
assertThat(zipFile.getEntries().hasMoreElements()).isTrue();
}
@@ -362,7 +364,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
assertThat(this.task.getArchiveFile().get().getAsFile()).exists();
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class"))
.isEqualTo("com.example.CustomLauncher");
.isEqualTo("com.example.CustomLauncher");
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class")).isEqualTo("com.example.Main");
assertThat(jarFile.getEntry("org/springframework/boot/loader/LaunchedURLClassLoader.class")).isNull();
}
@@ -377,7 +379,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class")).isEqualTo(this.launcherClass);
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class"))
.isEqualTo("com.example.CustomMain");
.isEqualTo("com.example.CustomMain");
}
}
@@ -399,7 +401,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
@Test
void constantTimestampMatchesGradleInternalTimestamp() {
assertThat(BootZipCopyAction.CONSTANT_TIME_FOR_ZIP_ENTRIES)
.isEqualTo(ZipCopyAction.CONSTANT_TIME_FOR_ZIP_ENTRIES);
.isEqualTo(ZipCopyAction.CONSTANT_TIME_FOR_ZIP_ENTRIES);
}
@Test
@@ -477,10 +479,10 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
executeTask();
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Classes"))
.isEqualTo(this.classesPath);
.isEqualTo(this.classesPath);
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Lib")).isEqualTo(this.libPath);
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Layers-Index"))
.isEqualTo(this.indexPath + "layers.idx");
.isEqualTo(this.indexPath + "layers.idx");
assertThat(getEntryNames(jarFile)).contains(this.libPath + JarModeLibrary.LAYER_TOOLS.getName());
}
}
@@ -496,10 +498,10 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
void whenJarIsLayeredThenManifestContainsEntryForLayersIndexInPlaceOfClassesAndLib() throws IOException {
try (JarFile jarFile = new JarFile(createLayeredJar())) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Classes"))
.isEqualTo(this.classesPath);
.isEqualTo(this.classesPath);
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Lib")).isEqualTo(this.libPath);
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Layers-Index"))
.isEqualTo(this.indexPath + "layers.idx");
.isEqualTo(this.indexPath + "layers.idx");
}
}
@@ -557,7 +559,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
dependencies.intoLayer("my-deps");
});
layered.getLayerOrder()
.set(List.of("my-deps", "my-internal-deps", "my-snapshot-deps", "resources", "application"));
.set(List.of("my-deps", "my-internal-deps", "my-snapshot-deps", "resources", "application"));
});
try (JarFile jarFile = new JarFile(jar)) {
List<String> entryNames = getEntryNames(jar);
@@ -607,7 +609,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
List<String> entryNames = getEntryNames(
createLayeredJar((configuration) -> configuration.getIncludeLayerTools().set(false)));
assertThat(entryNames)
.doesNotContain(this.indexPath + "layers/dependencies/lib/spring-boot-jarmode-layertools.jar");
.doesNotContain(this.indexPath + "layers/dependencies/lib/spring-boot-jarmode-layertools.jar");
}
protected File jarFile(String name) throws IOException {
@@ -718,11 +720,11 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
Set<ResolvedArtifact> artifacts = new LinkedHashSet<>();
artifacts.add(mockLibraryArtifact("first-library.jar", "com.example", "first-library", "1.0.0"));
artifacts.add(mockLibraryArtifact("second-library.jar", "com.example", "second-library", "1.0.0"));
artifacts.add(
mockLibraryArtifact("third-library-SNAPSHOT.jar", "com.example", "third-library", "1.0.0.SNAPSHOT"));
artifacts
.add(mockLibraryArtifact("third-library-SNAPSHOT.jar", "com.example", "third-library", "1.0.0.SNAPSHOT"));
artifacts.add(mockLibraryArtifact("fourth-library.jar", "com.example", "fourth-library", "1.0.0"));
artifacts
.add(mockProjectArtifact("first-project-library.jar", "com.example", "first-project-library", "1.0.0"));
.add(mockProjectArtifact("first-project-library.jar", "com.example", "first-project-library", "1.0.0"));
artifacts.add(mockProjectArtifact("second-project-library-SNAPSHOT.jar", "com.example",
"second-project-library", "1.0.0.SNAPSHOT"));
ResolvedConfiguration resolvedConfiguration = mock(ResolvedConfiguration.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -90,7 +90,7 @@ class BootBuildImageIntegrationTests {
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
assertThat(buildLibs.listFiles())
.containsExactly(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".war"));
.containsExactly(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".war"));
removeImages(projectName);
}
@@ -106,7 +106,7 @@ class BootBuildImageIntegrationTests {
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
assertThat(buildLibs.listFiles())
.containsExactly(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".war"));
.containsExactly(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".war"));
removeImages(projectName);
}
@@ -172,7 +172,7 @@ class BootBuildImageIntegrationTests {
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
assertThat(result.getOutput()).contains("---> Test Info buildpack building")
.contains("---> Test Info buildpack done");
.contains("---> Test Info buildpack done");
removeImages(projectName);
}
@@ -214,7 +214,7 @@ class BootBuildImageIntegrationTests {
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
assertThat(result.getOutput()).contains("---> Test Info buildpack building")
.contains("---> Test Info buildpack done");
.contains("---> Test Info buildpack done");
removeImages(projectName);
}
@@ -307,7 +307,7 @@ class BootBuildImageIntegrationTests {
BuildResult result = this.gradleBuild.buildAndFail("bootBuildImage", "--imageName=example/Invalid-Image-Name");
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.FAILED);
assertThat(result.getOutput()).containsPattern("Unable to parse image reference")
.containsPattern("example/Invalid-Image-Name");
.containsPattern("example/Invalid-Image-Name");
}
@TestTemplate
@@ -326,7 +326,7 @@ class BootBuildImageIntegrationTests {
BuildResult result = this.gradleBuild.buildAndFail("bootBuildImage");
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.FAILED);
assertThat(result.getOutput()).containsPattern("Unable to parse image reference")
.containsPattern("example/Invalid-Tag-Name");
.containsPattern("example/Invalid-Tag-Name");
}
@TestTemplate
@@ -362,17 +362,18 @@ class BootBuildImageIntegrationTests {
private void writeLongNameResource() throws IOException {
StringBuilder name = new StringBuilder();
new Random().ints('a', 'z' + 1).limit(128).forEach((i) -> name.append((char) i));
Path path = this.gradleBuild.getProjectDir().toPath()
.resolve(Paths.get("src", "main", "resources", name.toString()));
Path path = this.gradleBuild.getProjectDir()
.toPath()
.resolve(Paths.get("src", "main", "resources", name.toString()));
Files.createDirectories(path.getParent());
Files.createFile(path);
}
private void writeBuildpackContent() throws IOException {
FileAttribute<Set<PosixFilePermission>> dirAttribute = PosixFilePermissions
.asFileAttribute(PosixFilePermissions.fromString("rwxr-xr-x"));
.asFileAttribute(PosixFilePermissions.fromString("rwxr-xr-x"));
FileAttribute<Set<PosixFilePermission>> execFileAttribute = PosixFilePermissions
.asFileAttribute(PosixFilePermissions.fromString("rwxrwxrwx"));
.asFileAttribute(PosixFilePermissions.fromString("rwxrwxrwx"));
File buildpackDir = new File(this.gradleBuild.getProjectDir(), "buildpack/hello-world");
Files.createDirectories(buildpackDir.toPath(), dirAttribute);
File binDir = new File(buildpackDir, "bin");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 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.
@@ -53,7 +53,7 @@ class BootBuildImageRegistryIntegrationTests {
@Container
static final RegistryContainer registry = new RegistryContainer().withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(3));
.withStartupTimeout(Duration.ofMinutes(3));
String registryAddress;
@@ -72,9 +72,10 @@ class BootBuildImageRegistryIntegrationTests {
String imageName = this.registryAddress + "/" + repoName;
BuildResult result = this.gradleBuild.build("bootBuildImage", "--imageName=" + imageName);
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(result.getOutput()).contains("Building image").contains("Successfully built image")
.contains("Pushing image '" + imageName + ":latest" + "'")
.contains("Pushed image '" + imageName + ":latest" + "'");
assertThat(result.getOutput()).contains("Building image")
.contains("Successfully built image")
.contains("Pushing image '" + imageName + ":latest" + "'")
.contains("Pushed image '" + imageName + ":latest" + "'");
ImageReference imageReference = ImageReference.of(imageName);
Image pulledImage = new DockerApi().image().pull(imageReference, UpdateListener.none());
assertThat(pulledImage).isNotNull();

View File

@@ -103,8 +103,9 @@ class BootBuildImageTests {
void whenIndividualEntriesAreAddedToTheEnvironmentThenTheyAreIncludedInTheRequest() {
this.buildImage.getEnvironment().put("ALPHA", "a");
this.buildImage.getEnvironment().put("BRAVO", "b");
assertThat(this.buildImage.createRequest().getEnv()).containsEntry("ALPHA", "a").containsEntry("BRAVO", "b")
.hasSize(2);
assertThat(this.buildImage.createRequest().getEnv()).containsEntry("ALPHA", "a")
.containsEntry("BRAVO", "b")
.hasSize(2);
}
@Test
@@ -113,8 +114,9 @@ class BootBuildImageTests {
environment.put("ALPHA", "a");
environment.put("BRAVO", "b");
this.buildImage.getEnvironment().putAll(environment);
assertThat(this.buildImage.createRequest().getEnv()).containsEntry("ALPHA", "a").containsEntry("BRAVO", "b")
.hasSize(2);
assertThat(this.buildImage.createRequest().getEnv()).containsEntry("ALPHA", "a")
.containsEntry("BRAVO", "b")
.hasSize(2);
}
@Test
@@ -123,8 +125,9 @@ class BootBuildImageTests {
environment.put("ALPHA", "a");
environment.put("BRAVO", "b");
this.buildImage.getEnvironment().set(environment);
assertThat(this.buildImage.createRequest().getEnv()).containsEntry("ALPHA", "a").containsEntry("BRAVO", "b")
.hasSize(2);
assertThat(this.buildImage.createRequest().getEnv()).containsEntry("ALPHA", "a")
.containsEntry("BRAVO", "b")
.hasSize(2);
}
@Test
@@ -134,8 +137,9 @@ class BootBuildImageTests {
environment.put("BRAVO", "b");
this.buildImage.getEnvironment().put("C", "Charlie");
this.buildImage.getEnvironment().set(environment);
assertThat(this.buildImage.createRequest().getEnv()).containsEntry("ALPHA", "a").containsEntry("BRAVO", "b")
.hasSize(2);
assertThat(this.buildImage.createRequest().getEnv()).containsEntry("ALPHA", "a")
.containsEntry("BRAVO", "b")
.hasSize(2);
}
@Test
@@ -206,23 +210,23 @@ class BootBuildImageTests {
@Test
void whenBuildpacksAreConfiguredThenRequestHasBuildpacks() {
this.buildImage.getBuildpacks().set(Arrays.asList("example/buildpack1", "example/buildpack2"));
assertThat(this.buildImage.createRequest().getBuildpacks()).containsExactly(
BuildpackReference.of("example/buildpack1"), BuildpackReference.of("example/buildpack2"));
assertThat(this.buildImage.createRequest().getBuildpacks())
.containsExactly(BuildpackReference.of("example/buildpack1"), BuildpackReference.of("example/buildpack2"));
}
@Test
void whenEntriesAreAddedToBuildpacksThenRequestHasBuildpacks() {
this.buildImage.getBuildpacks().addAll(Arrays.asList("example/buildpack1", "example/buildpack2"));
assertThat(this.buildImage.createRequest().getBuildpacks()).containsExactly(
BuildpackReference.of("example/buildpack1"), BuildpackReference.of("example/buildpack2"));
assertThat(this.buildImage.createRequest().getBuildpacks())
.containsExactly(BuildpackReference.of("example/buildpack1"), BuildpackReference.of("example/buildpack2"));
}
@Test
void whenIndividualEntriesAreAddedToBuildpacksThenRequestHasBuildpacks() {
this.buildImage.getBuildpacks().add("example/buildpack1");
this.buildImage.getBuildpacks().add("example/buildpack2");
assertThat(this.buildImage.createRequest().getBuildpacks()).containsExactly(
BuildpackReference.of("example/buildpack1"), BuildpackReference.of("example/buildpack2"));
assertThat(this.buildImage.createRequest().getBuildpacks())
.containsExactly(BuildpackReference.of("example/buildpack1"), BuildpackReference.of("example/buildpack2"));
}
@Test
@@ -234,15 +238,15 @@ class BootBuildImageTests {
void whenBindingsAreConfiguredThenRequestHasBindings() {
this.buildImage.getBindings().set(Arrays.asList("host-src:container-dest:ro", "volume-name:container-dest:rw"));
assertThat(this.buildImage.createRequest().getBindings())
.containsExactly(Binding.of("host-src:container-dest:ro"), Binding.of("volume-name:container-dest:rw"));
.containsExactly(Binding.of("host-src:container-dest:ro"), Binding.of("volume-name:container-dest:rw"));
}
@Test
void whenEntriesAreAddedToBindingsThenRequestHasBindings() {
this.buildImage.getBindings()
.addAll(Arrays.asList("host-src:container-dest:ro", "volume-name:container-dest:rw"));
.addAll(Arrays.asList("host-src:container-dest:ro", "volume-name:container-dest:rw"));
assertThat(this.buildImage.createRequest().getBindings())
.containsExactly(Binding.of("host-src:container-dest:ro"), Binding.of("volume-name:container-dest:rw"));
.containsExactly(Binding.of("host-src:container-dest:ro"), Binding.of("volume-name:container-dest:rw"));
}
@Test
@@ -250,7 +254,7 @@ class BootBuildImageTests {
this.buildImage.getBindings().add("host-src:container-dest:ro");
this.buildImage.getBindings().add("volume-name:container-dest:rw");
assertThat(this.buildImage.createRequest().getBindings())
.containsExactly(Binding.of("host-src:container-dest:ro"), Binding.of("volume-name:container-dest:rw"));
.containsExactly(Binding.of("host-src:container-dest:ro"), Binding.of("volume-name:container-dest:rw"));
}
@Test
@@ -267,15 +271,15 @@ class BootBuildImageTests {
@Test
void whenTagsAreConfiguredThenRequestHasTags() {
this.buildImage.getTags()
.set(Arrays.asList("my-app:latest", "example.com/my-app:0.0.1-SNAPSHOT", "example.com/my-app:latest"));
.set(Arrays.asList("my-app:latest", "example.com/my-app:0.0.1-SNAPSHOT", "example.com/my-app:latest"));
assertThat(this.buildImage.createRequest().getTags()).containsExactly(ImageReference.of("my-app:latest"),
ImageReference.of("example.com/my-app:0.0.1-SNAPSHOT"), ImageReference.of("example.com/my-app:latest"));
}
@Test
void whenEntriesAreAddedToTagsThenRequestHasTags() {
this.buildImage.getTags().addAll(
Arrays.asList("my-app:latest", "example.com/my-app:0.0.1-SNAPSHOT", "example.com/my-app:latest"));
this.buildImage.getTags()
.addAll(Arrays.asList("my-app:latest", "example.com/my-app:0.0.1-SNAPSHOT", "example.com/my-app:latest"));
assertThat(this.buildImage.createRequest().getTags()).containsExactly(ImageReference.of("my-app:latest"),
ImageReference.of("example.com/my-app:0.0.1-SNAPSHOT"), ImageReference.of("example.com/my-app:latest"));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 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,7 +47,7 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests {
void whenAResolvableCopyOfAnUnresolvableConfigurationIsResolvedThenResolutionSucceeds() {
BuildResult build = this.gradleBuild.build("resolveResolvableCopyOfUnresolvableConfiguration");
assertThat(build.task(":resolveResolvableCopyOfUnresolvableConfiguration").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
.isEqualTo(TaskOutcome.SUCCESS);
}
@TestTemplate

View File

@@ -99,7 +99,7 @@ class BootJarTests extends AbstractBootArchiveTests<BootJar> {
void classpathIndexPointsToBootInfLibs() throws IOException {
try (JarFile jarFile = new JarFile(createPopulatedJar())) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Classpath-Index"))
.isEqualTo("BOOT-INF/classpath.idx");
.isEqualTo("BOOT-INF/classpath.idx");
assertThat(entryLines(jarFile, "BOOT-INF/classpath.idx")).containsExactly(
"- \"BOOT-INF/lib/first-library.jar\"", "- \"BOOT-INF/lib/second-library.jar\"",
"- \"BOOT-INF/lib/third-library-SNAPSHOT.jar\"", "- \"BOOT-INF/lib/fourth-library.jar\"",
@@ -208,7 +208,7 @@ class BootJarTests extends AbstractBootArchiveTests<BootJar> {
void javaVersionIsWrittenToManifest() throws IOException {
try (JarFile jarFile = new JarFile(createPopulatedJar())) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Build-Jdk-Spec"))
.isEqualTo(JavaVersion.VERSION_17.getMajorVersion());
.isEqualTo(JavaVersion.VERSION_17.getMajorVersion());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -117,7 +117,7 @@ class BootWarTests extends AbstractBootArchiveTests<BootWar> {
getTask().providedClasspath(jarFile("provided-library.jar"));
executeTask();
assertThat(getEntryNames(getTask().getArchiveFile().get().getAsFile()))
.containsSubsequence("WEB-INF/lib/library.jar", "WEB-INF/lib-provided/provided-library.jar");
.containsSubsequence("WEB-INF/lib/library.jar", "WEB-INF/lib-provided/provided-library.jar");
}
@Test
@@ -135,7 +135,7 @@ class BootWarTests extends AbstractBootArchiveTests<BootWar> {
void classpathIndexPointsToWebInfLibs() throws IOException {
try (JarFile jarFile = new JarFile(createPopulatedJar())) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Classpath-Index"))
.isEqualTo("WEB-INF/classpath.idx");
.isEqualTo("WEB-INF/classpath.idx");
assertThat(entryLines(jarFile, "WEB-INF/classpath.idx")).containsExactly(
"- \"WEB-INF/lib/first-library.jar\"", "- \"WEB-INF/lib/second-library.jar\"",
"- \"WEB-INF/lib/third-library-SNAPSHOT.jar\"", "- \"WEB-INF/lib/fourth-library.jar\"",
@@ -148,7 +148,7 @@ class BootWarTests extends AbstractBootArchiveTests<BootWar> {
void javaVersionIsWrittenToManifest() throws IOException {
try (JarFile jarFile = new JarFile(createPopulatedJar())) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Build-Jdk-Spec"))
.isEqualTo(JavaVersion.VERSION_17.getMajorVersion());
.isEqualTo(JavaVersion.VERSION_17.getMajorVersion());
}
}

View File

@@ -43,8 +43,11 @@ class DockerSpecTests {
@BeforeEach
void prepareDockerSpec(@TempDir File temp) {
this.dockerSpec = GradleProjectBuilder.builder().withProjectDir(temp).build().getObjects()
.newInstance(DockerSpec.class);
this.dockerSpec = GradleProjectBuilder.builder()
.withProjectDir(temp)
.build()
.getObjects()
.newInstance(DockerSpec.class);
}
@Test
@@ -53,8 +56,10 @@ class DockerSpecTests {
assertThat(dockerConfiguration.getHost()).isNull();
assertThat(dockerConfiguration.getBuilderRegistryAuthentication()).isNull();
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()))
.contains("\"username\" : \"\"").contains("\"password\" : \"\"").contains("\"email\" : \"\"")
.contains("\"serveraddress\" : \"\"");
.contains("\"username\" : \"\"")
.contains("\"password\" : \"\"")
.contains("\"email\" : \"\"")
.contains("\"serveraddress\" : \"\"");
}
@Test
@@ -70,8 +75,10 @@ class DockerSpecTests {
assertThat(dockerConfiguration.isBindHostToBuilder()).isFalse();
assertThat(this.dockerSpec.asDockerConfiguration().getBuilderRegistryAuthentication()).isNull();
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()))
.contains("\"username\" : \"\"").contains("\"password\" : \"\"").contains("\"email\" : \"\"")
.contains("\"serveraddress\" : \"\"");
.contains("\"username\" : \"\"")
.contains("\"password\" : \"\"")
.contains("\"email\" : \"\"")
.contains("\"serveraddress\" : \"\"");
}
@Test
@@ -85,8 +92,10 @@ class DockerSpecTests {
assertThat(dockerConfiguration.isBindHostToBuilder()).isFalse();
assertThat(this.dockerSpec.asDockerConfiguration().getBuilderRegistryAuthentication()).isNull();
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()))
.contains("\"username\" : \"\"").contains("\"password\" : \"\"").contains("\"email\" : \"\"")
.contains("\"serveraddress\" : \"\"");
.contains("\"username\" : \"\"")
.contains("\"password\" : \"\"")
.contains("\"email\" : \"\"")
.contains("\"serveraddress\" : \"\"");
}
@Test
@@ -101,8 +110,10 @@ class DockerSpecTests {
assertThat(dockerConfiguration.isBindHostToBuilder()).isTrue();
assertThat(this.dockerSpec.asDockerConfiguration().getBuilderRegistryAuthentication()).isNull();
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()))
.contains("\"username\" : \"\"").contains("\"password\" : \"\"").contains("\"email\" : \"\"")
.contains("\"serveraddress\" : \"\"");
.contains("\"username\" : \"\"")
.contains("\"password\" : \"\"")
.contains("\"email\" : \"\"")
.contains("\"serveraddress\" : \"\"");
}
@Test
@@ -121,13 +132,15 @@ class DockerSpecTests {
});
DockerConfiguration dockerConfiguration = this.dockerSpec.asDockerConfiguration();
assertThat(decoded(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()))
.contains("\"username\" : \"user1\"").contains("\"password\" : \"secret1\"")
.contains("\"email\" : \"docker1@example.com\"")
.contains("\"serveraddress\" : \"https://docker1.example.com\"");
.contains("\"username\" : \"user1\"")
.contains("\"password\" : \"secret1\"")
.contains("\"email\" : \"docker1@example.com\"")
.contains("\"serveraddress\" : \"https://docker1.example.com\"");
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()))
.contains("\"username\" : \"user2\"").contains("\"password\" : \"secret2\"")
.contains("\"email\" : \"docker2@example.com\"")
.contains("\"serveraddress\" : \"https://docker2.example.com\"");
.contains("\"username\" : \"user2\"")
.contains("\"password\" : \"secret2\"")
.contains("\"email\" : \"docker2@example.com\"")
.contains("\"serveraddress\" : \"https://docker2.example.com\"");
assertThat(this.dockerSpec.asDockerConfiguration().getHost()).isNull();
}
@@ -139,7 +152,7 @@ class DockerSpecTests {
registry.getEmail().set("docker1@example.com");
});
assertThatExceptionOfType(GradleException.class).isThrownBy(this.dockerSpec::asDockerConfiguration)
.withMessageContaining("Invalid Docker builder registry configuration");
.withMessageContaining("Invalid Docker builder registry configuration");
}
@Test
@@ -150,7 +163,7 @@ class DockerSpecTests {
registry.getEmail().set("docker2@example.com");
});
assertThatExceptionOfType(GradleException.class).isThrownBy(this.dockerSpec::asDockerConfiguration)
.withMessageContaining("Invalid Docker publish registry configuration");
.withMessageContaining("Invalid Docker publish registry configuration");
}
@Test
@@ -159,9 +172,9 @@ class DockerSpecTests {
this.dockerSpec.publishRegistry((registry) -> registry.getToken().set("token2"));
DockerConfiguration dockerConfiguration = this.dockerSpec.asDockerConfiguration();
assertThat(decoded(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()))
.contains("\"identitytoken\" : \"token1\"");
.contains("\"identitytoken\" : \"token1\"");
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()))
.contains("\"identitytoken\" : \"token2\"");
.contains("\"identitytoken\" : \"token2\"");
}
@Test
@@ -172,7 +185,7 @@ class DockerSpecTests {
registry.getToken().set("token");
});
assertThatExceptionOfType(GradleException.class).isThrownBy(this.dockerSpec::asDockerConfiguration)
.withMessageContaining("Invalid Docker builder registry configuration");
.withMessageContaining("Invalid Docker builder registry configuration");
}
String decoded(String value) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 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.
@@ -44,7 +44,10 @@ class MavenPublishingIntegrationTests {
assertThat(result.task(":publish").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(artifactWithSuffix("jar")).isFile();
assertThat(artifactWithSuffix("pom")).is(pomWith().groupId("com.example")
.artifactId(this.gradleBuild.getProjectDir().getName()).version("1.0").noPackaging().noDependencies());
.artifactId(this.gradleBuild.getProjectDir().getName())
.version("1.0")
.noPackaging()
.noDependencies());
}
@TestTemplate
@@ -52,9 +55,11 @@ class MavenPublishingIntegrationTests {
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());
assertThat(artifactWithSuffix("pom")).is(pomWith().groupId("com.example")
.artifactId(this.gradleBuild.getProjectDir().getName())
.version("1.0")
.packaging("war")
.noDependencies());
}
private File artifactWithSuffix(String suffix) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -87,7 +87,7 @@ class BootRunIntegrationTests {
BuildResult result = this.gradleBuild.build("bootRun");
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(result.getOutput())
.contains("Main class name = com.example.bootrun.classpath.BootRunClasspathApplication");
.contains("Main class name = com.example.bootrun.classpath.BootRunClasspathApplication");
}
@TestTemplate
@@ -111,8 +111,9 @@ class BootRunIntegrationTests {
copyJvmArgsApplication();
BuildResult result = this.gradleBuild.build("bootRun");
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(result.getOutput()).contains("-Dcom.bar=baz").contains("-Dcom.foo=bar")
.contains("-XX:TieredStopAtLevel=1");
assertThat(result.getOutput()).contains("-Dcom.bar=baz")
.contains("-Dcom.foo=bar")
.contains("-XX:TieredStopAtLevel=1");
}
@TestTemplate