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.
@@ -143,11 +143,11 @@ class ArtifactsLibrariesTests {
given(snapshotArtifact.getArtifactHandler()).willReturn(this.artifactHandler);
this.artifacts = Collections.singleton(snapshotArtifact);
new ArtifactsLibraries(this.artifacts, Collections.emptyList(), null, mock(Log.class))
.doWithLibraries((library) -> {
assertThat(library.isIncluded()).isTrue();
assertThat(library.isLocal()).isFalse();
assertThat(library.getCoordinates().getVersion()).isEqualTo("1.0-SNAPSHOT");
});
.doWithLibraries((library) -> {
assertThat(library.isIncluded()).isTrue();
assertThat(library.isLocal()).isFalse();
assertThat(library.getCoordinates().getVersion()).isEqualTo("1.0-SNAPSHOT");
});
}
@Test
@@ -162,7 +162,7 @@ class ArtifactsLibrariesTests {
given(mavenProject.getArtifact()).willReturn(artifact);
this.artifacts = Collections.singleton(artifact);
new ArtifactsLibraries(this.artifacts, Collections.singleton(mavenProject), null, mock(Log.class))
.doWithLibraries((library) -> assertThat(library.isLocal()).isTrue());
.doWithLibraries((library) -> assertThat(library.isLocal()).isTrue());
}
@Test
@@ -179,7 +179,7 @@ class ArtifactsLibrariesTests {
given(mavenProject.getAttachedArtifacts()).willReturn(Collections.singletonList(attachedArtifact));
this.artifacts = Collections.singleton(attachedArtifact);
new ArtifactsLibraries(this.artifacts, Collections.singleton(mavenProject), null, mock(Log.class))
.doWithLibraries((library) -> assertThat(library.isLocal()).isTrue());
.doWithLibraries((library) -> assertThat(library.isLocal()).isTrue());
}
@Test
@@ -194,7 +194,8 @@ class ArtifactsLibrariesTests {
given(mavenProject.getArtifact()).willReturn(artifact);
this.artifacts = Collections.singleton(artifact);
new ArtifactsLibraries(this.artifacts, Collections.emptySet(), Collections.singleton(mavenProject), null,
mock(Log.class)).doWithLibraries((library) -> assertThat(library.isIncluded()).isFalse());
mock(Log.class))
.doWithLibraries((library) -> assertThat(library.isIncluded()).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.
@@ -36,43 +36,44 @@ class CommandLineBuilderTests {
@Test
void buildWithNullJvmArgumentsIsIgnored() {
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withJvmArguments((String[]) null).build())
.containsExactly(CLASS_NAME);
.containsExactly(CLASS_NAME);
}
@Test
void buildWithNullIntermediateJvmArgumentIsIgnored() {
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withJvmArguments("-verbose:class", null, "-verbose:gc")
.build()).containsExactly("-verbose:class", "-verbose:gc", CLASS_NAME);
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME)
.withJvmArguments("-verbose:class", null, "-verbose:gc")
.build()).containsExactly("-verbose:class", "-verbose:gc", CLASS_NAME);
}
@Test
void buildWithJvmArgument() {
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withJvmArguments("-verbose:class").build())
.containsExactly("-verbose:class", CLASS_NAME);
.containsExactly("-verbose:class", CLASS_NAME);
}
@Test
void buildWithNullSystemPropertyIsIgnored() {
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withSystemProperties(null).build())
.containsExactly(CLASS_NAME);
.containsExactly(CLASS_NAME);
}
@Test
void buildWithSystemProperty() {
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withSystemProperties(Map.of("flag", "enabled")).build())
.containsExactly("-Dflag=\"enabled\"", CLASS_NAME);
.containsExactly("-Dflag=\"enabled\"", CLASS_NAME);
}
@Test
void buildWithNullArgumentsIsIgnored() {
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withArguments((String[]) null).build())
.containsExactly(CLASS_NAME);
.containsExactly(CLASS_NAME);
}
@Test
void buildWithNullIntermediateArgumentIsIgnored() {
assertThat(CommandLineBuilder.forMainClass(CLASS_NAME).withArguments("--test", null, "--another").build())
.containsExactly(CLASS_NAME, "--test", "--another");
.containsExactly(CLASS_NAME, "--test", "--another");
}
}

