mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Merge branch '2.7.x' into 3.0.x
This commit is contained in:
commit
d1f89db9a2
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -17,6 +17,9 @@
|
|||||||
package org.springframework.boot.configurationprocessor.tests;
|
package org.springframework.boot.configurationprocessor.tests;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -24,8 +27,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.springframework.boot.configurationmetadata.ConfigurationMetadataProperty;
|
import org.springframework.boot.configurationmetadata.ConfigurationMetadataProperty;
|
||||||
import org.springframework.boot.configurationmetadata.ConfigurationMetadataRepository;
|
import org.springframework.boot.configurationmetadata.ConfigurationMetadataRepository;
|
||||||
import org.springframework.boot.configurationmetadata.ConfigurationMetadataRepositoryJsonBuilder;
|
import org.springframework.boot.configurationmetadata.ConfigurationMetadataRepositoryJsonBuilder;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -40,12 +42,20 @@ class ConfigurationProcessorIntegrationTests {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
static void readMetadata() throws IOException {
|
static void readMetadata() throws IOException {
|
||||||
Resource resource = new ClassPathResource("META-INF/spring-configuration-metadata.json");
|
repository = ConfigurationMetadataRepositoryJsonBuilder.create(getResource().openStream()).build();
|
||||||
assertThat(resource.exists()).isTrue();
|
}
|
||||||
// Make sure the right file is detected
|
|
||||||
assertThat(resource.getURL().toString()).contains("spring-boot-configuration-processor-tests");
|
|
||||||
repository = ConfigurationMetadataRepositoryJsonBuilder.create(resource.getInputStream()).build();
|
|
||||||
|
|
||||||
|
private static URL getResource() throws IOException {
|
||||||
|
ClassLoader classLoader = ConfigurationProcessorIntegrationTests.class.getClassLoader();
|
||||||
|
List<URL> urls = new ArrayList<>();
|
||||||
|
CollectionUtils.toIterator(classLoader.getResources("META-INF/spring-configuration-metadata.json"))
|
||||||
|
.forEachRemaining(urls::add);
|
||||||
|
for (URL url : urls) {
|
||||||
|
if (url.toString().contains("spring-boot-configuration-processor-tests")) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("Unable to find correct configuration-metadata resource from " + urls);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user