pull/11775/head
Andy Wilkinson 7 years ago
parent e2cb7a7545
commit 4c23afdcd8

@ -80,18 +80,16 @@ public class WebEndpointAutoConfigurationTests {
@Test @Test
public void webApplicationConfiguresExposeExcludePropertyEndpointFilter() { public void webApplicationConfiguresExposeExcludePropertyEndpointFilter() {
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> assertThat(context)
assertThat(context).getBeans(ExposeExcludePropertyEndpointFilter.class) .getBeans(ExposeExcludePropertyEndpointFilter.class)
.containsKeys("webIncludeExcludePropertyEndpointFilter", .containsKeys("webIncludeExcludePropertyEndpointFilter",
"controllerIncludeExcludePropertyEndpointFilter"); "controllerIncludeExcludePropertyEndpointFilter"));
});
} }
@Test @Test
public void contextShouldConfigureServletEndpointDiscoverer() { public void contextShouldConfigureServletEndpointDiscoverer() {
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> assertThat(context)
assertThat(context).hasSingleBean(ServletEndpointDiscoverer.class); .hasSingleBean(ServletEndpointDiscoverer.class));
});
} }
@Test @Test

@ -52,9 +52,8 @@ public class ServletEndpointRegistrar implements ServletContextInitializer {
@Override @Override
public void onStartup(ServletContext servletContext) throws ServletException { public void onStartup(ServletContext servletContext) throws ServletException {
this.servletEndpoints.forEach((servletEndpoint) -> { this.servletEndpoints
register(servletContext, servletEndpoint); .forEach((servletEndpoint) -> register(servletContext, servletEndpoint));
});
} }
private void register(ServletContext servletContext, private void register(ServletContext servletContext,

@ -160,11 +160,9 @@ public class RedisAutoConfigurationTests {
.withPropertyValues("spring.redis.sentinel.master:mymaster", .withPropertyValues("spring.redis.sentinel.master:mymaster",
"spring.redis.sentinel.nodes:" "spring.redis.sentinel.nodes:"
+ StringUtils.collectionToCommaDelimitedString(sentinels)) + StringUtils.collectionToCommaDelimitedString(sentinels))
.run((context) -> { .run((context) -> assertThat(context
assertThat(context.getBean(LettuceConnectionFactory.class) .getBean(LettuceConnectionFactory.class).isRedisSentinelAware())
.isRedisSentinelAware()).isTrue(); .isTrue());
});
} }
@Test @Test
@ -192,11 +190,9 @@ public class RedisAutoConfigurationTests {
.withPropertyValues( .withPropertyValues(
"spring.redis.cluster.nodes[0]:" + clusterNodes.get(0), "spring.redis.cluster.nodes[0]:" + clusterNodes.get(0),
"spring.redis.cluster.nodes[1]:" + clusterNodes.get(1)) "spring.redis.cluster.nodes[1]:" + clusterNodes.get(1))
.run((context) -> { .run((context) -> assertThat(context
assertThat(context.getBean(LettuceConnectionFactory.class) .getBean(LettuceConnectionFactory.class).getClusterConnection())
.getClusterConnection()).isNotNull(); .isNotNull());
});
} }
@Test @Test
@ -206,12 +202,11 @@ public class RedisAutoConfigurationTests {
.withPropertyValues("spring.redis.password=password", .withPropertyValues("spring.redis.password=password",
"spring.redis.cluster.nodes[0]:" + clusterNodes.get(0), "spring.redis.cluster.nodes[0]:" + clusterNodes.get(0),
"spring.redis.cluster.nodes[1]:" + clusterNodes.get(1)) "spring.redis.cluster.nodes[1]:" + clusterNodes.get(1))
.run((context) -> { .run((context) -> assertThat(
assertThat( context.getBean(LettuceConnectionFactory.class).getPassword())
context.getBean(LettuceConnectionFactory.class).getPassword()) .isEqualTo("password")
.isEqualTo("password");
}); );
} }
private LettucePoolingClientConfiguration getPoolingClientConfiguration( private LettucePoolingClientConfiguration getPoolingClientConfiguration(

@ -74,9 +74,9 @@ public class JestAutoConfigurationTests {
@Test @Test
public void jestClientOnLocalhostByDefault() { public void jestClientOnLocalhostByDefault() {
this.contextRunner.run((context) -> { this.contextRunner
assertThat(context.getBeansOfType(JestClient.class)).hasSize(1); .run((context) -> assertThat(context.getBeansOfType(JestClient.class))
}); .hasSize(1));
} }
@Test @Test
@ -84,9 +84,8 @@ public class JestAutoConfigurationTests {
this.contextRunner.withUserConfiguration(CustomJestClient.class) this.contextRunner.withUserConfiguration(CustomJestClient.class)
.withPropertyValues( .withPropertyValues(
"spring.elasticsearch.jest.uris[0]=http://localhost:9200") "spring.elasticsearch.jest.uris[0]=http://localhost:9200")
.run((context) -> { .run((context) -> assertThat(context.getBeansOfType(JestClient.class))
assertThat(context.getBeansOfType(JestClient.class)).hasSize(1); .hasSize(1));
});
} }
@Test @Test
@ -120,11 +119,9 @@ public class JestAutoConfigurationTests {
.withPropertyValues( .withPropertyValues(
"spring.elasticsearch.jest.uris=http://localhost:9200", "spring.elasticsearch.jest.uris=http://localhost:9200",
"spring.elasticsearch.jest.proxy.host=proxy.example.com") "spring.elasticsearch.jest.proxy.host=proxy.example.com")
.run((context) -> { .run((context) -> assertThat(context.getStartupFailure())
assertThat(context.getStartupFailure()) .isInstanceOf(BeanCreationException.class)
.isInstanceOf(BeanCreationException.class) .hasMessageContaining("Proxy port must not be null"));
.hasMessageContaining("Proxy port must not be null");
});
} }
@Test @Test

@ -44,9 +44,9 @@ public class ProjectInfoAutoConfigurationTests {
@Test @Test
public void gitPropertiesUnavailableIfResourceNotAvailable() { public void gitPropertiesUnavailableIfResourceNotAvailable() {
this.contextRunner.run((context) -> { this.contextRunner
assertThat(context.getBeansOfType(GitProperties.class)).isEmpty(); .run((context) -> assertThat(context.getBeansOfType(GitProperties.class))
}); .isEmpty());
} }
@Test @Test
@ -107,9 +107,8 @@ public class ProjectInfoAutoConfigurationTests {
this.contextRunner this.contextRunner
.withPropertyValues("spring.info.build.location=" .withPropertyValues("spring.info.build.location="
+ "classpath:/org/acme/no-build-info.properties") + "classpath:/org/acme/no-build-info.properties")
.run((context) -> { .run((context) -> assertThat(
assertThat(context.getBeansOfType(BuildProperties.class)).hasSize(0); context.getBeansOfType(BuildProperties.class)).hasSize(0));
});
} }
@Test @Test

@ -66,9 +66,9 @@ public class JooqAutoConfigurationTests {
@Test @Test
public void noDataSource() { public void noDataSource() {
this.contextRunner.run((context) -> { this.contextRunner
assertThat(context.getBeansOfType(DSLContext.class)).isEmpty(); .run((context) -> assertThat(context.getBeansOfType(DSLContext.class))
}); .isEmpty());
} }
@Test @Test
@ -151,10 +151,10 @@ public class JooqAutoConfigurationTests {
@Test @Test
public void relaxedBindingOfSqlDialect() { public void relaxedBindingOfSqlDialect() {
this.contextRunner.withUserConfiguration(JooqDataSourceConfiguration.class) this.contextRunner.withUserConfiguration(JooqDataSourceConfiguration.class)
.withPropertyValues("spring.jooq.sql-dialect:PoSTGrES").run((context) -> { .withPropertyValues("spring.jooq.sql-dialect:PoSTGrES")
assertThat(context.getBean(org.jooq.Configuration.class).dialect()) .run((context) -> assertThat(
.isEqualTo(SQLDialect.POSTGRES); context.getBean(org.jooq.Configuration.class).dialect())
}); .isEqualTo(SQLDialect.POSTGRES));
} }
private static class AssertFetch implements TransactionalRunnable { private static class AssertFetch implements TransactionalRunnable {

@ -39,7 +39,7 @@ public class LdapAutoConfigurationTests {
@Test @Test
public void contextSourceWithDefaultUrl() { public void contextSourceWithDefaultUrl() {
this.contextRunner.run(context -> { this.contextRunner.run((context) -> {
LdapContextSource contextSource = context.getBean(LdapContextSource.class); LdapContextSource contextSource = context.getBean(LdapContextSource.class);
String[] urls = (String[]) ReflectionTestUtils.getField(contextSource, String[] urls = (String[]) ReflectionTestUtils.getField(contextSource,
"urls"); "urls");
@ -51,7 +51,7 @@ public class LdapAutoConfigurationTests {
@Test @Test
public void contextSourceWithSingleUrl() { public void contextSourceWithSingleUrl() {
this.contextRunner.withPropertyValues("spring.ldap.urls:ldap://localhost:123") this.contextRunner.withPropertyValues("spring.ldap.urls:ldap://localhost:123")
.run(context -> { .run((context) -> {
ContextSource contextSource = context.getBean(ContextSource.class); ContextSource contextSource = context.getBean(ContextSource.class);
String[] urls = (String[]) ReflectionTestUtils.getField(contextSource, String[] urls = (String[]) ReflectionTestUtils.getField(contextSource,
"urls"); "urls");
@ -64,7 +64,7 @@ public class LdapAutoConfigurationTests {
this.contextRunner this.contextRunner
.withPropertyValues( .withPropertyValues(
"spring.ldap.urls:ldap://localhost:123,ldap://mycompany:123") "spring.ldap.urls:ldap://localhost:123,ldap://mycompany:123")
.run(context -> { .run((context) -> {
ContextSource contextSource = context.getBean(ContextSource.class); ContextSource contextSource = context.getBean(ContextSource.class);
LdapProperties ldapProperties = context.getBean(LdapProperties.class); LdapProperties ldapProperties = context.getBean(LdapProperties.class);
String[] urls = (String[]) ReflectionTestUtils.getField(contextSource, String[] urls = (String[]) ReflectionTestUtils.getField(contextSource,
@ -83,7 +83,7 @@ public class LdapAutoConfigurationTests {
"spring.ldap.anonymous-read-only:true", "spring.ldap.anonymous-read-only:true",
"spring.ldap.base:cn=SpringDevelopers", "spring.ldap.base:cn=SpringDevelopers",
"spring.ldap.baseEnvironment.java.naming.security.authentication:DIGEST-MD5") "spring.ldap.baseEnvironment.java.naming.security.authentication:DIGEST-MD5")
.run(context -> { .run((context) -> {
LdapContextSource contextSource = context LdapContextSource contextSource = context
.getBean(LdapContextSource.class); .getBean(LdapContextSource.class);
assertThat(contextSource.getUserDn()).isEqualTo("root"); assertThat(contextSource.getUserDn()).isEqualTo("root");

@ -75,7 +75,7 @@ class PropertiesMigrationReport {
report.append(String.format("%nThe use of configuration keys that are no longer " report.append(String.format("%nThe use of configuration keys that are no longer "
+ "supported was found in the environment:%n%n")); + "supported was found in the environment:%n%n"));
append(report, content, append(report, content,
metadata -> "Reason: " (metadata) -> "Reason: "
+ (StringUtils.hasText(metadata.getDeprecation().getReason()) + (StringUtils.hasText(metadata.getDeprecation().getReason())
? metadata.getDeprecation().getReason() : "none")); ? metadata.getDeprecation().getReason() : "none"));
report.append(String.format("%n")); report.append(String.format("%n"));

Loading…
Cancel
Save