Commit 66f1344f authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '2.1.x'

Closes gh-17335
Closes gh-17292
parents 867c35a2 91786bc7
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<requirement <requirement
name="org.eclipse.jdt.feature.group"/> name="org.eclipse.jdt.feature.group"/>
<requirement <requirement
name="io.spring.javaformat.eclipse.feature.feature.group"/> name="io.spring.javaformat.eclipse.feature.feature.group" versionRange="[0.0.14,0.0.15)"/>
<requirement <requirement
name="org.eclipse.jst.server_adapters.feature.feature.group"/> name="org.eclipse.jst.server_adapters.feature.feature.group"/>
<requirement <requirement
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</property> </property>
</activation> </activation>
<properties> <properties>
<spring-javaformat.version>0.0.12</spring-javaformat.version> <spring-javaformat.version>0.0.14</spring-javaformat.version>
<nohttp-checkstyle.version>0.0.1.RELEASE</nohttp-checkstyle.version> <nohttp-checkstyle.version>0.0.1.RELEASE</nohttp-checkstyle.version>
</properties> </properties>
<build> <build>
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<dependency> <dependency>
<groupId>com.puppycrawl.tools</groupId> <groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId> <artifactId>checkstyle</artifactId>
<version>8.18</version> <version>8.22</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.spring.javaformat</groupId> <groupId>io.spring.javaformat</groupId>
......
...@@ -50,12 +50,12 @@ class HazelcastAutoConfigurationClientTests { ...@@ -50,12 +50,12 @@ class HazelcastAutoConfigurationClientTests {
private static HazelcastInstance hazelcastServer; private static HazelcastInstance hazelcastServer;
@BeforeAll @BeforeAll
public static void init() { static void init() {
hazelcastServer = Hazelcast.newHazelcastInstance(); hazelcastServer = Hazelcast.newHazelcastInstance();
} }
@AfterAll @AfterAll
public static void close() { static void close() {
if (hazelcastServer != null) { if (hazelcastServer != null) {
hazelcastServer.shutdown(); hazelcastServer.shutdown();
} }
......
...@@ -58,7 +58,7 @@ class KafkaAutoConfigurationIntegrationTests { ...@@ -58,7 +58,7 @@ class KafkaAutoConfigurationIntegrationTests {
private AnnotationConfigApplicationContext context; private AnnotationConfigApplicationContext context;
@BeforeAll @BeforeAll
public static void setUp() { static void setUp() {
embeddedKafka.afterPropertiesSet(); embeddedKafka.afterPropertiesSet();
} }
...@@ -70,7 +70,7 @@ class KafkaAutoConfigurationIntegrationTests { ...@@ -70,7 +70,7 @@ class KafkaAutoConfigurationIntegrationTests {
} }
@AfterAll @AfterAll
public static void tearDown() { static void tearDown() {
embeddedKafka.destroy(); embeddedKafka.destroy();
} }
......
...@@ -350,7 +350,8 @@ class InitCommandTests extends AbstractHttpClientMockTests { ...@@ -350,7 +350,8 @@ class InitCommandTests extends AbstractHttpClientMockTests {
} }
private byte[] createFakeZipArchive(String fileName, String content) throws IOException { private byte[] createFakeZipArchive(String fileName, String content) throws IOException {
try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(bos)) { try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
try (ZipOutputStream zos = new ZipOutputStream(bos)) {
ZipEntry entry = new ZipEntry(fileName); ZipEntry entry = new ZipEntry(fileName);
zos.putNextEntry(entry); zos.putNextEntry(entry);
zos.write(content.getBytes()); zos.write(content.getBytes());
...@@ -358,6 +359,7 @@ class InitCommandTests extends AbstractHttpClientMockTests { ...@@ -358,6 +359,7 @@ class InitCommandTests extends AbstractHttpClientMockTests {
return bos.toByteArray(); return bos.toByteArray();
} }
} }
}
private static class TestableInitCommandOptionHandler extends InitCommand.InitOptionHandler { private static class TestableInitCommandOptionHandler extends InitCommand.InitOptionHandler {
......
...@@ -63,8 +63,10 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat ...@@ -63,8 +63,10 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat
@Test @Test
void severalRepositoriesNoConflict() throws IOException { void severalRepositoriesNoConflict() throws IOException {
try (InputStream foo = getInputStreamFor("foo"); InputStream bar = getInputStreamFor("bar")) { try (InputStream foo = getInputStreamFor("foo")) {
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, bar).build(); try (InputStream bar = getInputStreamFor("bar")) {
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, bar)
.build();
validateFoo(repo); validateFoo(repo);
validateBar(repo); validateBar(repo);
assertThat(repo.getAllGroups()).hasSize(2); assertThat(repo.getAllGroups()).hasSize(2);
...@@ -73,11 +75,14 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat ...@@ -73,11 +75,14 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat
assertThat(repo.getAllProperties()).hasSize(6); assertThat(repo.getAllProperties()).hasSize(6);
} }
} }
}
@Test @Test
void repositoryWithRoot() throws IOException { void repositoryWithRoot() throws IOException {
try (InputStream foo = getInputStreamFor("foo"); InputStream root = getInputStreamFor("root")) { try (InputStream foo = getInputStreamFor("foo")) {
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, root).build(); try (InputStream root = getInputStreamFor("root")) {
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, root)
.build();
validateFoo(repo); validateFoo(repo);
assertThat(repo.getAllGroups()).hasSize(2); assertThat(repo.getAllGroups()).hasSize(2);
...@@ -86,11 +91,14 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat ...@@ -86,11 +91,14 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat
assertThat(repo.getAllProperties()).hasSize(5); assertThat(repo.getAllProperties()).hasSize(5);
} }
} }
}
@Test @Test
void severalRepositoriesIdenticalGroups() throws IOException { void severalRepositoriesIdenticalGroups() throws IOException {
try (InputStream foo = getInputStreamFor("foo"); InputStream foo2 = getInputStreamFor("foo2")) { try (InputStream foo = getInputStreamFor("foo")) {
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, foo2).build(); try (InputStream foo2 = getInputStreamFor("foo2")) {
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, foo2)
.build();
assertThat(repo.getAllGroups()).hasSize(1); assertThat(repo.getAllGroups()).hasSize(1);
ConfigurationMetadataGroup group = repo.getAllGroups().get("spring.foo"); ConfigurationMetadataGroup group = repo.getAllGroups().get("spring.foo");
contains(group.getSources(), "org.acme.Foo", "org.acme.Foo2", "org.springframework.boot.FooProperties"); contains(group.getSources(), "org.acme.Foo", "org.acme.Foo2", "org.springframework.boot.FooProperties");
...@@ -103,6 +111,7 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat ...@@ -103,6 +111,7 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat
assertThat(repo.getAllProperties()).hasSize(5); assertThat(repo.getAllProperties()).hasSize(5);
} }
} }
}
@Test @Test
void emptyGroups() throws IOException { void emptyGroups() throws IOException {
...@@ -135,8 +144,10 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat ...@@ -135,8 +144,10 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat
@Test @Test
void builderInstancesAreIsolated() throws IOException { void builderInstancesAreIsolated() throws IOException {
try (InputStream foo = getInputStreamFor("foo"); InputStream bar = getInputStreamFor("bar")) { try (InputStream foo = getInputStreamFor("foo")) {
ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder.create(); try (InputStream bar = getInputStreamFor("bar")) {
ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder
.create();
ConfigurationMetadataRepository firstRepo = builder.withJsonResource(foo).build(); ConfigurationMetadataRepository firstRepo = builder.withJsonResource(foo).build();
validateFoo(firstRepo); validateFoo(firstRepo);
ConfigurationMetadataRepository secondRepo = builder.withJsonResource(bar).build(); ConfigurationMetadataRepository secondRepo = builder.withJsonResource(bar).build();
...@@ -150,6 +161,7 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat ...@@ -150,6 +161,7 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat
assertThat(secondRepo.getAllProperties()).hasSize(6); assertThat(secondRepo.getAllProperties()).hasSize(6);
} }
} }
}
private void validateFoo(ConfigurationMetadataRepository repo) { private void validateFoo(ConfigurationMetadataRepository repo) {
ConfigurationMetadataGroup group = repo.getAllGroups().get("spring.foo"); ConfigurationMetadataGroup group = repo.getAllGroups().get("spring.foo");
......
...@@ -4,7 +4,7 @@ buildscript { ...@@ -4,7 +4,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath("io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.11") classpath("io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.14")
} }
} }
......
...@@ -32,12 +32,12 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -32,12 +32,12 @@ import static org.assertj.core.api.Assertions.assertThat;
class AnsiOutputTests { class AnsiOutputTests {
@BeforeAll @BeforeAll
public static void enable() { static void enable() {
AnsiOutput.setEnabled(Enabled.ALWAYS); AnsiOutput.setEnabled(Enabled.ALWAYS);
} }
@AfterAll @AfterAll
public static void reset() { static void reset() {
AnsiOutput.setEnabled(Enabled.DETECT); AnsiOutput.setEnabled(Enabled.DETECT);
} }
......
...@@ -42,12 +42,12 @@ class ColorConverterTests { ...@@ -42,12 +42,12 @@ class ColorConverterTests {
private final String in = "in"; private final String in = "in";
@BeforeAll @BeforeAll
public static void setupAnsi() { static void setupAnsi() {
AnsiOutput.setEnabled(AnsiOutput.Enabled.ALWAYS); AnsiOutput.setEnabled(AnsiOutput.Enabled.ALWAYS);
} }
@AfterAll @AfterAll
public static void resetAnsi() { static void resetAnsi() {
AnsiOutput.setEnabled(AnsiOutput.Enabled.DETECT); AnsiOutput.setEnabled(AnsiOutput.Enabled.DETECT);
} }
......
...@@ -52,7 +52,7 @@ class RootUriTemplateHandlerTests { ...@@ -52,7 +52,7 @@ class RootUriTemplateHandlerTests {
@BeforeEach @BeforeEach
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void setup() throws URISyntaxException { void setup() throws URISyntaxException {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
this.uri = new URI("https://example.com/hello"); this.uri = new URI("https://example.com/hello");
this.handler = new RootUriTemplateHandler("https://example.com", this.delegate); this.handler = new RootUriTemplateHandler("https://example.com", this.delegate);
......
...@@ -39,7 +39,7 @@ class ConfigurationProcessorIntegrationTests { ...@@ -39,7 +39,7 @@ class ConfigurationProcessorIntegrationTests {
private static ConfigurationMetadataRepository repository; private static ConfigurationMetadataRepository repository;
@BeforeAll @BeforeAll
public static void readMetadata() throws IOException { static void readMetadata() throws IOException {
Resource resource = new ClassPathResource("META-INF/spring-configuration-metadata.json"); Resource resource = new ClassPathResource("META-INF/spring-configuration-metadata.json");
assertThat(resource.exists()).isTrue(); assertThat(resource.exists()).isTrue();
// Make sure the right file is detected // Make sure the right file is detected
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment