From b3d5cd538dcea991d307ccc556cdfa93be3a7814 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 10 Jun 2019 16:03:37 -0700 Subject: [PATCH] Add JUnit 5 checkstyle rules Add a rule to enforce JUnit 5 usage and conventions. Closes gh-17093 --- pom.xml | 2 +- ...DataAutoConfigurationIntegrationTests.java | 1 - ...asticsearchDataAutoConfigurationTests.java | 2 +- ...SocketMessagingAutoConfigurationTests.java | 2 +- .../restassured/UserDocumentationTests.java | 15 ++---- .../ApplicationArgumentsExampleTests.java | 14 ++---- .../docs/test/web/MockMvcExampleTests.java | 13 ++--- .../web/MockWebTestClientExampleTests.java | 13 ++--- ...andomPortTestRestTemplateExampleTests.java | 12 ++--- .../RandomPortWebTestClientExampleTests.java | 11 +---- ...ientTestWithComponentIntegrationTests.java | 3 ++ .../CompoundConfigurationTableEntryTests.java | 4 +- .../ConfigurationTableTests.java | 4 +- .../SingleConfigurationTableEntryTests.java | 14 +++--- .../dsl/BuildInfoDslIntegrationTests.java | 14 +++--- .../plugin/MainClassConventionTests.java | 15 ++++-- .../SpringBootPluginIntegrationTests.java | 10 ++-- .../tasks/buildinfo/BuildInfoTests.java | 24 +++++----- .../bundling/AbstractBootArchiveTests.java | 48 +++++++++---------- .../gradle/tasks/bundling/BootJarTests.java | 8 ++-- .../gradle/tasks/bundling/BootWarTests.java | 18 +++---- .../LaunchScriptConfigurationTests.java | 16 +++---- .../AbstractConfigurationClassTests.java | 2 +- .../ConfigFileApplicationListenerTests.java | 2 +- .../SampleActuatorApplicationTests.java | 2 +- ...hutdownSampleActuatorApplicationTests.java | 2 +- .../Hibernate52ApplicationTests.java | 5 +- src/checkstyle/checkstyle-suppressions.xml | 7 +++ src/checkstyle/checkstyle.xml | 3 ++ 29 files changed, 130 insertions(+), 156 deletions(-) diff --git a/pom.xml b/pom.xml index 99c35f19bbc..04f16c276a3 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ - 0.0.11 + 0.0.12 0.0.1.RELEASE diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java index 69917bfbdd7..e6d22fed1b0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java @@ -71,7 +71,6 @@ class CassandraDataAutoConfigurationIntegrationTests { AutoConfigurationPackages.register(this.context, cityPackage); this.context.register(CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class); this.context.refresh(); - CassandraSessionFactoryBean bean = this.context.getBean(CassandraSessionFactoryBean.class); assertThat(bean.getSchemaAction()).isEqualTo(SchemaAction.NONE); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfigurationTests.java index 6ab471011af..03c3c5d2728 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfigurationTests.java @@ -103,7 +103,7 @@ class ElasticsearchDataAutoConfigurationTests { } @Test - public void customReactiveRestTemplateShouldBeUsed() { + void customReactiveRestTemplateShouldBeUsed() { this.contextRunner.withUserConfiguration(CustomReactiveRestTemplate.class) .run((context) -> assertThat(context).getBeanNames(ReactiveElasticsearchTemplate.class).hasSize(1) .contains("reactiveElasticsearchTemplate")); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketMessagingAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketMessagingAutoConfigurationTests.java index d109a238505..7b309e01cc4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketMessagingAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketMessagingAutoConfigurationTests.java @@ -42,7 +42,7 @@ class RSocketMessagingAutoConfigurationTests { .withUserConfiguration(BaseConfiguration.class); @Test - public void shouldCreateDefaultBeans() { + void shouldCreateDefaultBeans() { this.contextRunner.run((context) -> { assertThat(context).getBeans(MessageHandlerAcceptor.class).hasSize(1); assertThat(context.getBean(MessageHandlerAcceptor.class).getRouteMatcher()) diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java index 69863817fad..84f2ec13230 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java @@ -19,33 +19,24 @@ package org.springframework.boot.docs.test.autoconfigure.restdocs.restassured; // tag::source[] import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.junit.jupiter.SpringExtension; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.is; import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document; -@ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @AutoConfigureRestDocs -public class UserDocumentationTests { - - @LocalServerPort - private int port; - - @Autowired - private RequestSpecification documentationSpec; +class UserDocumentationTests { @Test - public void listUsers() { - given(this.documentationSpec).filter(document("list-users")).when().port(this.port).get("/").then().assertThat() + void listUsers(@Autowired RequestSpecification documentationSpec, @LocalServerPort int port) { + given(documentationSpec).filter(document("list-users")).when().port(port).get("/").then().assertThat() .statusCode(is(200)); } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/context/ApplicationArgumentsExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/context/ApplicationArgumentsExampleTests.java index dc6affc73e2..79625817166 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/context/ApplicationArgumentsExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/context/ApplicationArgumentsExampleTests.java @@ -17,27 +17,21 @@ package org.springframework.boot.docs.test.context; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; // tag::example[] -@ExtendWith(SpringExtension.class) @SpringBootTest(args = "--app.test=one") -public class ApplicationArgumentsExampleTests { - - @Autowired - private ApplicationArguments args; +class ApplicationArgumentsExampleTests { @Test - public void applicationArgumentsPopulated() { - assertThat(this.args.getOptionNames()).containsOnly("app.test"); - assertThat(this.args.getOptionValues("app.test")).containsOnly("one"); + void applicationArgumentsPopulated(@Autowired ApplicationArguments args) { + assertThat(args.getOptionNames()).containsOnly("app.test"); + assertThat(args.getOptionValues("app.test")).containsOnly("one"); } } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockMvcExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockMvcExampleTests.java index 99083589dc8..6105838bfea 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockMvcExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockMvcExampleTests.java @@ -19,29 +19,22 @@ package org.springframework.boot.docs.test.web; // tag::test-mock-mvc[] import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@ExtendWith(SpringExtension.class) @SpringBootTest @AutoConfigureMockMvc -public class MockMvcExampleTests { - - @Autowired - private MockMvc mvc; +class MockMvcExampleTests { @Test - public void exampleTest() throws Exception { - this.mvc.perform(get("/")).andExpect(status().isOk()).andExpect(content().string("Hello World")); + void exampleTest(MockMvc mvc) throws Exception { + mvc.perform(get("/")).andExpect(status().isOk()).andExpect(content().string("Hello World")); } } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockWebTestClientExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockWebTestClientExampleTests.java index d743de3c46c..883f5ebd382 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockWebTestClientExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockWebTestClientExampleTests.java @@ -19,26 +19,19 @@ package org.springframework.boot.docs.test.web; // tag::test-mock-web-test-client[] import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.reactive.server.WebTestClient; -@ExtendWith(SpringExtension.class) @SpringBootTest @AutoConfigureWebTestClient -public class MockWebTestClientExampleTests { - - @Autowired - private WebTestClient webClient; +class MockWebTestClientExampleTests { @Test - public void exampleTest() { - this.webClient.get().uri("/").exchange().expectStatus().isOk().expectBody(String.class) - .isEqualTo("Hello World"); + void exampleTest(@Autowired WebTestClient webClient) { + webClient.get().uri("/").exchange().expectStatus().isOk().expectBody(String.class).isEqualTo("Hello World"); } } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortTestRestTemplateExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortTestRestTemplateExampleTests.java index 57d0ae195ac..32a93ad3d10 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortTestRestTemplateExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortTestRestTemplateExampleTests.java @@ -19,26 +19,20 @@ package org.springframework.boot.docs.test.web; // tag::test-random-port[] import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.assertj.core.api.Assertions.assertThat; -@ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class RandomPortTestRestTemplateExampleTests { - - @Autowired - private TestRestTemplate restTemplate; +class RandomPortTestRestTemplateExampleTests { @Test - public void exampleTest() { - String body = this.restTemplate.getForObject("/", String.class); + void exampleTest(@Autowired TestRestTemplate restTemplate) { + String body = restTemplate.getForObject("/", String.class); assertThat(body).isEqualTo("Hello World"); } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortWebTestClientExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortWebTestClientExampleTests.java index 0427087a3a0..a650239300f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortWebTestClientExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortWebTestClientExampleTests.java @@ -19,25 +19,18 @@ package org.springframework.boot.docs.test.web; // tag::test-random-port[] import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.reactive.server.WebTestClient; -@ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) public class RandomPortWebTestClientExampleTests { - @Autowired - private WebTestClient webClient; - @Test - public void exampleTest() { - this.webClient.get().uri("/").exchange().expectStatus().isOk().expectBody(String.class) - .isEqualTo("Hello World"); + void exampleTest(@Autowired WebTestClient webClient) { + webClient.get().uri("/").exchange().expectStatus().isOk().expectBody(String.class).isEqualTo("Hello World"); } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithComponentIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithComponentIntegrationTests.java index e54d2a06646..c4e1d79454a 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithComponentIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithComponentIntegrationTests.java @@ -37,6 +37,9 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat @RestClientTest(ExampleRestClient.class) public class RestClientTestWithComponentIntegrationTests { + // JUnit 4 because RestClientTestWithoutJacksonIntegrationTests uses + // ModifiedClassPathRunner + @Autowired private MockRestServiceServer server; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/CompoundConfigurationTableEntryTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/CompoundConfigurationTableEntryTests.java index 4204d3332f9..0e06b595099 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/CompoundConfigurationTableEntryTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/CompoundConfigurationTableEntryTests.java @@ -27,12 +27,12 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Brian Clozel */ -public class CompoundConfigurationTableEntryTests { +class CompoundConfigurationTableEntryTests { private static String NEWLINE = System.lineSeparator(); @Test - public void simpleProperty() { + void simpleProperty() { ConfigurationMetadataProperty firstProp = new ConfigurationMetadataProperty(); firstProp.setId("spring.test.first"); firstProp.setType("java.lang.String"); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/ConfigurationTableTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/ConfigurationTableTests.java index a09e84d0733..2b15a476758 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/ConfigurationTableTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/ConfigurationTableTests.java @@ -27,12 +27,12 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Brian Clozel */ -public class ConfigurationTableTests { +class ConfigurationTableTests { private static String NEWLINE = System.lineSeparator(); @Test - public void simpleTable() { + void simpleTable() { ConfigurationTable table = new ConfigurationTable("test"); ConfigurationMetadataProperty first = new ConfigurationMetadataProperty(); first.setId("spring.test.prop"); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/SingleConfigurationTableEntryTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/SingleConfigurationTableEntryTests.java index 217e1df2078..291310cdcbd 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/SingleConfigurationTableEntryTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-docs/src/test/java/org/springframework/boot/configurationdocs/SingleConfigurationTableEntryTests.java @@ -27,12 +27,12 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Brian Clozel */ -public class SingleConfigurationTableEntryTests { +class SingleConfigurationTableEntryTests { private static String NEWLINE = System.lineSeparator(); @Test - public void simpleProperty() { + void simpleProperty() { ConfigurationMetadataProperty property = new ConfigurationMetadataProperty(); property.setId("spring.test.prop"); property.setDefaultValue("something"); @@ -46,7 +46,7 @@ public class SingleConfigurationTableEntryTests { } @Test - public void noDefaultValue() { + void noDefaultValue() { ConfigurationMetadataProperty property = new ConfigurationMetadataProperty(); property.setId("spring.test.prop"); property.setDescription("This is a description."); @@ -59,7 +59,7 @@ public class SingleConfigurationTableEntryTests { } @Test - public void defaultValueWithPipes() { + void defaultValueWithPipes() { ConfigurationMetadataProperty property = new ConfigurationMetadataProperty(); property.setId("spring.test.prop"); property.setDefaultValue("first|second"); @@ -73,7 +73,7 @@ public class SingleConfigurationTableEntryTests { } @Test - public void defaultValueWithBackslash() { + void defaultValueWithBackslash() { ConfigurationMetadataProperty property = new ConfigurationMetadataProperty(); property.setId("spring.test.prop"); property.setDefaultValue("first\\second"); @@ -87,7 +87,7 @@ public class SingleConfigurationTableEntryTests { } @Test - public void mapProperty() { + void mapProperty() { ConfigurationMetadataProperty property = new ConfigurationMetadataProperty(); property.setId("spring.test.prop"); property.setDescription("This is a description."); @@ -100,7 +100,7 @@ public class SingleConfigurationTableEntryTests { } @Test - public void listProperty() { + void listProperty() { String[] defaultValue = new String[] { "first", "second", "third" }; ConfigurationMetadataProperty property = new ConfigurationMetadataProperty(); property.setId("spring.test.prop"); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/dsl/BuildInfoDslIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/dsl/BuildInfoDslIntegrationTests.java index d08b4d59be5..cc7615d8e49 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/dsl/BuildInfoDslIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/dsl/BuildInfoDslIntegrationTests.java @@ -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); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MainClassConventionTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MainClassConventionTests.java index c9ddf005e28..34e6c115af6 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MainClassConventionTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MainClassConventionTests.java @@ -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, diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/SpringBootPluginIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/SpringBootPluginIntegrationTests.java index 88eed0f09a4..28f2da4030f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/SpringBootPluginIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/SpringBootPluginIntegrationTests.java @@ -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()) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoTests.java index 47d1a5913de..861343c6f6c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoTests.java @@ -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"); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java index b6c0940f48e..fcc6a751759 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java @@ -55,7 +55,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @param the type of the concrete BootArchive implementation * @author Andy Wilkinson */ -public abstract class AbstractBootArchiveTests { +abstract class AbstractBootArchiveTests { @TempDir File temp; @@ -80,7 +80,7 @@ public abstract class AbstractBootArchiveTests { } @BeforeEach - public void createTask() { + void createTask() { try { File projectDir = new File(this.temp, "project"); projectDir.mkdirs(); @@ -94,7 +94,7 @@ public abstract class AbstractBootArchiveTests { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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"); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootJarTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootJarTests.java index a32d1b9fb32..5fae9e8d133 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootJarTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootJarTests.java @@ -29,14 +29,14 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Andy Wilkinson */ -public class BootJarTests extends AbstractBootArchiveTests { +class BootJarTests extends AbstractBootArchiveTests { - 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 { } @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())); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootWarTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootWarTests.java index ffc3cee76d5..107a8272837 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootWarTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootWarTests.java @@ -29,14 +29,14 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Andy Wilkinson */ -public class BootWarTests extends AbstractBootArchiveTests { +class BootWarTests extends AbstractBootArchiveTests { - 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 { } @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 { } @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 { } @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 { } @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 { } @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 { } @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")); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfigurationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfigurationTests.java index c856a8eb07c..9085a37bcaf 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfigurationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfigurationTests.java @@ -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"); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/context/AbstractConfigurationClassTests.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/context/AbstractConfigurationClassTests.java index 15ad1eaf264..9805399398f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/context/AbstractConfigurationClassTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/context/AbstractConfigurationClassTests.java @@ -49,7 +49,7 @@ public abstract class AbstractConfigurationClassTests { private ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); @Test - public void allBeanMethodsArePublic() throws IOException { + void allBeanMethodsArePublic() throws IOException { Set nonPublicBeanMethods = new HashSet<>(); for (AnnotationMetadata configurationClass : findConfigurationClasses()) { Set beanMethods = configurationClass.getAnnotatedMethods(Bean.class.getName()); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java index 22c727c59ff..048d4f573ff 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java @@ -961,7 +961,7 @@ class ConfigFileApplicationListenerTests { } @Test - public void customDefaultPropertySourceIsNotReplaced() { + void customDefaultPropertySourceIsNotReplaced() { // gh-17011 Map source = new HashMap<>(); source.put("mapkey", "mapvalue"); diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java index 835b7d31f20..ef1ea60e61d 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java @@ -166,7 +166,7 @@ class SampleActuatorApplicationTests { @Test @SuppressWarnings("unchecked") - public void testBeans() { + void testBeans() { @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate.withBasicAuth("user", getPassword()) .getForEntity("/actuator/beans", Map.class); diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ShutdownSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ShutdownSampleActuatorApplicationTests.java index 05a3607faf8..4bb7f69748d 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ShutdownSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ShutdownSampleActuatorApplicationTests.java @@ -58,7 +58,7 @@ class ShutdownSampleActuatorApplicationTests { @Test @DirtiesContext - public void testShutdown() { + void testShutdown() { @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate.withBasicAuth("user", getPassword()) .postForEntity("/actuator/shutdown", null, Map.class); diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/test/java/org/springframework/boot/tests/hibernate52/Hibernate52ApplicationTests.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/test/java/org/springframework/boot/tests/hibernate52/Hibernate52ApplicationTests.java index dde20489845..a845b101c5d 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/test/java/org/springframework/boot/tests/hibernate52/Hibernate52ApplicationTests.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/test/java/org/springframework/boot/tests/hibernate52/Hibernate52ApplicationTests.java @@ -21,11 +21,10 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest -public class Hibernate52ApplicationTests { +class Hibernate52ApplicationTests { @Test - public void contextLoads() { - + void contextLoads() { } } diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml index 44ec76fb641..b09c33e376a 100644 --- a/src/checkstyle/checkstyle-suppressions.xml +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -38,4 +38,11 @@ + + + + + + + diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml index 0d489df93db..c0f1ac96746 100644 --- a/src/checkstyle/checkstyle.xml +++ b/src/checkstyle/checkstyle.xml @@ -8,6 +8,9 @@ + + +