Add JUnit 5 checkstyle rules
Add a rule to enforce JUnit 5 usage and conventions. Closes gh-17093
This commit is contained in:
@@ -38,12 +38,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@ExtendWith(GradleBuildExtension.class)
|
||||
public class BuildInfoDslIntegrationTests {
|
||||
class BuildInfoDslIntegrationTests {
|
||||
|
||||
final GradleBuild gradleBuild = new GradleBuild();
|
||||
|
||||
@Test
|
||||
public void basicJar() throws IOException {
|
||||
void basicJar() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
@@ -54,7 +54,7 @@ public class BuildInfoDslIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jarWithCustomName() throws IOException {
|
||||
void jarWithCustomName() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
@@ -65,7 +65,7 @@ public class BuildInfoDslIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicWar() throws IOException {
|
||||
void basicWar() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
@@ -76,7 +76,7 @@ public class BuildInfoDslIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void warWithCustomName() throws IOException {
|
||||
void warWithCustomName() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
@@ -87,7 +87,7 @@ public class BuildInfoDslIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void additionalProperties() throws IOException {
|
||||
void additionalProperties() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
@@ -100,7 +100,7 @@ public class BuildInfoDslIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classesDependency() throws IOException {
|
||||
void classesDependency() throws IOException {
|
||||
assertThat(this.gradleBuild.build("classes", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,12 @@ import org.springframework.boot.gradle.dsl.SpringBootExtension;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class MainClassConventionTests {
|
||||
/**
|
||||
* Integration tests for {@link MainClassConvention}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class MainClassConventionTests {
|
||||
|
||||
@TempDir
|
||||
File temp;
|
||||
@@ -40,20 +45,20 @@ public class MainClassConventionTests {
|
||||
private MainClassConvention convention;
|
||||
|
||||
@BeforeEach
|
||||
public void createConvention() throws IOException {
|
||||
void createConvention() throws IOException {
|
||||
this.project = ProjectBuilder.builder().withProjectDir(this.temp).build();
|
||||
this.convention = new MainClassConvention(this.project, () -> null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mainClassNameProjectPropertyIsUsed() throws Exception {
|
||||
void mainClassNameProjectPropertyIsUsed() throws Exception {
|
||||
this.project.getExtensions().getByType(ExtraPropertiesExtension.class).set("mainClassName",
|
||||
"com.example.MainClass");
|
||||
assertThat(this.convention.call()).isEqualTo("com.example.MainClass");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springBootExtensionMainClassNameIsUsed() throws Exception {
|
||||
void springBootExtensionMainClassNameIsUsed() throws Exception {
|
||||
SpringBootExtension extension = this.project.getExtensions().create("springBoot", SpringBootExtension.class,
|
||||
this.project);
|
||||
extension.setMainClassName("com.example.MainClass");
|
||||
@@ -61,7 +66,7 @@ public class MainClassConventionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springBootExtensionMainClassNameIsUsedInPreferenceToMainClassNameProjectProperty() throws Exception {
|
||||
void springBootExtensionMainClassNameIsUsedInPreferenceToMainClassNameProjectProperty() throws Exception {
|
||||
this.project.getExtensions().getByType(ExtraPropertiesExtension.class).set("mainClassName",
|
||||
"com.example.ProjectPropertyMainClass");
|
||||
SpringBootExtension extension = this.project.getExtensions().create("springBoot", SpringBootExtension.class,
|
||||
|
||||
@@ -34,29 +34,29 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@ExtendWith(GradleBuildExtension.class)
|
||||
public class SpringBootPluginIntegrationTests {
|
||||
class SpringBootPluginIntegrationTests {
|
||||
|
||||
final GradleBuild gradleBuild = new GradleBuild();
|
||||
|
||||
@Test
|
||||
public void failFastWithVersionOfGradleLowerThanRequired() {
|
||||
void failFastWithVersionOfGradleLowerThanRequired() {
|
||||
BuildResult result = this.gradleBuild.gradleVersion("4.9").buildAndFail();
|
||||
assertThat(result.getOutput())
|
||||
.contains("Spring Boot plugin requires Gradle 4.10" + " or later. The current version is Gradle 4.9");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void succeedWithVersionOfGradleHigherThanRequired() {
|
||||
void succeedWithVersionOfGradleHigherThanRequired() {
|
||||
this.gradleBuild.gradleVersion("4.10.1").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void succeedWithVersionOfGradleMatchingWhatIsRequired() {
|
||||
void succeedWithVersionOfGradleMatchingWhatIsRequired() {
|
||||
this.gradleBuild.gradleVersion("4.10").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unresolvedDependenciesAreAnalyzedWhenDependencyResolutionFails() throws IOException {
|
||||
void unresolvedDependenciesAreAnalyzedWhenDependencyResolutionFails() throws IOException {
|
||||
createMinimalMainSource();
|
||||
BuildResult result = this.gradleBuild.buildAndFail("compileJava");
|
||||
assertThat(result.getOutput())
|
||||
|
||||
@@ -35,13 +35,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class BuildInfoTests {
|
||||
class BuildInfoTests {
|
||||
|
||||
@TempDir
|
||||
File temp;
|
||||
|
||||
@Test
|
||||
public void basicExecution() {
|
||||
void basicExecution() {
|
||||
Properties properties = buildInfoProperties(createTask(createProject("test")));
|
||||
assertThat(properties).containsKey("build.time");
|
||||
assertThat(properties).containsEntry("build.artifact", "unspecified");
|
||||
@@ -51,63 +51,63 @@ public class BuildInfoTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customArtifactIsReflectedInProperties() {
|
||||
void customArtifactIsReflectedInProperties() {
|
||||
BuildInfo task = createTask(createProject("test"));
|
||||
task.getProperties().setArtifact("custom");
|
||||
assertThat(buildInfoProperties(task)).containsEntry("build.artifact", "custom");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void projectGroupIsReflectedInProperties() {
|
||||
void projectGroupIsReflectedInProperties() {
|
||||
BuildInfo task = createTask(createProject("test"));
|
||||
task.getProject().setGroup("com.example");
|
||||
assertThat(buildInfoProperties(task)).containsEntry("build.group", "com.example");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customGroupIsReflectedInProperties() {
|
||||
void customGroupIsReflectedInProperties() {
|
||||
BuildInfo task = createTask(createProject("test"));
|
||||
task.getProperties().setGroup("com.example");
|
||||
assertThat(buildInfoProperties(task)).containsEntry("build.group", "com.example");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customNameIsReflectedInProperties() {
|
||||
void customNameIsReflectedInProperties() {
|
||||
BuildInfo task = createTask(createProject("test"));
|
||||
task.getProperties().setName("Example");
|
||||
assertThat(buildInfoProperties(task)).containsEntry("build.name", "Example");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void projectVersionIsReflectedInProperties() {
|
||||
void projectVersionIsReflectedInProperties() {
|
||||
BuildInfo task = createTask(createProject("test"));
|
||||
task.getProject().setVersion("1.2.3");
|
||||
assertThat(buildInfoProperties(task)).containsEntry("build.version", "1.2.3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customVersionIsReflectedInProperties() {
|
||||
void customVersionIsReflectedInProperties() {
|
||||
BuildInfo task = createTask(createProject("test"));
|
||||
task.getProperties().setVersion("2.3.4");
|
||||
assertThat(buildInfoProperties(task)).containsEntry("build.version", "2.3.4");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void timeIsSetInProperties() {
|
||||
void timeIsSetInProperties() {
|
||||
BuildInfo task = createTask(createProject("test"));
|
||||
assertThat(buildInfoProperties(task)).containsEntry("build.time",
|
||||
DateTimeFormatter.ISO_INSTANT.format(task.getProperties().getTime()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void timeCanBeRemovedFromProperties() {
|
||||
void timeCanBeRemovedFromProperties() {
|
||||
BuildInfo task = createTask(createProject("test"));
|
||||
task.getProperties().setTime(null);
|
||||
assertThat(buildInfoProperties(task)).doesNotContainKey("build.time");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void timeCanBeCustomizedInProperties() {
|
||||
void timeCanBeCustomizedInProperties() {
|
||||
Instant now = Instant.now();
|
||||
BuildInfo task = createTask(createProject("test"));
|
||||
task.getProperties().setTime(now);
|
||||
@@ -115,7 +115,7 @@ public class BuildInfoTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void additionalPropertiesAreReflectedInProperties() {
|
||||
void additionalPropertiesAreReflectedInProperties() {
|
||||
BuildInfo task = createTask(createProject("test"));
|
||||
task.getProperties().getAdditional().put("a", "alpha");
|
||||
task.getProperties().getAdditional().put("b", "bravo");
|
||||
|
||||
@@ -55,7 +55,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @param <T> the type of the concrete BootArchive implementation
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
|
||||
@TempDir
|
||||
File temp;
|
||||
@@ -80,7 +80,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void createTask() {
|
||||
void createTask() {
|
||||
try {
|
||||
File projectDir = new File(this.temp, "project");
|
||||
projectDir.mkdirs();
|
||||
@@ -94,7 +94,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicArchiveCreation() throws IOException {
|
||||
void basicArchiveCreation() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
executeTask();
|
||||
assertThat(this.task.getArchivePath()).exists();
|
||||
@@ -109,7 +109,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classpathJarsArePackagedBeneathLibPath() throws IOException {
|
||||
void classpathJarsArePackagedBeneathLibPath() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.classpath(jarFile("one.jar"), jarFile("two.jar"));
|
||||
executeTask();
|
||||
@@ -120,7 +120,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classpathFoldersArePackagedBeneathClassesPath() throws IOException {
|
||||
void classpathFoldersArePackagedBeneathClassesPath() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
File classpathFolder = new File(this.temp, "classes");
|
||||
File applicationClass = new File(classpathFolder, "com/example/Application.class");
|
||||
@@ -134,7 +134,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void moduleInfoClassIsPackagedInTheRootOfTheArchive() throws IOException {
|
||||
void moduleInfoClassIsPackagedInTheRootOfTheArchive() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
File classpathFolder = new File(this.temp, "classes");
|
||||
File moduleInfoClass = new File(classpathFolder, "module-info.class");
|
||||
@@ -154,7 +154,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classpathCanBeSetUsingAFileCollection() throws IOException {
|
||||
void classpathCanBeSetUsingAFileCollection() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.classpath(jarFile("one.jar"));
|
||||
this.task.setClasspath(this.task.getProject().files(jarFile("two.jar")));
|
||||
@@ -166,7 +166,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classpathCanBeSetUsingAnObject() throws IOException {
|
||||
void classpathCanBeSetUsingAnObject() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.classpath(jarFile("one.jar"));
|
||||
this.task.setClasspath(jarFile("two.jar"));
|
||||
@@ -178,7 +178,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filesOnTheClasspathThatAreNotZipFilesAreSkipped() throws IOException {
|
||||
void filesOnTheClasspathThatAreNotZipFilesAreSkipped() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.classpath(new File("test.pom"));
|
||||
this.task.execute();
|
||||
@@ -188,7 +188,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loaderIsWrittenToTheRootOfTheJar() throws IOException {
|
||||
void loaderIsWrittenToTheRootOfTheJar() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
@@ -198,7 +198,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loaderIsWrittenToTheRootOfTheJarWhenUsingThePropertiesLauncher() throws IOException {
|
||||
void loaderIsWrittenToTheRootOfTheJarWhenUsingThePropertiesLauncher() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
executeTask();
|
||||
this.task.getManifest().getAttributes().put("Main-Class", "org.springframework.boot.loader.PropertiesLauncher");
|
||||
@@ -209,7 +209,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unpackCommentIsAddedToEntryIdentifiedByAPattern() throws IOException {
|
||||
void unpackCommentIsAddedToEntryIdentifiedByAPattern() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.classpath(jarFile("one.jar"), jarFile("two.jar"));
|
||||
this.task.requiresUnpack("**/one.jar");
|
||||
@@ -221,7 +221,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unpackCommentIsAddedToEntryIdentifiedByASpec() throws IOException {
|
||||
void unpackCommentIsAddedToEntryIdentifiedByASpec() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.classpath(jarFile("one.jar"), jarFile("two.jar"));
|
||||
this.task.requiresUnpack((element) -> element.getName().endsWith("two.jar"));
|
||||
@@ -233,7 +233,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void launchScriptCanBePrepended() throws IOException {
|
||||
void launchScriptCanBePrepended() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.launchScript();
|
||||
executeTask();
|
||||
@@ -253,7 +253,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customLaunchScriptCanBePrepended() throws IOException {
|
||||
void customLaunchScriptCanBePrepended() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
File customScript = new File(this.temp, "custom.script");
|
||||
Files.write(customScript.toPath(), Arrays.asList("custom script"), StandardOpenOption.CREATE);
|
||||
@@ -263,7 +263,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void launchScriptInitInfoPropertiesCanBeCustomized() throws IOException {
|
||||
void launchScriptInitInfoPropertiesCanBeCustomized() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.launchScript((configuration) -> {
|
||||
configuration.getProperties().put("initInfoProvides", "provides");
|
||||
@@ -278,7 +278,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customMainClassInTheManifestIsHonored() throws IOException {
|
||||
void customMainClassInTheManifestIsHonored() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.getManifest().getAttributes().put("Main-Class", "com.example.CustomLauncher");
|
||||
executeTask();
|
||||
@@ -292,7 +292,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customStartClassInTheManifestIsHonored() throws IOException {
|
||||
void customStartClassInTheManifestIsHonored() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.getManifest().getAttributes().put("Start-Class", "com.example.CustomMain");
|
||||
executeTask();
|
||||
@@ -305,7 +305,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fileTimestampPreservationCanBeDisabled() throws IOException {
|
||||
void fileTimestampPreservationCanBeDisabled() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.setPreserveFileTimestamps(false);
|
||||
executeTask();
|
||||
@@ -320,7 +320,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reproducibleOrderingCanBeEnabled() throws IOException {
|
||||
void reproducibleOrderingCanBeEnabled() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.from(newFile("bravo.txt"), newFile("alpha.txt"), newFile("charlie.txt"));
|
||||
this.task.setReproducibleFileOrder(true);
|
||||
@@ -340,7 +340,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void devtoolsJarIsExcludedByDefault() throws IOException {
|
||||
void devtoolsJarIsExcludedByDefault() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.classpath(newFile("spring-boot-devtools-0.1.2.jar"));
|
||||
executeTask();
|
||||
@@ -351,7 +351,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void devtoolsJarCanBeIncluded() throws IOException {
|
||||
void devtoolsJarCanBeIncluded() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.classpath(jarFile("spring-boot-devtools-0.1.2.jar"));
|
||||
this.task.setExcludeDevtools(false);
|
||||
@@ -363,7 +363,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allEntriesUseUnixPlatformAndUtf8NameEncoding() throws IOException {
|
||||
void allEntriesUseUnixPlatformAndUtf8NameEncoding() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.setMetadataCharset("UTF-8");
|
||||
File classpathFolder = new File(this.temp, "classes");
|
||||
@@ -384,7 +384,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loaderIsWrittenFirstThenApplicationClassesThenLibraries() throws IOException {
|
||||
void loaderIsWrittenFirstThenApplicationClassesThenLibraries() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
File classpathFolder = new File(this.temp, "classes");
|
||||
File applicationClass = new File(classpathFolder, "com/example/Application.class");
|
||||
|
||||
@@ -29,14 +29,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class BootJarTests extends AbstractBootArchiveTests<BootJar> {
|
||||
class BootJarTests extends AbstractBootArchiveTests<BootJar> {
|
||||
|
||||
public BootJarTests() {
|
||||
BootJarTests() {
|
||||
super(BootJar.class, "org.springframework.boot.loader.JarLauncher", "BOOT-INF/lib/", "BOOT-INF/classes/");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contentCanBeAddedToBootInfUsingCopySpecFromGetter() throws IOException {
|
||||
void contentCanBeAddedToBootInfUsingCopySpecFromGetter() throws IOException {
|
||||
BootJar bootJar = getTask();
|
||||
bootJar.setMainClassName("com.example.Application");
|
||||
bootJar.getBootInf().into("test").from(new File("build.gradle").getAbsolutePath());
|
||||
@@ -47,7 +47,7 @@ public class BootJarTests extends AbstractBootArchiveTests<BootJar> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contentCanBeAddedToBootInfUsingCopySpecAction() throws IOException {
|
||||
void contentCanBeAddedToBootInfUsingCopySpecAction() throws IOException {
|
||||
BootJar bootJar = getTask();
|
||||
bootJar.setMainClassName("com.example.Application");
|
||||
bootJar.bootInf((copySpec) -> copySpec.into("test").from(new File("build.gradle").getAbsolutePath()));
|
||||
|
||||
@@ -29,14 +29,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
|
||||
public BootWarTests() {
|
||||
BootWarTests() {
|
||||
super(BootWar.class, "org.springframework.boot.loader.WarLauncher", "WEB-INF/lib/", "WEB-INF/classes/");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void providedClasspathJarsArePackagedInWebInfLibProvided() throws IOException {
|
||||
void providedClasspathJarsArePackagedInWebInfLibProvided() throws IOException {
|
||||
getTask().setMainClassName("com.example.Main");
|
||||
getTask().providedClasspath(jarFile("one.jar"), jarFile("two.jar"));
|
||||
executeTask();
|
||||
@@ -47,7 +47,7 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void providedClasspathCanBeSetUsingAFileCollection() throws IOException {
|
||||
void providedClasspathCanBeSetUsingAFileCollection() throws IOException {
|
||||
getTask().setMainClassName("com.example.Main");
|
||||
getTask().providedClasspath(jarFile("one.jar"));
|
||||
getTask().setProvidedClasspath(getTask().getProject().files(jarFile("two.jar")));
|
||||
@@ -59,7 +59,7 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void providedClasspathCanBeSetUsingAnObject() throws IOException {
|
||||
void providedClasspathCanBeSetUsingAnObject() throws IOException {
|
||||
getTask().setMainClassName("com.example.Main");
|
||||
getTask().providedClasspath(jarFile("one.jar"));
|
||||
getTask().setProvidedClasspath(jarFile("two.jar"));
|
||||
@@ -71,7 +71,7 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void devtoolsJarIsExcludedByDefaultWhenItsOnTheProvidedClasspath() throws IOException {
|
||||
void devtoolsJarIsExcludedByDefaultWhenItsOnTheProvidedClasspath() throws IOException {
|
||||
getTask().setMainClassName("com.example.Main");
|
||||
getTask().providedClasspath(newFile("spring-boot-devtools-0.1.2.jar"));
|
||||
executeTask();
|
||||
@@ -82,7 +82,7 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void devtoolsJarCanBeIncludedWhenItsOnTheProvidedClasspath() throws IOException {
|
||||
void devtoolsJarCanBeIncludedWhenItsOnTheProvidedClasspath() throws IOException {
|
||||
getTask().setMainClassName("com.example.Main");
|
||||
getTask().providedClasspath(jarFile("spring-boot-devtools-0.1.2.jar"));
|
||||
getTask().setExcludeDevtools(false);
|
||||
@@ -94,7 +94,7 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void webappResourcesInDirectoriesThatOverlapWithLoaderCanBePackaged() throws IOException {
|
||||
void webappResourcesInDirectoriesThatOverlapWithLoaderCanBePackaged() throws IOException {
|
||||
File webappFolder = new File(this.temp, "src/main/webapp");
|
||||
webappFolder.mkdirs();
|
||||
File orgFolder = new File(webappFolder, "org");
|
||||
@@ -111,7 +111,7 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void libProvidedEntriesAreWrittenAfterLibEntries() throws IOException {
|
||||
void libProvidedEntriesAreWrittenAfterLibEntries() throws IOException {
|
||||
getTask().setMainClassName("com.example.Main");
|
||||
getTask().classpath(jarFile("library.jar"));
|
||||
getTask().providedClasspath(jarFile("provided-library.jar"));
|
||||
|
||||
@@ -30,7 +30,7 @@ import static org.mockito.Mockito.mock;
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class LaunchScriptConfigurationTests {
|
||||
class LaunchScriptConfigurationTests {
|
||||
|
||||
private final AbstractArchiveTask task = mock(AbstractArchiveTask.class);
|
||||
|
||||
@@ -42,49 +42,49 @@ public class LaunchScriptConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initInfoProvidesUsesArchiveBaseNameByDefault() {
|
||||
void initInfoProvidesUsesArchiveBaseNameByDefault() {
|
||||
given(this.task.getBaseName()).willReturn("base-name");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoProvides",
|
||||
"base-name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initInfoShortDescriptionUsesDescriptionByDefault() {
|
||||
void initInfoShortDescriptionUsesDescriptionByDefault() {
|
||||
given(this.project.getDescription()).willReturn("Project description");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoShortDescription",
|
||||
"Project description");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initInfoShortDescriptionUsesArchiveBaseNameWhenDescriptionIsNull() {
|
||||
void initInfoShortDescriptionUsesArchiveBaseNameWhenDescriptionIsNull() {
|
||||
given(this.task.getBaseName()).willReturn("base-name");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoShortDescription",
|
||||
"base-name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initInfoShortDescriptionUsesSingleLineVersionOfMultiLineProjectDescription() {
|
||||
void initInfoShortDescriptionUsesSingleLineVersionOfMultiLineProjectDescription() {
|
||||
given(this.project.getDescription()).willReturn("Project\ndescription");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoShortDescription",
|
||||
"Project description");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initInfoDescriptionUsesArchiveBaseNameWhenDescriptionIsNull() {
|
||||
void initInfoDescriptionUsesArchiveBaseNameWhenDescriptionIsNull() {
|
||||
given(this.task.getBaseName()).willReturn("base-name");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoDescription",
|
||||
"base-name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initInfoDescriptionUsesProjectDescriptionByDefault() {
|
||||
void initInfoDescriptionUsesProjectDescriptionByDefault() {
|
||||
given(this.project.getDescription()).willReturn("Project description");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoDescription",
|
||||
"Project description");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initInfoDescriptionUsesCorrectlyFormattedMultiLineProjectDescription() {
|
||||
void initInfoDescriptionUsesCorrectlyFormattedMultiLineProjectDescription() {
|
||||
given(this.project.getDescription()).willReturn("The\nproject\ndescription");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoDescription",
|
||||
"The\n# project\n# description");
|
||||
|
||||
Reference in New Issue
Block a user