Merge branch '2.1.x'
Closes gh-17335 Closes gh-17292
This commit is contained in:
@@ -59,7 +59,7 @@
|
||||
<requirement
|
||||
name="org.eclipse.jdt.feature.group"/>
|
||||
<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
|
||||
name="org.eclipse.jst.server_adapters.feature.feature.group"/>
|
||||
<requirement
|
||||
|
||||
4
pom.xml
4
pom.xml
@@ -24,7 +24,7 @@
|
||||
</property>
|
||||
</activation>
|
||||
<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>
|
||||
</properties>
|
||||
<build>
|
||||
@@ -37,7 +37,7 @@
|
||||
<dependency>
|
||||
<groupId>com.puppycrawl.tools</groupId>
|
||||
<artifactId>checkstyle</artifactId>
|
||||
<version>8.18</version>
|
||||
<version>8.22</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.spring.javaformat</groupId>
|
||||
|
||||
@@ -50,12 +50,12 @@ class HazelcastAutoConfigurationClientTests {
|
||||
private static HazelcastInstance hazelcastServer;
|
||||
|
||||
@BeforeAll
|
||||
public static void init() {
|
||||
static void init() {
|
||||
hazelcastServer = Hazelcast.newHazelcastInstance();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void close() {
|
||||
static void close() {
|
||||
if (hazelcastServer != null) {
|
||||
hazelcastServer.shutdown();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class KafkaAutoConfigurationIntegrationTests {
|
||||
private AnnotationConfigApplicationContext context;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() {
|
||||
static void setUp() {
|
||||
embeddedKafka.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class KafkaAutoConfigurationIntegrationTests {
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void tearDown() {
|
||||
static void tearDown() {
|
||||
embeddedKafka.destroy();
|
||||
}
|
||||
|
||||
|
||||
@@ -350,12 +350,14 @@ class InitCommandTests extends AbstractHttpClientMockTests {
|
||||
}
|
||||
|
||||
private byte[] createFakeZipArchive(String fileName, String content) throws IOException {
|
||||
try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(bos)) {
|
||||
ZipEntry entry = new ZipEntry(fileName);
|
||||
zos.putNextEntry(entry);
|
||||
zos.write(content.getBytes());
|
||||
zos.closeEntry();
|
||||
return bos.toByteArray();
|
||||
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
|
||||
try (ZipOutputStream zos = new ZipOutputStream(bos)) {
|
||||
ZipEntry entry = new ZipEntry(fileName);
|
||||
zos.putNextEntry(entry);
|
||||
zos.write(content.getBytes());
|
||||
zos.closeEntry();
|
||||
return bos.toByteArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,44 +63,53 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat
|
||||
|
||||
@Test
|
||||
void severalRepositoriesNoConflict() throws IOException {
|
||||
try (InputStream foo = getInputStreamFor("foo"); InputStream bar = getInputStreamFor("bar")) {
|
||||
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, bar).build();
|
||||
validateFoo(repo);
|
||||
validateBar(repo);
|
||||
assertThat(repo.getAllGroups()).hasSize(2);
|
||||
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
|
||||
"spring.bar.name", "spring.bar.description", "spring.bar.counter");
|
||||
assertThat(repo.getAllProperties()).hasSize(6);
|
||||
try (InputStream foo = getInputStreamFor("foo")) {
|
||||
try (InputStream bar = getInputStreamFor("bar")) {
|
||||
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, bar)
|
||||
.build();
|
||||
validateFoo(repo);
|
||||
validateBar(repo);
|
||||
assertThat(repo.getAllGroups()).hasSize(2);
|
||||
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
|
||||
"spring.bar.name", "spring.bar.description", "spring.bar.counter");
|
||||
assertThat(repo.getAllProperties()).hasSize(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void repositoryWithRoot() throws IOException {
|
||||
try (InputStream foo = getInputStreamFor("foo"); InputStream root = getInputStreamFor("root")) {
|
||||
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, root).build();
|
||||
validateFoo(repo);
|
||||
assertThat(repo.getAllGroups()).hasSize(2);
|
||||
try (InputStream foo = getInputStreamFor("foo")) {
|
||||
try (InputStream root = getInputStreamFor("root")) {
|
||||
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, root)
|
||||
.build();
|
||||
validateFoo(repo);
|
||||
assertThat(repo.getAllGroups()).hasSize(2);
|
||||
|
||||
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
|
||||
"spring.root.name", "spring.root2.name");
|
||||
assertThat(repo.getAllProperties()).hasSize(5);
|
||||
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
|
||||
"spring.root.name", "spring.root2.name");
|
||||
assertThat(repo.getAllProperties()).hasSize(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void severalRepositoriesIdenticalGroups() throws IOException {
|
||||
try (InputStream foo = getInputStreamFor("foo"); InputStream foo2 = getInputStreamFor("foo2")) {
|
||||
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, foo2).build();
|
||||
assertThat(repo.getAllGroups()).hasSize(1);
|
||||
ConfigurationMetadataGroup group = repo.getAllGroups().get("spring.foo");
|
||||
contains(group.getSources(), "org.acme.Foo", "org.acme.Foo2", "org.springframework.boot.FooProperties");
|
||||
assertThat(group.getSources()).hasSize(3);
|
||||
contains(group.getProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
|
||||
"spring.foo.enabled", "spring.foo.type");
|
||||
assertThat(group.getProperties()).hasSize(5);
|
||||
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
|
||||
"spring.foo.enabled", "spring.foo.type");
|
||||
assertThat(repo.getAllProperties()).hasSize(5);
|
||||
try (InputStream foo = getInputStreamFor("foo")) {
|
||||
try (InputStream foo2 = getInputStreamFor("foo2")) {
|
||||
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, foo2)
|
||||
.build();
|
||||
assertThat(repo.getAllGroups()).hasSize(1);
|
||||
ConfigurationMetadataGroup group = repo.getAllGroups().get("spring.foo");
|
||||
contains(group.getSources(), "org.acme.Foo", "org.acme.Foo2", "org.springframework.boot.FooProperties");
|
||||
assertThat(group.getSources()).hasSize(3);
|
||||
contains(group.getProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
|
||||
"spring.foo.enabled", "spring.foo.type");
|
||||
assertThat(group.getProperties()).hasSize(5);
|
||||
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter",
|
||||
"spring.foo.enabled", "spring.foo.type");
|
||||
assertThat(repo.getAllProperties()).hasSize(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,19 +144,22 @@ class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurat
|
||||
|
||||
@Test
|
||||
void builderInstancesAreIsolated() throws IOException {
|
||||
try (InputStream foo = getInputStreamFor("foo"); InputStream bar = getInputStreamFor("bar")) {
|
||||
ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder.create();
|
||||
ConfigurationMetadataRepository firstRepo = builder.withJsonResource(foo).build();
|
||||
validateFoo(firstRepo);
|
||||
ConfigurationMetadataRepository secondRepo = builder.withJsonResource(bar).build();
|
||||
validateFoo(secondRepo);
|
||||
validateBar(secondRepo);
|
||||
// first repo not impacted by second build
|
||||
assertThat(secondRepo).isNotEqualTo(firstRepo);
|
||||
assertThat(firstRepo.getAllGroups()).hasSize(1);
|
||||
assertThat(firstRepo.getAllProperties()).hasSize(3);
|
||||
assertThat(secondRepo.getAllGroups()).hasSize(2);
|
||||
assertThat(secondRepo.getAllProperties()).hasSize(6);
|
||||
try (InputStream foo = getInputStreamFor("foo")) {
|
||||
try (InputStream bar = getInputStreamFor("bar")) {
|
||||
ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder
|
||||
.create();
|
||||
ConfigurationMetadataRepository firstRepo = builder.withJsonResource(foo).build();
|
||||
validateFoo(firstRepo);
|
||||
ConfigurationMetadataRepository secondRepo = builder.withJsonResource(bar).build();
|
||||
validateFoo(secondRepo);
|
||||
validateBar(secondRepo);
|
||||
// first repo not impacted by second build
|
||||
assertThat(secondRepo).isNotEqualTo(firstRepo);
|
||||
assertThat(firstRepo.getAllGroups()).hasSize(1);
|
||||
assertThat(firstRepo.getAllProperties()).hasSize(3);
|
||||
assertThat(secondRepo.getAllGroups()).hasSize(2);
|
||||
assertThat(secondRepo.getAllProperties()).hasSize(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
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;
|
||||
class AnsiOutputTests {
|
||||
|
||||
@BeforeAll
|
||||
public static void enable() {
|
||||
static void enable() {
|
||||
AnsiOutput.setEnabled(Enabled.ALWAYS);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void reset() {
|
||||
static void reset() {
|
||||
AnsiOutput.setEnabled(Enabled.DETECT);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,12 +42,12 @@ class ColorConverterTests {
|
||||
private final String in = "in";
|
||||
|
||||
@BeforeAll
|
||||
public static void setupAnsi() {
|
||||
static void setupAnsi() {
|
||||
AnsiOutput.setEnabled(AnsiOutput.Enabled.ALWAYS);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void resetAnsi() {
|
||||
static void resetAnsi() {
|
||||
AnsiOutput.setEnabled(AnsiOutput.Enabled.DETECT);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class RootUriTemplateHandlerTests {
|
||||
|
||||
@BeforeEach
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setup() throws URISyntaxException {
|
||||
void setup() throws URISyntaxException {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.uri = new URI("https://example.com/hello");
|
||||
this.handler = new RootUriTemplateHandler("https://example.com", this.delegate);
|
||||
|
||||
@@ -39,7 +39,7 @@ class ConfigurationProcessorIntegrationTests {
|
||||
private static ConfigurationMetadataRepository repository;
|
||||
|
||||
@BeforeAll
|
||||
public static void readMetadata() throws IOException {
|
||||
static void readMetadata() throws IOException {
|
||||
Resource resource = new ClassPathResource("META-INF/spring-configuration-metadata.json");
|
||||
assertThat(resource.exists()).isTrue();
|
||||
// Make sure the right file is detected
|
||||
|
||||
Reference in New Issue
Block a user