Reformat code following spring-javaformat upgrade

This commit is contained in:
Phillip Webb
2023-02-21 22:49:23 -08:00
parent b93c9f7fec
commit df5898a146
1878 changed files with 27649 additions and 22403 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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 @@ public class DefaultLaunchScript implements LaunchScript {
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("\\{\\{(\\w+)(:.*?)?\\}\\}(?!\\})");
private static final Set<String> FILE_PATH_KEYS = Collections
.unmodifiableSet(Collections.singleton("inlinedConfScript"));
.unmodifiableSet(Collections.singleton("inlinedConfScript"));
private final String content;

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.
@@ -104,7 +104,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
execute(packager, NO_LIBRARIES);
Manifest actualManifest = getPackagedManifest();
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo("org.springframework.boot.loader.JarLauncher");
.isEqualTo("org.springframework.boot.loader.JarLauncher");
assertThat(actualManifest.getMainAttributes().getValue("Start-Class")).isEqualTo("a.b.C");
assertThat(hasPackagedLauncherClasses()).isTrue();
}
@@ -120,7 +120,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
execute(packager, NO_LIBRARIES);
Manifest actualManifest = getPackagedManifest();
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo("org.springframework.boot.loader.JarLauncher");
.isEqualTo("org.springframework.boot.loader.JarLauncher");
assertThat(actualManifest.getMainAttributes().getValue("Start-Class")).isEqualTo("a.b.C");
assertThat(hasPackagedLauncherClasses()).isTrue();
}
@@ -132,7 +132,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
execute(packager, NO_LIBRARIES);
Manifest actualManifest = getPackagedManifest();
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo("org.springframework.boot.loader.JarLauncher");
.isEqualTo("org.springframework.boot.loader.JarLauncher");
assertThat(actualManifest.getMainAttributes().getValue("Start-Class")).isEqualTo("a.b.C");
assertThat(hasPackagedLauncherClasses()).isTrue();
}
@@ -142,8 +142,8 @@ abstract class AbstractPackagerTests<P extends Packager> {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/D.class", ClassWithMainMethod.class);
P packager = createPackager();
assertThatIllegalStateException().isThrownBy(() -> execute(packager, NO_LIBRARIES)).withMessageContaining(
"Unable to find a single main class from the following candidates [a.b.C, a.b.D]");
assertThatIllegalStateException().isThrownBy(() -> execute(packager, NO_LIBRARIES))
.withMessageContaining("Unable to find a single main class from the following candidates [a.b.C, a.b.D]");
}
@Test
@@ -151,7 +151,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
this.testJarFile.addClass("a/b/C.class", ClassWithoutMainMethod.class);
P packager = createPackager(this.testJarFile.getFile());
assertThatIllegalStateException().isThrownBy(() -> execute(packager, NO_LIBRARIES))
.withMessageContaining("Unable to find main class");
.withMessageContaining("Unable to find main class");
}
@Test
@@ -181,7 +181,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
P packager = createPackager();
assertThatIllegalArgumentException().isThrownBy(() -> execute(packager, null))
.withMessageContaining("Libraries must not be null");
.withMessageContaining("Libraries must not be null");
}
@Test
@@ -234,7 +234,8 @@ abstract class AbstractPackagerTests<P extends Packager> {
String index = getPackagedEntryContent("BOOT-INF/classpath.idx");
String[] libraries = index.split("\\r?\\n");
List<String> expected = Stream.of(libJarFile1, libJarFile2, libJarFile3)
.map((jar) -> "- \"BOOT-INF/lib/" + jar.getName() + "\"").collect(Collectors.toList());
.map((jar) -> "- \"BOOT-INF/lib/" + jar.getName() + "\"")
.collect(Collectors.toList());
assertThat(Arrays.asList(libraries)).containsExactlyElementsOf(expected);
}
@@ -265,7 +266,8 @@ abstract class AbstractPackagerTests<P extends Packager> {
assertThat(hasPackagedEntry("BOOT-INF/classpath.idx")).isTrue();
String classpathIndex = getPackagedEntryContent("BOOT-INF/classpath.idx");
List<String> expectedClasspathIndex = Stream.of(libJarFile1, libJarFile2, libJarFile3)
.map((file) -> "- \"BOOT-INF/lib/" + file.getName() + "\"").collect(Collectors.toList());
.map((file) -> "- \"BOOT-INF/lib/" + file.getName() + "\"")
.collect(Collectors.toList());
assertThat(Arrays.asList(classpathIndex.split("\\n"))).containsExactlyElementsOf(expectedClasspathIndex);
assertThat(hasPackagedEntry("BOOT-INF/layers.idx")).isTrue();
String layersIndex = getPackagedEntryContent("BOOT-INF/layers.idx");
@@ -283,7 +285,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
expectedLayers.add("- '0003':");
expectedLayers.add(" - 'BOOT-INF/lib/" + libJarFile3.getName() + "'");
assertThat(layersIndex.split("\\n"))
.containsExactly(expectedLayers.stream().map((s) -> s.replace('\'', '"')).toArray(String[]::new));
.containsExactly(expectedLayers.stream().map((s) -> s.replace('\'', '"')).toArray(String[]::new));
}
@Test
@@ -296,7 +298,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
assertThat(hasPackagedEntry("BOOT-INF/classpath.idx")).isTrue();
String classpathIndex = getPackagedEntryContent("BOOT-INF/classpath.idx");
assertThat(Arrays.asList(classpathIndex.split("\\n")))
.containsExactly("- \"BOOT-INF/lib/spring-boot-jarmode-layertools.jar\"");
.containsExactly("- \"BOOT-INF/lib/spring-boot-jarmode-layertools.jar\"");
assertThat(hasPackagedEntry("BOOT-INF/layers.idx")).isTrue();
String layersIndex = getPackagedEntryContent("BOOT-INF/layers.idx");
List<String> expectedLayers = new ArrayList<>();
@@ -305,7 +307,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
expectedLayers.add(" - 'META-INF/'");
expectedLayers.add(" - 'org/'");
assertThat(layersIndex.split("\\n"))
.containsExactly(expectedLayers.stream().map((s) -> s.replace('\'', '"')).toArray(String[]::new));
.containsExactly(expectedLayers.stream().map((s) -> s.replace('\'', '"')).toArray(String[]::new));
}
@Test
@@ -394,7 +396,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
this.testJarFile.addClass("a/b/C.class", ClassWithoutMainMethod.class);
Packager packager = createPackager();
assertThatIllegalArgumentException().isThrownBy(() -> packager.setLayout(null))
.withMessageContaining("Layout must not be null");
.withMessageContaining("Layout must not be null");
}
@Test
@@ -650,8 +652,10 @@ abstract class AbstractPackagerTests<P extends Packager> {
}
protected ZipEntry getPackagedEntry(String name) throws IOException {
return getAllPackagedEntries().stream().filter((entry) -> name.equals(entry.getName())).findFirst()
.orElse(null);
return getAllPackagedEntries().stream()
.filter((entry) -> name.equals(entry.getName()))
.findFirst()
.orElse(null);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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,26 +63,26 @@ class ImplicitLayerResolverTests {
@Test
void getLayerWhenLoaderClassReturnsLoaderLayer() {
assertThat(this.layers.getLayer("org/springframework/boot/loader/Launcher.class"))
.isEqualTo(StandardLayers.SPRING_BOOT_LOADER);
.isEqualTo(StandardLayers.SPRING_BOOT_LOADER);
assertThat(this.layers.getLayer("org/springframework/boot/loader/Utils.class"))
.isEqualTo(StandardLayers.SPRING_BOOT_LOADER);
.isEqualTo(StandardLayers.SPRING_BOOT_LOADER);
}
@Test
void getLayerWhenLibraryIsSnapshotReturnsSnapshotLayer() {
assertThat(this.layers.getLayer(mockLibrary("spring-boot.2.0.0.BUILD-SNAPSHOT.jar")))
.isEqualTo(StandardLayers.SNAPSHOT_DEPENDENCIES);
.isEqualTo(StandardLayers.SNAPSHOT_DEPENDENCIES);
assertThat(this.layers.getLayer(mockLibrary("spring-boot.2.0.0-SNAPSHOT.jar")))
.isEqualTo(StandardLayers.SNAPSHOT_DEPENDENCIES);
.isEqualTo(StandardLayers.SNAPSHOT_DEPENDENCIES);
assertThat(this.layers.getLayer(mockLibrary("spring-boot.2.0.0.SNAPSHOT.jar")))
.isEqualTo(StandardLayers.SNAPSHOT_DEPENDENCIES);
.isEqualTo(StandardLayers.SNAPSHOT_DEPENDENCIES);
}
@Test
void getLayerWhenLibraryIsNotSnapshotReturnsDependenciesLayer() {
assertThat(this.layers.getLayer(mockLibrary("spring-boot.2.0.0.jar"))).isEqualTo(StandardLayers.DEPENDENCIES);
assertThat(this.layers.getLayer(mockLibrary("spring-boot.2.0.0-classified.jar")))
.isEqualTo(StandardLayers.DEPENDENCIES);
.isEqualTo(StandardLayers.DEPENDENCIES);
}
private Library mockLibrary(String name) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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,7 +42,7 @@ class LayerTests {
@Test
void createWhenNameContainsBadCharsThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new Layer("bad!name"))
.withMessage("Malformed layer name 'bad!name'");
.withMessage("Malformed layer name 'bad!name'");
}
@Test
@@ -62,11 +62,11 @@ class LayerTests {
@Test
void createWhenUsingReservedNameThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new Layer("ext"))
.withMessage("Layer name 'ext' is reserved");
.withMessage("Layer name 'ext' is reserved");
assertThatIllegalArgumentException().isThrownBy(() -> new Layer("ExT"))
.withMessage("Layer name 'ExT' is reserved");
.withMessage("Layer name 'ExT' is reserved");
assertThatIllegalArgumentException().isThrownBy(() -> new Layer("springbootloader"))
.withMessage("Layer name 'springbootloader' is reserved");
.withMessage("Layer name 'springbootloader' is reserved");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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 LayoutsTests {
@Test
void unknownFile() {
assertThatIllegalStateException().isThrownBy(() -> Layouts.forFile(new File("test.txt")))
.withMessageContaining("Unable to deduce layout for 'test.txt'");
.withMessageContaining("Unable to deduce layout for 'test.txt'");
}
@Test

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,8 +85,8 @@ class MainClassFinderTests {
this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
try (JarFile jarFile = this.testJarFile.getJarFile()) {
assertThatIllegalStateException().isThrownBy(() -> MainClassFinder.findSingleMainClass(jarFile, ""))
.withMessageContaining(
"Unable to find a single main class from the following candidates [a.B, a.b.c.E]");
.withMessageContaining(
"Unable to find a single main class from the following candidates [a.B, a.b.c.E]");
}
}
@@ -142,9 +142,8 @@ class MainClassFinderTests {
this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
assertThatIllegalStateException()
.isThrownBy(() -> MainClassFinder.findSingleMainClass(this.testJarFile.getJarSource()))
.withMessageContaining(
"Unable to find a single main class from the following candidates [a.B, a.b.c.E]");
.isThrownBy(() -> MainClassFinder.findSingleMainClass(this.testJarFile.getJarSource()))
.withMessageContaining("Unable to find a single main class from the following candidates [a.B, a.b.c.E]");
}
@Test

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.
@@ -79,7 +79,7 @@ class RepackagerTests extends AbstractPackagerTests<Repackager> {
repackager.repackage(NO_LIBRARIES);
Manifest actualManifest = getPackagedManifest();
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo("org.springframework.boot.loader.JarLauncher");
.isEqualTo("org.springframework.boot.loader.JarLauncher");
assertThat(actualManifest.getMainAttributes().getValue("Start-Class")).isEqualTo("a.b.C");
assertThat(hasPackagedLauncherClasses()).isTrue();
}
@@ -121,7 +121,7 @@ class RepackagerTests extends AbstractPackagerTests<Repackager> {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
Repackager repackager = createRepackager(this.testJarFile.getFile(), true);
assertThatIllegalArgumentException().isThrownBy(() -> repackager.repackage(null, NO_LIBRARIES))
.withMessageContaining("Invalid destination");
.withMessageContaining("Invalid destination");
}
@Test
@@ -129,7 +129,7 @@ class RepackagerTests extends AbstractPackagerTests<Repackager> {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
Repackager repackager = createRepackager(this.testJarFile.getFile(), true);
assertThatIllegalArgumentException().isThrownBy(() -> repackager.repackage(this.tempDir, NO_LIBRARIES))
.withMessageContaining("Invalid destination");
.withMessageContaining("Invalid destination");
}
@Test
@@ -166,7 +166,7 @@ class RepackagerTests extends AbstractPackagerTests<Repackager> {
}
try {
assertThat(Files.getPosixFilePermissions(this.destination.toPath()))
.contains(PosixFilePermission.OWNER_EXECUTE);
.contains(PosixFilePermission.OWNER_EXECUTE);
}
catch (UnsupportedOperationException ex) {
// Probably running the test on Windows
@@ -185,8 +185,10 @@ class RepackagerTests extends AbstractPackagerTests<Repackager> {
timestamp = entry.getTime();
}
else {
assertThat(entry.getTime()).withFailMessage("Expected time %d to be equal to %d for entry %s",
entry.getTime(), timestamp, entry.getName()).isEqualTo(timestamp);
assertThat(entry.getTime())
.withFailMessage("Expected time %d to be equal to %d for entry %s", entry.getTime(), timestamp,
entry.getName())
.isEqualTo(timestamp);
}
}
}

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.
@@ -59,7 +59,7 @@ public class TestJarFile {
File file = getFilePath(filename);
file.getParentFile().mkdirs();
InputStream inputStream = getClass()
.getResourceAsStream("/" + classToCopy.getName().replace('.', '/') + ".class");
.getResourceAsStream("/" + classToCopy.getName().replace('.', '/') + ".class");
copyToFile(inputStream, file);
if (time != null) {
file.setLastModified(time);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -33,13 +33,13 @@ class ApplicationContentFilterTests {
@Test
void createWhenPatternIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new ApplicationContentFilter(null))
.withMessage("Pattern must not be empty");
.withMessage("Pattern must not be empty");
}
@Test
void createWhenPatternIsEmptyThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new ApplicationContentFilter(""))
.withMessage("Pattern must not be empty");
.withMessage("Pattern must not be empty");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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,16 +39,17 @@ class IncludeExcludeContentSelectorTests {
@Test
void createWhenLayerIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(
() -> new IncludeExcludeContentSelector<>(null, Collections.emptyList(), Collections.emptyList()))
.withMessage("Layer must not be null");
assertThatIllegalArgumentException()
.isThrownBy(
() -> new IncludeExcludeContentSelector<>(null, Collections.emptyList(), Collections.emptyList()))
.withMessage("Layer must not be null");
}
@Test
void createWhenFactoryIsNullThrowsException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new IncludeExcludeContentSelector<>(LAYER, null, null, null))
.withMessage("FilterFactory must not be null");
.isThrownBy(() -> new IncludeExcludeContentSelector<>(LAYER, null, null, null))
.withMessage("FilterFactory must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -38,13 +38,13 @@ class LibraryContentFilterTests {
@Test
void createWhenCoordinatesPatternIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new LibraryContentFilter(null))
.withMessage("CoordinatesPattern must not be empty");
.withMessage("CoordinatesPattern must not be empty");
}
@Test
void createWhenCoordinatesPatternIsEmptyThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new LibraryContentFilter(""))
.withMessage("CoordinatesPattern must not be empty");
.withMessage("CoordinatesPattern must not be empty");
}
@Test