View File

@@ -52,8 +52,9 @@ class CustomLayersProviderTests {
@Test
void getLayerResolverWhenDocumentValid() throws Exception {
CustomLayers layers = this.customLayersProvider.getLayers(getDocument("layers.xml"));
assertThat(layers).extracting("name").containsExactly("my-deps", "my-dependencies-name",
"snapshot-dependencies", "my-resources", "configuration", "application");
assertThat(layers).extracting("name")
.containsExactly("my-deps", "my-dependencies-name", "snapshot-dependencies", "my-resources",
"configuration", "application");
Library snapshot = mockLibrary("test-SNAPSHOT.jar", "org.foo", "1.0.0-SNAPSHOT");
Library groupId = mockLibrary("my-library", "com.acme", null);
Library otherDependency = mockLibrary("other-library", "org.foo", null);
@@ -81,7 +82,7 @@ class CustomLayersProviderTests {
Library library = mockLibrary("my-library", "com.acme", null);
assertThat(layers.getLayer(library)).hasToString("my-deps");
assertThatIllegalStateException().isThrownBy(() -> layers.getLayer("application.yml"))
.withMessageContaining("match any layer");
.withMessageContaining("match any layer");
}
@Test
@@ -90,7 +91,7 @@ class CustomLayersProviderTests {
Library library = mockLibrary("my-library", "com.acme", null);
assertThat(layers.getLayer("application.yml")).hasToString("my-layer");
assertThatIllegalStateException().isThrownBy(() -> layers.getLayer(library))
.withMessageContaining("match any layer");
.withMessageContaining("match any layer");
}
private Document getDocument(String resourceName) throws Exception {

View File

@@ -41,8 +41,10 @@ class DockerTests {
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
@@ -59,8 +61,10 @@ class DockerTests {
assertThat(dockerConfiguration.isBindHostToBuilder()).isFalse();
assertThat(docker.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
@@ -78,8 +82,10 @@ class DockerTests {
assertThat(dockerConfiguration.isBindHostToBuilder()).isTrue();
assertThat(docker.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
@@ -91,13 +97,15 @@ class DockerTests {
new Docker.DockerRegistry("user2", "secret2", "https://docker2.example.com", "docker2@example.com"));
DockerConfiguration dockerConfiguration = docker.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\"");
}
@Test
@@ -106,7 +114,7 @@ class DockerTests {
docker.setBuilderRegistry(
new Docker.DockerRegistry("user", null, "https://docker.example.com", "docker@example.com"));
assertThatIllegalArgumentException().isThrownBy(docker::asDockerConfiguration)
.withMessageContaining("Invalid Docker builder registry configuration");
.withMessageContaining("Invalid Docker builder registry configuration");
}
@Test
@@ -115,7 +123,7 @@ class DockerTests {
docker.setPublishRegistry(
new Docker.DockerRegistry("user", null, "https://docker.example.com", "docker@example.com"));
assertThatIllegalArgumentException().isThrownBy(docker::asDockerConfiguration)
.withMessageContaining("Invalid Docker publish registry configuration");
.withMessageContaining("Invalid Docker publish registry configuration");
}
@Test
@@ -125,9 +133,9 @@ class DockerTests {
docker.setPublishRegistry(new Docker.DockerRegistry("token2"));
DockerConfiguration dockerConfiguration = docker.asDockerConfiguration();
assertThat(decoded(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()))
.contains("\"identitytoken\" : \"token1\"");
.contains("\"identitytoken\" : \"token1\"");
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()))
.contains("\"identitytoken\" : \"token2\"");
.contains("\"identitytoken\" : \"token2\"");
}
@Test
@@ -139,7 +147,7 @@ class DockerTests {
Docker docker = new Docker();
docker.setBuilderRegistry(dockerRegistry);
assertThatIllegalArgumentException().isThrownBy(docker::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-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.
@@ -93,7 +93,7 @@ class JavaCompilerPluginConfigurationTests {
private Xpp3Dom buildConfigurationDom(String... properties) throws IOException, XmlPullParserException {
return Xpp3DomBuilder
.build(new StringReader("<configuration>" + Arrays.toString(properties) + "</configuration>"));
.build(new StringReader("<configuration>" + Arrays.toString(properties) + "</configuration>"));
}
}