mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Merge branch '1.5.x'
This commit is contained in:
commit
991314c63d
@ -42,7 +42,6 @@ import org.springframework.data.cassandra.core.CassandraAdminOperations;
|
||||
import org.springframework.data.cassandra.core.CassandraTemplate;
|
||||
import org.springframework.data.cassandra.core.convert.CassandraConverter;
|
||||
import org.springframework.data.cassandra.core.convert.MappingCassandraConverter;
|
||||
import org.springframework.data.cassandra.core.mapping.BasicCassandraMappingContext;
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
|
||||
import org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver;
|
||||
import org.springframework.util.StringUtils;
|
||||
@ -81,7 +80,7 @@ public class CassandraDataAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public CassandraMappingContext cassandraMapping() throws ClassNotFoundException {
|
||||
BasicCassandraMappingContext context = new BasicCassandraMappingContext();
|
||||
CassandraMappingContext context = new CassandraMappingContext();
|
||||
List<String> packages = EntityScanPackages.get(this.beanFactory)
|
||||
.getPackageNames();
|
||||
if (packages.isEmpty() && AutoConfigurationPackages.has(this.beanFactory)) {
|
||||
|
@ -36,7 +36,7 @@ import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.data.cassandra.core.mapping.BasicCassandraMappingContext;
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
|
||||
import org.springframework.data.cassandra.repository.config.EnableReactiveCassandraRepositories;
|
||||
import org.springframework.data.cql.core.session.ReactiveSession;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
@ -87,8 +87,8 @@ public class CassandraReactiveRepositoriesAutoConfigurationTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Set<Class<?>> getInitialEntitySet() {
|
||||
BasicCassandraMappingContext mappingContext = this.context
|
||||
.getBean(BasicCassandraMappingContext.class);
|
||||
CassandraMappingContext mappingContext = this.context
|
||||
.getBean(CassandraMappingContext.class);
|
||||
return (Set<Class<?>>) ReflectionTestUtils.getField(mappingContext,
|
||||
"initialEntitySet");
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.data.cassandra.core.mapping.BasicCassandraMappingContext;
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
|
||||
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@ -88,8 +88,8 @@ public class CassandraRepositoriesAutoConfigurationTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Set<Class<?>> getInitialEntitySet() {
|
||||
BasicCassandraMappingContext mappingContext = this.context
|
||||
.getBean(BasicCassandraMappingContext.class);
|
||||
CassandraMappingContext mappingContext = this.context
|
||||
.getBean(CassandraMappingContext.class);
|
||||
return (Set<Class<?>>) ReflectionTestUtils.getField(mappingContext,
|
||||
"initialEntitySet");
|
||||
}
|
||||
|
@ -210,19 +210,16 @@ public class DataSourceAutoConfigurationTests {
|
||||
@Test
|
||||
public void testExplicitDriverClassClearsUsername() throws Exception {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.driverClassName:"
|
||||
+ "org.springframework.boot.autoconfigure.jdbc."
|
||||
+ "DataSourceAutoConfigurationTests$DatabaseTestDriver",
|
||||
"spring.datasource.driverClassName:" + DatabaseTestDriver.class.getName(),
|
||||
"spring.datasource.url:jdbc:foo://localhost").applyTo(this.context);
|
||||
this.context.register(DataSourceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
DataSource bean = this.context.getBean(DataSource.class);
|
||||
assertThat(bean).isNotNull();
|
||||
HikariDataSource pool = (HikariDataSource) bean;
|
||||
assertThat(pool.getDriverClassName()).isEqualTo(
|
||||
"org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests$DatabaseTestDriver");
|
||||
assertThat(pool.getUsername()).isNull();
|
||||
DataSource dataSource = this.context.getBean(DataSource.class);
|
||||
assertThat(dataSource).isNotNull();
|
||||
assertThat(((HikariDataSource) dataSource).getDriverClassName())
|
||||
.isEqualTo(DatabaseTestDriver.class.getName());
|
||||
assertThat(((HikariDataSource) dataSource).getUsername()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -168,6 +168,7 @@ public class KafkaAutoConfigurationTests {
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void listenerProperties() {
|
||||
load("spring.kafka.template.default-topic=testTopic",
|
||||
@ -176,8 +177,8 @@ public class KafkaAutoConfigurationTests {
|
||||
"spring.kafka.listener.ack-time=456",
|
||||
"spring.kafka.listener.concurrency=3",
|
||||
"spring.kafka.listener.poll-timeout=2000",
|
||||
"spring.kafka.listener.type=batch",
|
||||
"spring.kafka.jaas.enabled=true", "spring.kafka.jaas.login-module=foo",
|
||||
"spring.kafka.listener.type=batch", "spring.kafka.jaas.enabled=true",
|
||||
"spring.kafka.jaas.login-module=foo",
|
||||
"spring.kafka.jaas.control-flag=REQUISITE",
|
||||
"spring.kafka.jaas.options.useKeyTab=true");
|
||||
DefaultKafkaProducerFactory<?, ?> producerFactory = this.context
|
||||
@ -199,8 +200,7 @@ public class KafkaAutoConfigurationTests {
|
||||
assertThat(dfa.getPropertyValue("concurrency")).isEqualTo(3);
|
||||
assertThat(dfa.getPropertyValue("containerProperties.pollTimeout"))
|
||||
.isEqualTo(2000L);
|
||||
assertThat(dfa.getPropertyValue("batchListener"))
|
||||
.isEqualTo(true);
|
||||
assertThat(dfa.getPropertyValue("batchListener")).isEqualTo(true);
|
||||
assertThat(this.context.getBeansOfType(KafkaJaasLoginModuleInitializer.class))
|
||||
.hasSize(1);
|
||||
KafkaJaasLoginModuleInitializer jaas = this.context
|
||||
|
@ -354,11 +354,8 @@ public class QuartzAutoConfigurationTests {
|
||||
|
||||
public static class ComponentThatUsesScheduler {
|
||||
|
||||
private Scheduler scheduler;
|
||||
|
||||
public ComponentThatUsesScheduler(Scheduler scheduler) {
|
||||
Assert.notNull(scheduler, "Scheduler must not be null");
|
||||
this.scheduler = scheduler;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -216,8 +216,8 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe
|
||||
ApplicationContext applicationContext) {
|
||||
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||
if (applicationContext instanceof DefaultResourceLoader) {
|
||||
Collection<ProtocolResolver> protocolResolvers =
|
||||
((DefaultResourceLoader) applicationContext).getProtocolResolvers();
|
||||
Collection<ProtocolResolver> protocolResolvers = ((DefaultResourceLoader) applicationContext)
|
||||
.getProtocolResolvers();
|
||||
for (ProtocolResolver protocolResolver : protocolResolvers) {
|
||||
resourceLoader.addProtocolResolver(protocolResolver);
|
||||
}
|
||||
@ -247,11 +247,11 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe
|
||||
|
||||
private ResourceLoader createResourceLoader(
|
||||
WebApplicationContext applicationContext) {
|
||||
WebApplicationContextResourceLoader resourceLoader =
|
||||
new WebApplicationContextResourceLoader(applicationContext);
|
||||
WebApplicationContextResourceLoader resourceLoader = new WebApplicationContextResourceLoader(
|
||||
applicationContext);
|
||||
if (applicationContext instanceof DefaultResourceLoader) {
|
||||
Collection<ProtocolResolver> protocolResolvers =
|
||||
((DefaultResourceLoader) applicationContext).getProtocolResolvers();
|
||||
Collection<ProtocolResolver> protocolResolvers = ((DefaultResourceLoader) applicationContext)
|
||||
.getProtocolResolvers();
|
||||
for (ProtocolResolver protocolResolver : protocolResolvers) {
|
||||
resourceLoader.addProtocolResolver(protocolResolver);
|
||||
}
|
||||
|
@ -110,8 +110,9 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||
context.register(classes);
|
||||
context.register(DevToolsDataSourceAutoConfiguration.class);
|
||||
if (driverClassName != null) {
|
||||
TestPropertyValues.of(
|
||||
"spring.datasource.driver-class-name:" + driverClassName).applyTo(context);
|
||||
TestPropertyValues
|
||||
.of("spring.datasource.driver-class-name:" + driverClassName)
|
||||
.applyTo(context);
|
||||
}
|
||||
if (url != null) {
|
||||
TestPropertyValues.of("spring.datasource.url:" + url).applyTo(context);
|
||||
|
@ -39,9 +39,9 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||
import org.springframework.web.context.support.ServletContextResource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@ -168,8 +168,7 @@ public class ClassLoaderFilesResourcePatternResolverTests {
|
||||
|
||||
private ProtocolResolver mockProtocolResolver(String path, Resource resource) {
|
||||
ProtocolResolver resolver = mock(ProtocolResolver.class);
|
||||
given(resolver.resolve(eq(path), any(ResourceLoader.class)))
|
||||
.willReturn(resource);
|
||||
given(resolver.resolve(eq(path), any(ResourceLoader.class))).willReturn(resource);
|
||||
return resolver;
|
||||
}
|
||||
|
||||
|
@ -47,16 +47,16 @@ public class SampleHypermediaUiSecureApplicationTests {
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/env",
|
||||
String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
ResponseEntity<String> user = this.restTemplate.getForEntity("/application/env/foo",
|
||||
String.class);
|
||||
ResponseEntity<String> user = this.restTemplate
|
||||
.getForEntity("/application/env/foo", String.class);
|
||||
assertThat(user.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(user.getBody()).contains("{\"foo\":");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSecurePath() throws Exception {
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/metrics",
|
||||
String.class);
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.getForEntity("/application/metrics", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
@ -29,7 +28,7 @@ import javax.persistence.SequenceGenerator;
|
||||
public class Tag {
|
||||
|
||||
@Id
|
||||
@SequenceGenerator(name="tag_generator", sequenceName="tag_sequence", initialValue = 4)
|
||||
@SequenceGenerator(name = "tag_generator", sequenceName = "tag_sequence", initialValue = 4)
|
||||
@GeneratedValue(generator = "tag_generator")
|
||||
private long id;
|
||||
|
||||
|
@ -22,7 +22,7 @@ import org.quartz.JobExecutionException;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
public class SampleJob extends QuartzJobBean {
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
// Invoked if a Job data map entry with that name
|
||||
|
@ -70,7 +70,8 @@ public class SampleSecureOAuth2ActuatorApplicationTests {
|
||||
|
||||
@Test
|
||||
public void healthAvailable() throws Exception {
|
||||
this.mvc.perform(get("/application/health")).andExpect(status().isOk()).andDo(print());
|
||||
this.mvc.perform(get("/application/health")).andExpect(status().isOk())
|
||||
.andDo(print());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -56,8 +56,9 @@ class OverrideAutoConfigurationContextCustomizerFactory
|
||||
@Override
|
||||
public void customizeContext(ConfigurableApplicationContext context,
|
||||
MergedContextConfiguration mergedConfig) {
|
||||
TestPropertyValues.of(
|
||||
EnableAutoConfiguration.ENABLED_OVERRIDE_PROPERTY + "=false").applyTo(context);
|
||||
TestPropertyValues
|
||||
.of(EnableAutoConfiguration.ENABLED_OVERRIDE_PROPERTY + "=false")
|
||||
.applyTo(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,9 +26,9 @@ import java.lang.annotation.Target;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
|
||||
/**
|
||||
* {@link ImportAutoConfiguration Auto-configuration imports} for typical Data LDAP
|
||||
* tests. Most tests should consider using {@link DataLdapTest @DataLdapTest} rather
|
||||
* than using this annotation directly.
|
||||
* {@link ImportAutoConfiguration Auto-configuration imports} for typical Data LDAP tests.
|
||||
* Most tests should consider using {@link DataLdapTest @DataLdapTest} rather than using
|
||||
* this annotation directly.
|
||||
*
|
||||
* @author Eddú Meléndez
|
||||
* @since 2.0.0
|
||||
|
@ -35,8 +35,8 @@ import org.springframework.test.context.BootstrapWith;
|
||||
|
||||
/**
|
||||
* Annotation that can be used in combination with {@code @RunWith(SpringRunner.class)}
|
||||
* for a typical LDAP test. Can be used when a test focuses <strong>only</strong> on
|
||||
* LDAP components.
|
||||
* for a typical LDAP test. Can be used when a test focuses <strong>only</strong> on LDAP
|
||||
* components.
|
||||
* <p>
|
||||
* Using this annotation will disable full auto-configuration and instead apply only
|
||||
* configuration relevant to LDAP tests.
|
||||
|
@ -46,12 +46,12 @@ class DataLdapTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter
|
||||
@Override
|
||||
protected Filter[] getFilters(FilterType type) {
|
||||
switch (type) {
|
||||
case INCLUDE:
|
||||
return this.annotation.includeFilters();
|
||||
case EXCLUDE:
|
||||
return this.annotation.excludeFilters();
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported type " + type);
|
||||
case INCLUDE:
|
||||
return this.annotation.includeFilters();
|
||||
case EXCLUDE:
|
||||
return this.annotation.excludeFilters();
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported type " + type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,12 +46,12 @@ class DataNeo4jTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter
|
||||
@Override
|
||||
protected Filter[] getFilters(FilterType type) {
|
||||
switch (type) {
|
||||
case INCLUDE:
|
||||
return this.annotation.includeFilters();
|
||||
case EXCLUDE:
|
||||
return this.annotation.excludeFilters();
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported type " + type);
|
||||
case INCLUDE:
|
||||
return this.annotation.includeFilters();
|
||||
case EXCLUDE:
|
||||
return this.annotation.excludeFilters();
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported type " + type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,12 +46,12 @@ class DataRedisTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter
|
||||
@Override
|
||||
protected Filter[] getFilters(FilterType type) {
|
||||
switch (type) {
|
||||
case INCLUDE:
|
||||
return this.annotation.includeFilters();
|
||||
case EXCLUDE:
|
||||
return this.annotation.excludeFilters();
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported type " + type);
|
||||
case INCLUDE:
|
||||
return this.annotation.includeFilters();
|
||||
case EXCLUDE:
|
||||
return this.annotation.excludeFilters();
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported type " + type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@DataLdapTest
|
||||
@TestPropertySource(properties = {"spring.ldap.embedded.base-dn=dc=spring,dc=org",
|
||||
"spring.ldap.embedded.ldif=classpath:org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif"})
|
||||
@TestPropertySource(properties = { "spring.ldap.embedded.base-dn=dc=spring,dc=org",
|
||||
"spring.ldap.embedded.ldif=classpath:org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif" })
|
||||
public class DataLdapTestIntegrationTests {
|
||||
|
||||
@Rule
|
||||
@ -63,10 +63,11 @@ public class DataLdapTestIntegrationTests {
|
||||
LdapQuery ldapQuery = LdapQueryBuilder.query().where("cn").is("Bob Smith");
|
||||
Optional<ExampleEntry> entry = this.exampleRepository.findOne(ldapQuery);
|
||||
assertThat(entry.isPresent());
|
||||
assertThat(entry.get().getDn())
|
||||
.isEqualTo(LdapUtils.newLdapName("cn=Bob Smith,ou=company1,c=Sweden,dc=spring,dc=org"));
|
||||
assertThat(this.ldapTemplate.findOne(ldapQuery, ExampleEntry.class) .getDn())
|
||||
.isEqualTo(LdapUtils.newLdapName("cn=Bob Smith,ou=company1,c=Sweden,dc=spring,dc=org"));
|
||||
assertThat(entry.get().getDn()).isEqualTo(LdapUtils
|
||||
.newLdapName("cn=Bob Smith,ou=company1,c=Sweden,dc=spring,dc=org"));
|
||||
assertThat(this.ldapTemplate.findOne(ldapQuery, ExampleEntry.class).getDn())
|
||||
.isEqualTo(LdapUtils.newLdapName(
|
||||
"cn=Bob Smith,ou=company1,c=Sweden,dc=spring,dc=org"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -36,8 +36,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@DataLdapTest(includeFilters = @Filter(Service.class))
|
||||
@TestPropertySource(properties = {"spring.ldap.embedded.base-dn=dc=spring,dc=org",
|
||||
"spring.ldap.embedded.ldif=classpath:org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif"})
|
||||
@TestPropertySource(properties = { "spring.ldap.embedded.base-dn=dc=spring,dc=org",
|
||||
"spring.ldap.embedded.ldif=classpath:org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif" })
|
||||
public class DataLdapTestWithIncludeFilterIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
|
@ -38,7 +38,7 @@ public class DataNeo4jTestWithIncludeFilterIntegrationTests {
|
||||
|
||||
@Rule
|
||||
public Neo4jTestServer server = new Neo4jTestServer(
|
||||
new String[]{"org.springframework.boot.test.autoconfigure.data.neo4j"});
|
||||
new String[] { "org.springframework.boot.test.autoconfigure.data.neo4j" });
|
||||
|
||||
@Autowired
|
||||
private ExampleService service;
|
||||
|
@ -104,8 +104,9 @@ public class Neo4jTestServer implements TestRule {
|
||||
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
Assume.assumeTrue("Skipping test due to Neo4j SessionFactory"
|
||||
+ " not being available", false);
|
||||
Assume.assumeTrue(
|
||||
"Skipping test due to Neo4j SessionFactory" + " not being available",
|
||||
false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -66,7 +66,8 @@ public class DataRedisTestIntegrationTests {
|
||||
assertThat(personHash.getId()).isNull();
|
||||
PersonHash savedEntity = this.exampleRepository.save(personHash);
|
||||
assertThat(savedEntity.getId()).isNotNull();
|
||||
assertThat(this.operations.execute((RedisConnection connection) -> connection.exists(("persons:" + savedEntity.getId()).getBytes(CHARSET)))).isTrue();
|
||||
assertThat(this.operations.execute((RedisConnection connection) -> connection
|
||||
.exists(("persons:" + savedEntity.getId()).getBytes(CHARSET)))).isTrue();
|
||||
this.exampleRepository.deleteAll();
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ public class ExampleService {
|
||||
}
|
||||
|
||||
public boolean hasRecord(PersonHash personHash) {
|
||||
return this.operations.execute((RedisConnection connection) ->
|
||||
connection.exists(("persons:" + personHash.getId()).getBytes(CHARSET)));
|
||||
return this.operations.execute((RedisConnection connection) -> connection
|
||||
.exists(("persons:" + personHash.getId()).getBytes(CHARSET)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc;
|
||||
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
|
||||
/**
|
||||
* Example exception used in {@link WebMvcTest} tests.
|
||||
*
|
||||
|
@ -150,8 +150,10 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
|
||||
private void setActiveProfiles(ConfigurableEnvironment environment,
|
||||
String[] profiles) {
|
||||
TestPropertyValues.of("spring.profiles.active="
|
||||
+ StringUtils.arrayToCommaDelimitedString(profiles)).applyTo(environment);
|
||||
TestPropertyValues
|
||||
.of("spring.profiles.active="
|
||||
+ StringUtils.arrayToCommaDelimitedString(profiles))
|
||||
.applyTo(environment);
|
||||
}
|
||||
|
||||
protected String[] getInlinedProperties(MergedContextConfiguration config) {
|
||||
|
@ -31,15 +31,15 @@ import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link SpringBootTest} in a reactive environment configured with
|
||||
* a user-defined {@link RestTemplate} that is named {@code testRestTemplate}.
|
||||
* Tests for {@link SpringBootTest} in a reactive environment configured with a
|
||||
* user-defined {@link RestTemplate} that is named {@code testRestTemplate}.
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@DirtiesContext
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
properties = { "spring.main.web-application-type=reactive", "value=123" })
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
|
||||
"spring.main.web-application-type=reactive", "value=123" })
|
||||
public class SpringBootTestReactiveWebEnvironmentUserDefinedTestRestTemplateTests
|
||||
extends AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests {
|
||||
|
||||
|
@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
public class EnvironmentTestUtilsTests {
|
||||
|
||||
private final ConfigurableEnvironment environment = new StandardEnvironment();
|
||||
|
@ -71,8 +71,8 @@ public class ItemDeprecation {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ItemDeprecation{" + "reason='" + this.reason + '\'' + ", "
|
||||
+ "replacement='" + this.replacement + '\'' + ", "
|
||||
+ "level='" + this.level + '\'' + '}';
|
||||
+ "replacement='" + this.replacement + '\'' + ", " + "level='"
|
||||
+ this.level + '\'' + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -556,16 +556,14 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
@Test
|
||||
public void mergeExistingPropertyDeprecation() throws Exception {
|
||||
ItemMetadata property = ItemMetadata.newProperty("simple", "comparator", null,
|
||||
null, null, null, null,
|
||||
new ItemDeprecation("Don't use this.", "simple.complex-comparator",
|
||||
"error"));
|
||||
null, null, null, null, new ItemDeprecation("Don't use this.",
|
||||
"simple.complex-comparator", "error"));
|
||||
writeAdditionalMetadata(property);
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(metadata)
|
||||
.has(Metadata.withProperty("simple.comparator", "java.util.Comparator<?>")
|
||||
.fromSource(SimpleProperties.class)
|
||||
.withDeprecation("Don't use this.", "simple.complex-comparator",
|
||||
"error"));
|
||||
.fromSource(SimpleProperties.class).withDeprecation(
|
||||
"Don't use this.", "simple.complex-comparator", "error"));
|
||||
assertThat(metadata.getItems()).hasSize(4);
|
||||
}
|
||||
|
||||
@ -591,8 +589,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
ConfigurationMetadata metadata = compile(DeprecatedSingleProperty.class);
|
||||
assertThat(metadata).has(
|
||||
Metadata.withProperty("singledeprecated.name", String.class.getName())
|
||||
.fromSource(DeprecatedSingleProperty.class)
|
||||
.withDeprecation("renamed", "singledeprecated.new-name", "error"));
|
||||
.fromSource(DeprecatedSingleProperty.class).withDeprecation(
|
||||
"renamed", "singledeprecated.new-name", "error"));
|
||||
assertThat(metadata.getItems()).hasSize(3);
|
||||
}
|
||||
|
||||
|
@ -63,12 +63,10 @@ public class RedisTestServer implements TestRule {
|
||||
ClassLoader classLoader = RedisTestServer.class.getClassLoader();
|
||||
RedisConnectionFactory cf;
|
||||
if (ClassUtils.isPresent("redis.clients.jedis.Jedis", classLoader)) {
|
||||
cf = new JedisConnectionFactoryConfiguration()
|
||||
.createConnectionFactory();
|
||||
cf = new JedisConnectionFactoryConfiguration().createConnectionFactory();
|
||||
}
|
||||
else {
|
||||
cf = new LettuceConnectionFactoryConfiguration()
|
||||
.createConnectionFactory();
|
||||
cf = new LettuceConnectionFactoryConfiguration().createConnectionFactory();
|
||||
}
|
||||
|
||||
testConnection(cf);
|
||||
@ -142,8 +140,7 @@ public class RedisTestServer implements TestRule {
|
||||
|
||||
RedisConnectionFactory createConnectionFactory() {
|
||||
LettuceClientConfiguration config = LettuceClientConfiguration.builder()
|
||||
.shutdownTimeout(Duration.ofMillis(0))
|
||||
.build();
|
||||
.shutdownTimeout(Duration.ofMillis(0)).build();
|
||||
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(
|
||||
new RedisStandaloneConfiguration(), config);
|
||||
connectionFactory.afterPropertiesSet();
|
||||
|
@ -79,8 +79,8 @@ public class JsonComponentModule extends SimpleModule implements BeanFactoryAwar
|
||||
addDeserializerWithDeducedType((JsonDeserializer<?>) bean);
|
||||
}
|
||||
for (Class<?> innerClass : bean.getClass().getDeclaredClasses()) {
|
||||
if (!Modifier.isAbstract(innerClass.getModifiers()) &&
|
||||
(JsonSerializer.class.isAssignableFrom(innerClass)
|
||||
if (!Modifier.isAbstract(innerClass.getModifiers())
|
||||
&& (JsonSerializer.class.isAssignableFrom(innerClass)
|
||||
|| JsonDeserializer.class.isAssignableFrom(innerClass))) {
|
||||
try {
|
||||
addJsonBean(innerClass.newInstance());
|
||||
|
@ -987,7 +987,7 @@ public class SpringApplicationTests {
|
||||
public void run() {
|
||||
SpringApplication application = new SpringApplication(
|
||||
FailingConfig.class);
|
||||
application.setWebEnvironment(false);
|
||||
application.setWebApplicationType(WebApplicationType.NONE);
|
||||
application.run();
|
||||
};
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -73,7 +73,8 @@ public class CloudPlatformTests {
|
||||
|
||||
@Test
|
||||
public void getActiveWhenHasHcLandscapeShouldReturnHcp() throws Exception {
|
||||
Environment environment = new MockEnvironment().withProperty("HC_LANDSCAPE", "---");
|
||||
Environment environment = new MockEnvironment().withProperty("HC_LANDSCAPE",
|
||||
"---");
|
||||
CloudPlatform platform = CloudPlatform.getActive(environment);
|
||||
assertThat(platform).isEqualTo(CloudPlatform.HCP);
|
||||
assertThat(platform.isActive(environment)).isTrue();
|
||||
|
@ -109,7 +109,8 @@ public class JsonComponentModuleTests {
|
||||
@JsonComponent
|
||||
static class ComponentWithInnerAbstractClass {
|
||||
|
||||
private static abstract class AbstractSerializer extends NameAndAgeJsonComponent.Serializer {
|
||||
private static abstract class AbstractSerializer
|
||||
extends NameAndAgeJsonComponent.Serializer {
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user