Polish
This commit is contained in:
@@ -121,8 +121,8 @@ public class CacheStatisticsAutoConfigurationTests {
|
||||
@Test
|
||||
public void baseCaffeineCacheStatistics() {
|
||||
load(CaffeineCacheConfig.class);
|
||||
CacheStatisticsProvider provider = this.context
|
||||
.getBean("caffeineCacheStatisticsProvider", CacheStatisticsProvider.class);
|
||||
CacheStatisticsProvider provider = this.context.getBean(
|
||||
"caffeineCacheStatisticsProvider", CacheStatisticsProvider.class);
|
||||
doTestCoreStatistics(provider, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +168,8 @@ public class EndpointAutoConfigurationTests {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.info.git.location:classpath:nonexistent");
|
||||
this.context.register(InfoContributorAutoConfiguration.class, EndpointAutoConfiguration.class);
|
||||
this.context.register(InfoContributorAutoConfiguration.class,
|
||||
EndpointAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
InfoEndpoint endpoint = this.context.getBean(InfoEndpoint.class);
|
||||
assertThat(endpoint).isNotNull();
|
||||
@@ -179,7 +180,8 @@ public class EndpointAutoConfigurationTests {
|
||||
public void testInfoEndpointOrdering() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "info.name:foo");
|
||||
this.context.register(CustomInfoContributorsConfig.class, ProjectInfoAutoConfiguration.class,
|
||||
this.context.register(CustomInfoContributorsConfig.class,
|
||||
ProjectInfoAutoConfiguration.class,
|
||||
InfoContributorAutoConfiguration.class, EndpointAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -265,8 +267,8 @@ public class EndpointAutoConfigurationTests {
|
||||
GitFullInfoContributor(Resource location) throws BindException, IOException {
|
||||
this.content = new LinkedHashMap<String, Object>();
|
||||
if (location.exists()) {
|
||||
PropertiesConfigurationFactory<Map<String, Object>> factory
|
||||
= new PropertiesConfigurationFactory<Map<String, Object>>(this.content);
|
||||
PropertiesConfigurationFactory<Map<String, Object>> factory = new PropertiesConfigurationFactory<Map<String, Object>>(
|
||||
this.content);
|
||||
factory.setTargetName("git");
|
||||
Properties gitInfoProperties = PropertiesLoaderUtils
|
||||
.loadProperties(location);
|
||||
@@ -281,7 +283,9 @@ public class EndpointAutoConfigurationTests {
|
||||
builder.withDetail("git", this.content);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ public class InfoContributorAutoConfigurationTests {
|
||||
gitInfo.getCommit().setId("abcdefg");
|
||||
return gitInfo;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -120,6 +121,7 @@ public class InfoContributorAutoConfigurationTests {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,10 +57,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = {TestConfiguration.class})
|
||||
@SpringApplicationConfiguration(classes = { TestConfiguration.class })
|
||||
@WebAppConfiguration
|
||||
@TestPropertySource(properties = {"info.app.name=MyService"})
|
||||
@TestPropertySource(properties = { "info.app.name=MyService" })
|
||||
public class InfoMvcEndpointTests {
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
@@ -68,7 +69,6 @@ public class InfoMvcEndpointTests {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
this.context.getBean(InfoEndpoint.class).setEnabled(true);
|
||||
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
}
|
||||
@@ -76,18 +76,16 @@ public class InfoMvcEndpointTests {
|
||||
@Test
|
||||
public void home() throws Exception {
|
||||
this.mvc.perform(get("/info")).andExpect(status().isOk())
|
||||
.andExpect(content().string(
|
||||
containsString("\"beanName1\":{\"key11\":\"value11\",\"key12\":\"value12\"}")
|
||||
))
|
||||
.andExpect(content().string(
|
||||
containsString("\"beanName2\":{\"key21\":\"value21\",\"key22\":\"value22\"}")));
|
||||
.andExpect(content().string(containsString(
|
||||
"\"beanName1\":{\"key11\":\"value11\",\"key12\":\"value12\"}")))
|
||||
.andExpect(content().string(containsString(
|
||||
"\"beanName2\":{\"key21\":\"value21\",\"key22\":\"value22\"}")));
|
||||
}
|
||||
|
||||
@Import({JacksonAutoConfiguration.class,
|
||||
@Import({ JacksonAutoConfiguration.class,
|
||||
HttpMessageConvertersAutoConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class,
|
||||
WebMvcAutoConfiguration.class,
|
||||
ManagementServerPropertiesAutoConfiguration.class})
|
||||
EndpointWebMvcAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||
ManagementServerPropertiesAutoConfiguration.class })
|
||||
@Configuration
|
||||
public static class TestConfiguration {
|
||||
|
||||
@@ -122,6 +120,7 @@ public class InfoMvcEndpointTests {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,9 +50,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
* @author Meang Akira Tanaka
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = {TestConfiguration.class})
|
||||
@SpringApplicationConfiguration(classes = { TestConfiguration.class })
|
||||
@WebAppConfiguration
|
||||
public class InfoMvcEndpointWithoutAnyInfoProvidersTests {
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
@@ -70,11 +71,10 @@ public class InfoMvcEndpointWithoutAnyInfoProvidersTests {
|
||||
this.mvc.perform(get("/info")).andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Import({JacksonAutoConfiguration.class,
|
||||
@Import({ JacksonAutoConfiguration.class,
|
||||
HttpMessageConvertersAutoConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class,
|
||||
WebMvcAutoConfiguration.class,
|
||||
ManagementServerPropertiesAutoConfiguration.class})
|
||||
EndpointWebMvcAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||
ManagementServerPropertiesAutoConfiguration.class })
|
||||
@Configuration
|
||||
public static class TestConfiguration {
|
||||
|
||||
|
||||
@@ -33,9 +33,8 @@ public class EnvironmentInfoContributorTests {
|
||||
|
||||
@Test
|
||||
public void extractOnlyInfoProperty() {
|
||||
EnvironmentTestUtils.addEnvironment(this.environment,
|
||||
"info.app=my app", "info.version=1.0.0", "foo=bar");
|
||||
|
||||
EnvironmentTestUtils.addEnvironment(this.environment, "info.app=my app",
|
||||
"info.version=1.0.0", "foo=bar");
|
||||
Info actual = contributeFrom(this.environment);
|
||||
assertThat(actual.get("app", String.class)).isEqualTo("my app");
|
||||
assertThat(actual.get("version", String.class)).isEqualTo("1.0.0");
|
||||
@@ -45,13 +44,13 @@ public class EnvironmentInfoContributorTests {
|
||||
@Test
|
||||
public void extractNoEntry() {
|
||||
EnvironmentTestUtils.addEnvironment(this.environment, "foo=bar");
|
||||
|
||||
Info actual = contributeFrom(this.environment);
|
||||
assertThat(actual.getDetails().size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
private static Info contributeFrom(ConfigurableEnvironment environment) {
|
||||
EnvironmentInfoContributor contributor = new EnvironmentInfoContributor(environment);
|
||||
EnvironmentInfoContributor contributor = new EnvironmentInfoContributor(
|
||||
environment);
|
||||
Info.Builder builder = new Info.Builder();
|
||||
contributor.contribute(builder);
|
||||
return builder.build();
|
||||
|
||||
@@ -45,7 +45,6 @@ public class SimpleInfoContributorTests {
|
||||
assertThat(info.get("test")).isSameAs(o);
|
||||
}
|
||||
|
||||
|
||||
private static Info contributeFrom(String prefix, Object detail) {
|
||||
SimpleInfoContributor contributor = new SimpleInfoContributor(prefix, detail);
|
||||
Info.Builder builder = new Info.Builder();
|
||||
|
||||
Reference in New Issue
Block a user