Polish
This commit is contained in:
@@ -29,8 +29,6 @@ import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitProperties.Retry;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitProperties.Template;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -161,29 +159,33 @@ public class RabbitAutoConfiguration {
|
||||
if (messageConverter != null) {
|
||||
rabbitTemplate.setMessageConverter(messageConverter);
|
||||
}
|
||||
Template template = this.properties.getTemplate();
|
||||
Retry retry = template.getRetry();
|
||||
if (retry.isEnabled()) {
|
||||
RetryTemplate retryTemplate = new RetryTemplate();
|
||||
SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
|
||||
retryPolicy.setMaxAttempts(retry.getMaxAttempts());
|
||||
retryTemplate.setRetryPolicy(retryPolicy);
|
||||
ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
|
||||
backOffPolicy.setInitialInterval(retry.getInitialInterval());
|
||||
backOffPolicy.setMultiplier(retry.getMultiplier());
|
||||
backOffPolicy.setMaxInterval(retry.getMaxInterval());
|
||||
retryTemplate.setBackOffPolicy(backOffPolicy);
|
||||
rabbitTemplate.setRetryTemplate(retryTemplate);
|
||||
RabbitProperties.Template templateProperties = this.properties.getTemplate();
|
||||
RabbitProperties.Retry retryProperties = templateProperties.getRetry();
|
||||
if (retryProperties.isEnabled()) {
|
||||
rabbitTemplate.setRetryTemplate(createRetryTemplate(retryProperties));
|
||||
}
|
||||
if (template.getReceiveTimeout() != null) {
|
||||
rabbitTemplate.setReceiveTimeout(template.getReceiveTimeout());
|
||||
if (templateProperties.getReceiveTimeout() != null) {
|
||||
rabbitTemplate.setReceiveTimeout(templateProperties.getReceiveTimeout());
|
||||
}
|
||||
if (template.getReplyTimeout() != null) {
|
||||
rabbitTemplate.setReplyTimeout(template.getReplyTimeout());
|
||||
if (templateProperties.getReplyTimeout() != null) {
|
||||
rabbitTemplate.setReplyTimeout(templateProperties.getReplyTimeout());
|
||||
}
|
||||
return rabbitTemplate;
|
||||
}
|
||||
|
||||
private RetryTemplate createRetryTemplate(RabbitProperties.Retry properties) {
|
||||
RetryTemplate template = new RetryTemplate();
|
||||
SimpleRetryPolicy policy = new SimpleRetryPolicy();
|
||||
policy.setMaxAttempts(properties.getMaxAttempts());
|
||||
template.setRetryPolicy(policy);
|
||||
ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
|
||||
backOffPolicy.setInitialInterval(properties.getInitialInterval());
|
||||
backOffPolicy.setMultiplier(properties.getMultiplier());
|
||||
backOffPolicy.setMaxInterval(properties.getMaxInterval());
|
||||
template.setBackOffPolicy(backOffPolicy);
|
||||
return template;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnSingleCandidate(ConnectionFactory.class)
|
||||
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "dynamic", matchIfMissing = true)
|
||||
@@ -192,7 +194,6 @@ public class RabbitAutoConfiguration {
|
||||
return new RabbitAdmin(connectionFactory);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -512,8 +512,7 @@ public class RabbitProperties {
|
||||
private int maxAttempts = 3;
|
||||
|
||||
/**
|
||||
* Interval between the first and second attempt to publish or deliver
|
||||
* a message.
|
||||
* Interval between the first and second attempt to publish or deliver a message.
|
||||
*/
|
||||
private long initialInterval = 1000L;
|
||||
|
||||
|
||||
@@ -92,14 +92,14 @@ public final class SimpleRabbitListenerContainerFactoryConfigurer {
|
||||
}
|
||||
ListenerRetry retryConfig = listenerConfig.getRetry();
|
||||
if (retryConfig.isEnabled()) {
|
||||
RetryInterceptorBuilder<?> builder = (retryConfig.isStateless() ?
|
||||
RetryInterceptorBuilder.stateless() : RetryInterceptorBuilder.stateful());
|
||||
factory.setAdviceChain(builder
|
||||
.maxAttempts(retryConfig.getMaxAttempts())
|
||||
.backOffOptions(retryConfig.getInitialInterval(),
|
||||
retryConfig.getMultiplier(), retryConfig.getMaxInterval())
|
||||
.recoverer(new RejectAndDontRequeueRecoverer())
|
||||
.build());
|
||||
RetryInterceptorBuilder<?> builder = (retryConfig.isStateless()
|
||||
? RetryInterceptorBuilder.stateless()
|
||||
: RetryInterceptorBuilder.stateful());
|
||||
builder.maxAttempts(retryConfig.getMaxAttempts());
|
||||
builder.backOffOptions(retryConfig.getInitialInterval(),
|
||||
retryConfig.getMultiplier(), retryConfig.getMaxInterval());
|
||||
builder.recoverer(new RejectAndDontRequeueRecoverer());
|
||||
factory.setAdviceChain(builder.build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ import org.springframework.util.Assert;
|
||||
@ConditionalOnMissingBean(value = CacheManager.class, name = "cacheResolver")
|
||||
@EnableConfigurationProperties(CacheProperties.class)
|
||||
@AutoConfigureBefore(HibernateJpaAutoConfiguration.class)
|
||||
@AutoConfigureAfter({CouchbaseAutoConfiguration.class, HazelcastAutoConfiguration.class,
|
||||
@AutoConfigureAfter({ CouchbaseAutoConfiguration.class, HazelcastAutoConfiguration.class,
|
||||
RedisAutoConfiguration.class })
|
||||
@Import({ CacheManagerCustomizers.class, CacheConfigurationImportSelector.class })
|
||||
public class CacheAutoConfiguration {
|
||||
|
||||
@@ -30,9 +30,6 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
final class CacheConfigurations {
|
||||
|
||||
private CacheConfigurations() {
|
||||
}
|
||||
|
||||
private static final Map<CacheType, Class<?>> MAPPINGS;
|
||||
|
||||
static {
|
||||
@@ -51,6 +48,9 @@ final class CacheConfigurations {
|
||||
MAPPINGS = Collections.unmodifiableMap(mappings);
|
||||
}
|
||||
|
||||
private CacheConfigurations() {
|
||||
}
|
||||
|
||||
public static String getConfigurationClass(CacheType cacheType) {
|
||||
Class<?> configurationClass = MAPPINGS.get(cacheType);
|
||||
Assert.state(configurationClass != null, "Unknown cache type " + cacheType);
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({Bucket.class, CouchbaseCacheManager.class})
|
||||
@ConditionalOnClass({ Bucket.class, CouchbaseCacheManager.class })
|
||||
@ConditionalOnMissingBean(CacheManager.class)
|
||||
@ConditionalOnSingleCandidate(Bucket.class)
|
||||
@Conditional(CacheCondition.class)
|
||||
@@ -60,8 +60,8 @@ public class CouchbaseCacheConfiguration {
|
||||
public CouchbaseCacheManager cacheManager() {
|
||||
List<String> cacheNames = this.cacheProperties.getCacheNames();
|
||||
CouchbaseCacheManager cacheManager = new CouchbaseCacheManager(
|
||||
CacheBuilder.newInstance(this.bucket)
|
||||
.withExpirationInMillis(this.cacheProperties.getCouchbase().getExpiration()),
|
||||
CacheBuilder.newInstance(this.bucket).withExpirationInMillis(
|
||||
this.cacheProperties.getCouchbase().getExpiration()),
|
||||
cacheNames.toArray(new String[cacheNames.size()]));
|
||||
return this.customizers.customize(cacheManager);
|
||||
}
|
||||
|
||||
@@ -45,12 +45,11 @@ import org.springframework.data.couchbase.config.CouchbaseConfigurer;
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({CouchbaseBucket.class, Cluster.class})
|
||||
@ConditionalOnClass({ CouchbaseBucket.class, Cluster.class })
|
||||
@Conditional(CouchbaseAutoConfiguration.CouchbaseCondition.class)
|
||||
@EnableConfigurationProperties(CouchbaseProperties.class)
|
||||
public class CouchbaseAutoConfiguration {
|
||||
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnMissingBean(CouchbaseConfigurer.class)
|
||||
public static class CouchbaseConfiguration {
|
||||
@@ -77,8 +76,10 @@ public class CouchbaseAutoConfiguration {
|
||||
@Bean
|
||||
@Primary
|
||||
public ClusterInfo couchbaseClusterInfo() throws Exception {
|
||||
return couchbaseCluster().clusterManager(this.properties.getBucket().getName(),
|
||||
this.properties.getBucket().getPassword()).info();
|
||||
return couchbaseCluster()
|
||||
.clusterManager(this.properties.getBucket().getName(),
|
||||
this.properties.getBucket().getPassword())
|
||||
.info();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -96,13 +97,12 @@ public class CouchbaseAutoConfiguration {
|
||||
protected CouchbaseEnvironment createEnvironment(CouchbaseProperties properties) {
|
||||
CouchbaseProperties.Endpoints endpoints = properties.getEnv().getEndpoints();
|
||||
CouchbaseProperties.Timeouts timeouts = properties.getEnv().getTimeouts();
|
||||
DefaultCouchbaseEnvironment.Builder builder = DefaultCouchbaseEnvironment.builder()
|
||||
.connectTimeout(timeouts.getConnect())
|
||||
DefaultCouchbaseEnvironment.Builder builder = DefaultCouchbaseEnvironment
|
||||
.builder().connectTimeout(timeouts.getConnect())
|
||||
.kvEndpoints(endpoints.getKeyValue())
|
||||
.kvTimeout(timeouts.getKeyValue())
|
||||
.queryEndpoints(endpoints.getQuery())
|
||||
.queryTimeout(timeouts.getQuery())
|
||||
.viewEndpoints(endpoints.getView())
|
||||
.queryTimeout(timeouts.getQuery()).viewEndpoints(endpoints.getView())
|
||||
.viewTimeout(timeouts.getView());
|
||||
CouchbaseProperties.Ssl ssl = properties.getEnv().getSsl();
|
||||
if (ssl.getEnabled()) {
|
||||
@@ -121,8 +121,8 @@ public class CouchbaseAutoConfiguration {
|
||||
|
||||
/**
|
||||
* Determine if Couchbase should be configured. This happens if either the
|
||||
* user-configuration defines a {@link CouchbaseConfigurer} or if at least
|
||||
* the "bootstrapHosts" property is specified.
|
||||
* user-configuration defines a {@link CouchbaseConfigurer} or if at least the
|
||||
* "bootstrapHosts" property is specified.
|
||||
*/
|
||||
static class CouchbaseCondition extends AnyNestedCondition {
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@ public class CouchbaseProperties {
|
||||
return this.env;
|
||||
}
|
||||
|
||||
|
||||
public static class Bucket {
|
||||
|
||||
/**
|
||||
@@ -175,7 +174,8 @@ public class CouchbaseProperties {
|
||||
private String keyStorePassword;
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return (this.enabled != null ? this.enabled : StringUtils.hasText(this.keyStore));
|
||||
return (this.enabled != null ? this.enabled
|
||||
: StringUtils.hasText(this.keyStore));
|
||||
}
|
||||
|
||||
public void setEnabled(Boolean enabled) {
|
||||
|
||||
@@ -25,8 +25,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.couchbase.config.CouchbaseConfigurer;
|
||||
|
||||
/**
|
||||
* Adapt the core Couchbase configuration to an expected {@link CouchbaseConfigurer}
|
||||
* if necessary.
|
||||
* Adapt the core Couchbase configuration to an expected {@link CouchbaseConfigurer} if
|
||||
* necessary.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@@ -44,8 +44,10 @@ class CouchbaseConfigurerAdapterConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public CouchbaseConfigurer springBootCouchbaseConfigurer() throws Exception {
|
||||
return new SpringBootCouchbaseConfigurer(this.configuration.couchbaseEnvironment(),
|
||||
this.configuration.couchbaseCluster(), this.configuration.couchbaseClusterInfo(),
|
||||
return new SpringBootCouchbaseConfigurer(
|
||||
this.configuration.couchbaseEnvironment(),
|
||||
this.configuration.couchbaseCluster(),
|
||||
this.configuration.couchbaseClusterInfo(),
|
||||
this.configuration.couchbaseClient());
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.springframework.data.couchbase.repository.CouchbaseRepository;
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({Bucket.class, CouchbaseRepository.class})
|
||||
@ConditionalOnClass({ Bucket.class, CouchbaseRepository.class })
|
||||
@AutoConfigureAfter(CouchbaseAutoConfiguration.class)
|
||||
@EnableConfigurationProperties(CouchbaseDataProperties.class)
|
||||
@Import({ CouchbaseConfigurerAdapterConfiguration.class,
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
|
||||
* Repositories.
|
||||
*
|
||||
* @author Eddú Meléndez
|
||||
* @since 1.4.0
|
||||
*/
|
||||
class CouchbaseRepositoriesRegistrar
|
||||
extends AbstractRepositoryConfigurationSourceSupport {
|
||||
|
||||
@@ -68,9 +68,7 @@ class SpringBootCouchbaseDataConfiguration extends AbstractCouchbaseDataConfigur
|
||||
if (this.properties.isAutoIndex()) {
|
||||
return new IndexManager(true, true, true);
|
||||
}
|
||||
else {
|
||||
return new IndexManager(false, false, false);
|
||||
}
|
||||
return new IndexManager(false, false, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,4 +43,5 @@ import org.springframework.data.redis.repository.support.RedisRepositoryFactoryB
|
||||
@Import(RedisRepositoriesAutoConfigureRegistrar.class)
|
||||
@AutoConfigureAfter(RedisAutoConfiguration.class)
|
||||
public class RedisRepositoriesAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ class RedisRepositoriesAutoConfigureRegistrar
|
||||
|
||||
@EnableRedisRepositories
|
||||
private static class EnableRedisRepositoriesConfiguration {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,7 +63,8 @@ public class H2ConsoleAutoConfiguration {
|
||||
public ServletRegistrationBean h2Console() {
|
||||
String path = this.properties.getPath();
|
||||
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
|
||||
ServletRegistrationBean registration = new ServletRegistrationBean(new WebServlet(), urlMapping);
|
||||
ServletRegistrationBean registration = new ServletRegistrationBean(
|
||||
new WebServlet(), urlMapping);
|
||||
H2ConsoleProperties.Settings settings = this.properties.getSettings();
|
||||
if (settings.isTrace()) {
|
||||
registration.addInitParameter("trace", "");
|
||||
|
||||
@@ -66,7 +66,8 @@ public class ProjectInfoAutoConfiguration {
|
||||
@ConditionalOnMissingBean
|
||||
@Bean
|
||||
public BuildProperties buildProperties() throws Exception {
|
||||
return new BuildProperties(loadFrom(this.properties.getBuild().getLocation(), "build"));
|
||||
return new BuildProperties(
|
||||
loadFrom(this.properties.getBuild().getLocation(), "build"));
|
||||
}
|
||||
|
||||
protected Properties loadFrom(Resource location, String prefix) throws IOException {
|
||||
@@ -88,8 +89,10 @@ public class ProjectInfoAutoConfiguration {
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
ResourceLoader loader = context.getResourceLoader() == null
|
||||
? this.defaultResourceLoader : context.getResourceLoader();
|
||||
ResourceLoader loader = context.getResourceLoader();
|
||||
if (loader == null) {
|
||||
loader = this.defaultResourceLoader;
|
||||
}
|
||||
PropertyResolver propertyResolver = context.getEnvironment();
|
||||
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
|
||||
propertyResolver, "spring.info.git.");
|
||||
|
||||
@@ -53,7 +53,6 @@ public class ProjectInfoProperties {
|
||||
getGit().setLocation(defaultGitLocation);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build specific info properties.
|
||||
*/
|
||||
@@ -62,7 +61,8 @@ public class ProjectInfoProperties {
|
||||
/**
|
||||
* Location of the generated build.properties file.
|
||||
*/
|
||||
private Resource location = new ClassPathResource("META-INF/boot/build.properties");
|
||||
private Resource location = new ClassPathResource(
|
||||
"META-INF/boot/build.properties");
|
||||
|
||||
public Resource getLocation() {
|
||||
return this.location;
|
||||
|
||||
@@ -65,7 +65,8 @@ public class JmsAutoConfiguration {
|
||||
public JmsTemplate jmsTemplate(ConnectionFactory connectionFactory) {
|
||||
JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
|
||||
jmsTemplate.setPubSubDomain(this.properties.isPubSubDomain());
|
||||
DestinationResolver destinationResolver = this.destinationResolver.getIfUnique();
|
||||
DestinationResolver destinationResolver = this.destinationResolver
|
||||
.getIfUnique();
|
||||
if (destinationResolver != null) {
|
||||
jmsTemplate.setDestinationResolver(destinationResolver);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ class ActiveMQConnectionFactoryConfiguration {
|
||||
@Bean(destroyMethod = "stop")
|
||||
@ConditionalOnProperty(prefix = "spring.activemq.pool", name = "enabled", havingValue = "true", matchIfMissing = false)
|
||||
@ConfigurationProperties("spring.activemq.pool.configuration")
|
||||
public PooledConnectionFactory pooledJmsConnectionFactory(ActiveMQProperties properties) {
|
||||
public PooledConnectionFactory pooledJmsConnectionFactory(
|
||||
ActiveMQProperties properties) {
|
||||
PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(
|
||||
new ActiveMQConnectionFactoryFactory(properties)
|
||||
.createConnectionFactory(ActiveMQConnectionFactory.class));
|
||||
|
||||
@@ -67,6 +67,26 @@ public class ActiveMQProperties {
|
||||
this.inMemory = inMemory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if pooling is enabled.
|
||||
* @return if pooling is enabled
|
||||
* @deprecated since 1.4 in favor of "spring.activemq.pool.enabled"
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isPooled() {
|
||||
return getPool().isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if pooling is enabled.
|
||||
* @param pooled the pooling enabled value
|
||||
* @deprecated since 1.4 in favor of "spring.activemq.pool.enabled"
|
||||
*/
|
||||
@Deprecated
|
||||
public void setPooled(boolean pooled) {
|
||||
getPool().setEnabled(pooled);
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return this.user;
|
||||
}
|
||||
@@ -91,7 +111,7 @@ public class ActiveMQProperties {
|
||||
this.pool = pool;
|
||||
}
|
||||
|
||||
protected static class Pool {
|
||||
public static class Pool {
|
||||
|
||||
/**
|
||||
* Whether a PooledConnectionFactory should be created instead of a regular
|
||||
@@ -147,4 +167,5 @@ public class ActiveMQProperties {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.springframework.context.annotation.Primary;
|
||||
class ActiveMQXAConnectionFactoryConfiguration {
|
||||
|
||||
@Primary
|
||||
@Bean(name = {"jmsConnectionFactory", "xaJmsConnectionFactory"})
|
||||
@Bean(name = { "jmsConnectionFactory", "xaJmsConnectionFactory" })
|
||||
public ConnectionFactory jmsConnectionFactory(ActiveMQProperties properties,
|
||||
XAConnectionFactoryWrapper wrapper) throws Exception {
|
||||
ActiveMQXAConnectionFactory connectionFactory = new ActiveMQConnectionFactoryFactory(
|
||||
|
||||
@@ -158,11 +158,14 @@ public class RabbitAutoConfigurationTests {
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitTemplate);
|
||||
assertThat(dfa.getPropertyValue("receiveTimeout")).isEqualTo(123L);
|
||||
assertThat(dfa.getPropertyValue("replyTimeout")).isEqualTo(456L);
|
||||
RetryTemplate retryTemplate = (RetryTemplate) dfa.getPropertyValue("retryTemplate");
|
||||
RetryTemplate retryTemplate = (RetryTemplate) dfa
|
||||
.getPropertyValue("retryTemplate");
|
||||
assertThat(retryTemplate).isNotNull();
|
||||
dfa = new DirectFieldAccessor(retryTemplate);
|
||||
SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) dfa.getPropertyValue("retryPolicy");
|
||||
ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) dfa.getPropertyValue("backOffPolicy");
|
||||
SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) dfa
|
||||
.getPropertyValue("retryPolicy");
|
||||
ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) dfa
|
||||
.getPropertyValue("backOffPolicy");
|
||||
assertThat(retryPolicy.getMaxAttempts()).isEqualTo(4);
|
||||
assertThat(backOffPolicy.getInitialInterval()).isEqualTo(2000);
|
||||
assertThat(backOffPolicy.getMultiplier()).isEqualTo(1.5);
|
||||
@@ -182,8 +185,7 @@ public class RabbitAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testConnectionFactoryCacheSettings() {
|
||||
load(TestConfiguration.class,
|
||||
"spring.rabbitmq.cache.channel.size=23",
|
||||
load(TestConfiguration.class, "spring.rabbitmq.cache.channel.size=23",
|
||||
"spring.rabbitmq.cache.channel.checkoutTimeout=1000",
|
||||
"spring.rabbitmq.cache.connection.mode=CONNECTION",
|
||||
"spring.rabbitmq.cache.connection.size=2");
|
||||
@@ -273,16 +275,20 @@ public class RabbitAutoConfigurationTests {
|
||||
assertThat(dfa.getPropertyValue("txSize")).isEqualTo(20);
|
||||
assertThat(dfa.getPropertyValue("messageConverter"))
|
||||
.isSameAs(this.context.getBean("myMessageConverter"));
|
||||
assertThat(dfa.getPropertyValue("defaultRequeueRejected")).isEqualTo(Boolean.FALSE);
|
||||
assertThat(dfa.getPropertyValue("defaultRequeueRejected"))
|
||||
.isEqualTo(Boolean.FALSE);
|
||||
Advice[] adviceChain = (Advice[]) dfa.getPropertyValue("adviceChain");
|
||||
assertThat(adviceChain).isNotNull();
|
||||
assertThat(adviceChain.length).isEqualTo(1);
|
||||
dfa = new DirectFieldAccessor(adviceChain[0]);
|
||||
RetryTemplate retryTemplate = (RetryTemplate) dfa.getPropertyValue("retryOperations");
|
||||
RetryTemplate retryTemplate = (RetryTemplate) dfa
|
||||
.getPropertyValue("retryOperations");
|
||||
assertThat(retryTemplate).isNotNull();
|
||||
dfa = new DirectFieldAccessor(retryTemplate);
|
||||
SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) dfa.getPropertyValue("retryPolicy");
|
||||
ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) dfa.getPropertyValue("backOffPolicy");
|
||||
SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) dfa
|
||||
.getPropertyValue("retryPolicy");
|
||||
ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) dfa
|
||||
.getPropertyValue("backOffPolicy");
|
||||
assertThat(retryPolicy.getMaxAttempts()).isEqualTo(4);
|
||||
assertThat(backOffPolicy.getInitialInterval()).isEqualTo(2000);
|
||||
assertThat(backOffPolicy.getMultiplier()).isEqualTo(1.5);
|
||||
@@ -427,10 +433,12 @@ public class RabbitAutoConfigurationTests {
|
||||
@Configuration
|
||||
@EnableRabbit
|
||||
protected static class EnableRabbitConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
protected static class NoEnableRabbitConfiguration {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -214,7 +214,8 @@ public class CacheAutoConfigurationTests {
|
||||
@Test
|
||||
public void couchbaseCacheExplicit() {
|
||||
load(CouchbaseCacheConfiguration.class, "spring.cache.type=couchbase");
|
||||
CouchbaseCacheManager cacheManager = validateCacheManager(CouchbaseCacheManager.class);
|
||||
CouchbaseCacheManager cacheManager = validateCacheManager(
|
||||
CouchbaseCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames()).isEmpty();
|
||||
}
|
||||
|
||||
@@ -228,24 +229,29 @@ public class CacheAutoConfigurationTests {
|
||||
public void couchbaseCacheExplicitWithCaches() {
|
||||
load(CouchbaseCacheConfiguration.class, "spring.cache.type=couchbase",
|
||||
"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
|
||||
CouchbaseCacheManager cacheManager = validateCacheManager(CouchbaseCacheManager.class);
|
||||
CouchbaseCacheManager cacheManager = validateCacheManager(
|
||||
CouchbaseCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
|
||||
Cache cache = cacheManager.getCache("foo");
|
||||
assertThat(cache).isInstanceOf(CouchbaseCache.class);
|
||||
assertThat(((CouchbaseCache) cache).getTtl()).isEqualTo(0);
|
||||
assertThat(((CouchbaseCache) cache).getNativeCache()).isEqualTo(this.context.getBean("bucket"));
|
||||
assertThat(((CouchbaseCache) cache).getNativeCache())
|
||||
.isEqualTo(this.context.getBean("bucket"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void couchbaseCacheExplicitWithTtl() {
|
||||
load(CouchbaseCacheConfiguration.class, "spring.cache.type=couchbase",
|
||||
"spring.cache.cacheNames=foo,bar", "spring.cache.couchbase.expiration=2000");
|
||||
CouchbaseCacheManager cacheManager = validateCacheManager(CouchbaseCacheManager.class);
|
||||
"spring.cache.cacheNames=foo,bar",
|
||||
"spring.cache.couchbase.expiration=2000");
|
||||
CouchbaseCacheManager cacheManager = validateCacheManager(
|
||||
CouchbaseCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
|
||||
Cache cache = cacheManager.getCache("foo");
|
||||
assertThat(cache).isInstanceOf(CouchbaseCache.class);
|
||||
assertThat(((CouchbaseCache) cache).getTtl()).isEqualTo(2000);
|
||||
assertThat(((CouchbaseCache) cache).getNativeCache()).isEqualTo(this.context.getBean("bucket"));
|
||||
assertThat(((CouchbaseCache) cache).getNativeCache())
|
||||
.isEqualTo(this.context.getBean("bucket"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -789,7 +795,8 @@ public class CacheAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import({ CouchbaseCacheConfiguration.class, CacheManagerCustomizersConfiguration.class })
|
||||
@Import({ CouchbaseCacheConfiguration.class,
|
||||
CacheManagerCustomizersConfiguration.class })
|
||||
static class CouchbaseCacheAndCustomizersConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
/**
|
||||
* Base class for {@link CouchbaseAutoConfiguration} tests.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public abstract class AbstractCouchbaseAutoConfigurationTests {
|
||||
|
||||
@@ -59,7 +59,6 @@ public class CouchbaseAutoConfigurationIntegrationTests
|
||||
assertThat(this.context.getBeansOfType(Bucket.class)).hasSize(2);
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
static class CustomConfiguration {
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Eddú Meléndez
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class CouchbaseAutoConfigurationTests extends AbstractCouchbaseAutoConfigurationTests {
|
||||
public class CouchbaseAutoConfigurationTests
|
||||
extends AbstractCouchbaseAutoConfigurationTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
@@ -47,8 +48,7 @@ public class CouchbaseAutoConfigurationTests extends AbstractCouchbaseAutoConfig
|
||||
@Test
|
||||
public void bootstrapHostsNotRequiredIfCouchbaseConfigurerIsSet() {
|
||||
load(CouchbaseTestConfigurer.class);
|
||||
assertThat(this.context.getBeansOfType(CouchbaseTestConfigurer.class))
|
||||
.hasSize(1);
|
||||
assertThat(this.context.getBeansOfType(CouchbaseTestConfigurer.class)).hasSize(1);
|
||||
// No beans are going to be created
|
||||
assertNoCouchbaseBeans();
|
||||
}
|
||||
@@ -56,8 +56,7 @@ public class CouchbaseAutoConfigurationTests extends AbstractCouchbaseAutoConfig
|
||||
@Test
|
||||
public void bootstrapHostsIgnoredIfCouchbaseConfigurerIsSet() {
|
||||
load(CouchbaseTestConfigurer.class, "spring.couchbase.bootstrapHosts=localhost");
|
||||
assertThat(this.context.getBeansOfType(CouchbaseTestConfigurer.class))
|
||||
.hasSize(1);
|
||||
assertThat(this.context.getBeansOfType(CouchbaseTestConfigurer.class)).hasSize(1);
|
||||
assertNoCouchbaseBeans();
|
||||
}
|
||||
|
||||
@@ -114,11 +113,12 @@ public class CouchbaseAutoConfigurationTests extends AbstractCouchbaseAutoConfig
|
||||
assertThat(env.sslKeystorePassword()).isNull();
|
||||
}
|
||||
|
||||
private DefaultCouchbaseEnvironment customizeEnv(String... environment) throws Exception {
|
||||
private DefaultCouchbaseEnvironment customizeEnv(String... environment)
|
||||
throws Exception {
|
||||
load(CouchbaseTestConfigurer.class, environment);
|
||||
CouchbaseProperties properties = this.context.getBean(CouchbaseProperties.class);
|
||||
return (DefaultCouchbaseEnvironment) new CouchbaseAutoConfiguration.CouchbaseConfiguration(properties)
|
||||
.couchbaseEnvironment();
|
||||
return (DefaultCouchbaseEnvironment) new CouchbaseAutoConfiguration.CouchbaseConfiguration(
|
||||
properties).couchbaseEnvironment();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ import com.couchbase.client.java.env.CouchbaseEnvironment;
|
||||
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Assume;
|
||||
import org.junit.AssumptionViolatedException;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
/**
|
||||
* {@link TestRule} for working with an optional Couchbase server. Expects
|
||||
* a default {@link Bucket} with no password to be available on localhost.
|
||||
* {@link TestRule} for working with an optional Couchbase server. Expects a default
|
||||
* {@link Bucket} with no password to be available on localhost.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@@ -40,19 +40,20 @@ public class CouchbaseTestServer implements TestRule {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(CouchbaseTestServer.class);
|
||||
|
||||
private CouchbaseEnvironment env;
|
||||
private CouchbaseEnvironment environment;
|
||||
|
||||
private Cluster cluster;
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, Description description) {
|
||||
try {
|
||||
this.env = DefaultCouchbaseEnvironment.create();
|
||||
this.cluster = CouchbaseCluster.create(this.env, "localhost");
|
||||
this.environment = DefaultCouchbaseEnvironment.create();
|
||||
this.cluster = CouchbaseCluster.create(this.environment,
|
||||
"localhost");
|
||||
testConnection(this.cluster);
|
||||
return new CouchbaseStatement(base, this.env, this.cluster);
|
||||
return new CouchbaseStatement(base, this.environment, this.cluster);
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
logger.info("No couchbase server available");
|
||||
return new SkipStatement();
|
||||
}
|
||||
@@ -64,10 +65,10 @@ public class CouchbaseTestServer implements TestRule {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the couchbase env if any
|
||||
* @return the Couchbase environment if any
|
||||
*/
|
||||
public CouchbaseEnvironment getEnv() {
|
||||
return this.env;
|
||||
public CouchbaseEnvironment getCouchbaseEnvironment() {
|
||||
return this.environment;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,16 +78,18 @@ public class CouchbaseTestServer implements TestRule {
|
||||
return this.cluster;
|
||||
}
|
||||
|
||||
|
||||
private static class CouchbaseStatement extends Statement {
|
||||
|
||||
private final Statement base;
|
||||
private final CouchbaseEnvironment env;
|
||||
|
||||
private final CouchbaseEnvironment environment;
|
||||
|
||||
private final Cluster cluster;
|
||||
|
||||
CouchbaseStatement(Statement base, CouchbaseEnvironment env, Cluster cluster) {
|
||||
CouchbaseStatement(Statement base, CouchbaseEnvironment environment,
|
||||
Cluster cluster) {
|
||||
this.base = base;
|
||||
this.env = env;
|
||||
this.environment = environment;
|
||||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
@@ -98,10 +101,11 @@ public class CouchbaseTestServer implements TestRule {
|
||||
finally {
|
||||
try {
|
||||
this.cluster.disconnect();
|
||||
this.env.shutdownAsync();
|
||||
this.environment.shutdownAsync();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
logger.warn("Exception while trying to cleanup couchbase resource", ex);
|
||||
logger.warn("Exception while trying to cleanup couchbase resource",
|
||||
ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,8 +115,8 @@ public class CouchbaseTestServer implements TestRule {
|
||||
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
Assume.assumeTrue("Skipping test due to Couchbase "
|
||||
+ "not being available", false);
|
||||
throw new AssumptionViolatedException(
|
||||
"Skipping test due to Couchbase not being available");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,14 +65,15 @@ public class CouchbaseDataAutoConfigurationTests {
|
||||
@Test
|
||||
public void customConfiguration() {
|
||||
load(CustomCouchbaseConfiguration.class);
|
||||
CouchbaseTemplate couchbaseTemplate = this.context.getBean(CouchbaseTemplate.class);
|
||||
assertThat(couchbaseTemplate.getDefaultConsistency()).isEqualTo(Consistency.STRONGLY_CONSISTENT);
|
||||
CouchbaseTemplate couchbaseTemplate = this.context
|
||||
.getBean(CouchbaseTemplate.class);
|
||||
assertThat(couchbaseTemplate.getDefaultConsistency())
|
||||
.isEqualTo(Consistency.STRONGLY_CONSISTENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validatorIsPresent() {
|
||||
load(ValidatorConfiguration.class);
|
||||
|
||||
ValidatingCouchbaseEventListener listener = this.context
|
||||
.getBean(ValidatingCouchbaseEventListener.class);
|
||||
assertThat(new DirectFieldAccessor(listener).getPropertyValue("validator"))
|
||||
@@ -90,8 +91,7 @@ public class CouchbaseDataAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void enableAutoIndex() {
|
||||
load(CouchbaseTestConfigurer.class,
|
||||
"spring.data.couchbase.auto-index=true");
|
||||
load(CouchbaseTestConfigurer.class, "spring.data.couchbase.auto-index=true");
|
||||
IndexManager indexManager = this.context.getBean(IndexManager.class);
|
||||
assertThat(indexManager.isIgnoreViews()).isFalse();
|
||||
assertThat(indexManager.isIgnoreN1qlPrimary()).isFalse();
|
||||
@@ -115,13 +115,11 @@ public class CouchbaseDataAutoConfigurationTests {
|
||||
context.register(config);
|
||||
}
|
||||
context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
CouchbaseAutoConfiguration.class,
|
||||
CouchbaseDataAutoConfiguration.class);
|
||||
CouchbaseAutoConfiguration.class, CouchbaseDataAutoConfiguration.class);
|
||||
context.refresh();
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@Import(CouchbaseTestConfigurer.class)
|
||||
static class ValidatorConfiguration {
|
||||
@@ -145,6 +143,7 @@ public class CouchbaseDataAutoConfigurationTests {
|
||||
protected Consistency getDefaultConsistency() {
|
||||
return Consistency.STRONGLY_CONSISTENT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -82,8 +82,7 @@ public class CouchbaseRepositoriesAutoConfigurationTests {
|
||||
context.register(config);
|
||||
}
|
||||
context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
CouchbaseAutoConfiguration.class,
|
||||
CouchbaseDataAutoConfiguration.class,
|
||||
CouchbaseAutoConfiguration.class, CouchbaseDataAutoConfiguration.class,
|
||||
CouchbaseRepositoriesAutoConfiguration.class);
|
||||
context.refresh();
|
||||
this.context = context;
|
||||
|
||||
@@ -43,8 +43,7 @@ public class RedisRepositoriesAutoConfigurationTests {
|
||||
@Rule
|
||||
public RedisTestServer redis = new RedisTestServer();
|
||||
|
||||
private AnnotationConfigApplicationContext context
|
||||
= new AnnotationConfigApplicationContext();
|
||||
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
|
||||
@After
|
||||
public void close() {
|
||||
@@ -53,8 +52,8 @@ public class RedisRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultRepositoryConfiguration() {
|
||||
this.context.register(TestConfiguration.class,
|
||||
RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class,
|
||||
this.context.register(TestConfiguration.class, RedisAutoConfiguration.class,
|
||||
RedisRepositoriesAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
|
||||
@@ -62,8 +61,7 @@ public class RedisRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testNoRepositoryConfiguration() {
|
||||
this.context.register(EmptyConfiguration.class,
|
||||
RedisAutoConfiguration.class,
|
||||
this.context.register(EmptyConfiguration.class, RedisAutoConfiguration.class,
|
||||
RedisRepositoriesAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -72,8 +70,7 @@ public class RedisRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
|
||||
this.context.register(CustomizedConfiguration.class,
|
||||
RedisAutoConfiguration.class,
|
||||
this.context.register(CustomizedConfiguration.class, RedisAutoConfiguration.class,
|
||||
RedisRepositoriesAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
||||
@@ -70,12 +70,12 @@ public class H2ConsoleAutoConfigurationTests {
|
||||
"spring.h2.console.enabled:true");
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
|
||||
assertThat(this.context.getBean(ServletRegistrationBean.class).getUrlMappings())
|
||||
.contains("/h2-console/*");
|
||||
assertThat(this.context.getBean(ServletRegistrationBean.class).getInitParameters()).
|
||||
doesNotContainKey("trace");
|
||||
assertThat(this.context.getBean(ServletRegistrationBean.class).getInitParameters()).
|
||||
doesNotContainKey("webAllowOthers");
|
||||
ServletRegistrationBean registrationBean = this.context
|
||||
.getBean(ServletRegistrationBean.class);
|
||||
assertThat(registrationBean.getUrlMappings()).contains("/h2-console/*");
|
||||
assertThat(registrationBean.getInitParameters()).doesNotContainKey("trace");
|
||||
assertThat(registrationBean.getInitParameters())
|
||||
.doesNotContainKey("webAllowOthers");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -114,17 +114,16 @@ public class H2ConsoleAutoConfigurationTests {
|
||||
public void customInitParameters() {
|
||||
this.context.register(H2ConsoleAutoConfiguration.class);
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.h2.console.enabled:true",
|
||||
"spring.h2.console.settings.trace=true",
|
||||
"spring.h2.console.enabled:true", "spring.h2.console.settings.trace=true",
|
||||
"spring.h2.console.settings.webAllowOthers=true");
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
|
||||
assertThat(this.context.getBean(ServletRegistrationBean.class).getUrlMappings())
|
||||
.contains("/h2-console/*");
|
||||
assertThat(this.context.getBean(ServletRegistrationBean.class).getInitParameters()).
|
||||
containsEntry("trace", "");
|
||||
assertThat(this.context.getBean(ServletRegistrationBean.class).getInitParameters()).
|
||||
containsEntry("webAllowOthers", "");
|
||||
ServletRegistrationBean registrationBean = this.context
|
||||
.getBean(ServletRegistrationBean.class);
|
||||
assertThat(registrationBean.getUrlMappings()).contains("/h2-console/*");
|
||||
assertThat(registrationBean.getInitParameters()).containsEntry("trace", "");
|
||||
assertThat(registrationBean.getInitParameters()).containsEntry("webAllowOthers",
|
||||
"");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,8 @@ public class ProjectInfoAutoConfigurationTests {
|
||||
@Test
|
||||
public void gitPropertiesUnavailableIfResourceNotAvailable() {
|
||||
load();
|
||||
Map<String, GitProperties> beans = this.context.getBeansOfType(GitProperties.class);
|
||||
Map<String, GitProperties> beans = this.context
|
||||
.getBeansOfType(GitProperties.class);
|
||||
assertThat(beans).hasSize(0);
|
||||
}
|
||||
|
||||
@@ -61,7 +62,8 @@ public class ProjectInfoAutoConfigurationTests {
|
||||
"spring.git.properties=classpath:/org/springframework/boot/autoconfigure/info/git-no-data.properties");
|
||||
GitProperties gitProperties = this.context.getBean(GitProperties.class);
|
||||
assertThat(gitProperties.getBranch()).isNull();
|
||||
assertThat(gitProperties.getCommitId()).isEqualTo("f95038ec09e29d8f91982fd1cbcc0f3b131b1d0a");
|
||||
assertThat(gitProperties.getCommitId())
|
||||
.isEqualTo("f95038ec09e29d8f91982fd1cbcc0f3b131b1d0a");
|
||||
assertThat(gitProperties.getCommitTime().getTime()).isEqualTo(1456995720000L);
|
||||
}
|
||||
|
||||
@@ -70,7 +72,8 @@ public class ProjectInfoAutoConfigurationTests {
|
||||
load("spring.git.properties=classpath:/org/springframework/boot/autoconfigure/info/git-epoch.properties");
|
||||
GitProperties gitProperties = this.context.getBean(GitProperties.class);
|
||||
assertThat(gitProperties.getBranch()).isEqualTo("master");
|
||||
assertThat(gitProperties.getCommitId()).isEqualTo("5009933788f5f8c687719de6a697074ff80b1b69");
|
||||
assertThat(gitProperties.getCommitId())
|
||||
.isEqualTo("5009933788f5f8c687719de6a697074ff80b1b69");
|
||||
assertThat(gitProperties.getCommitTime().getTime()).isEqualTo(1457103850000L);
|
||||
}
|
||||
|
||||
@@ -114,7 +117,8 @@ public class ProjectInfoAutoConfigurationTests {
|
||||
@Test
|
||||
public void buildPropertiesCustomInvalidLocation() {
|
||||
load("spring.info.build.location=classpath:/org/acme/no-build.properties");
|
||||
Map<String, BuildProperties> beans = this.context.getBeansOfType(BuildProperties.class);
|
||||
Map<String, BuildProperties> beans = this.context
|
||||
.getBeansOfType(BuildProperties.class);
|
||||
assertThat(beans).hasSize(0);
|
||||
}
|
||||
|
||||
@@ -122,7 +126,8 @@ public class ProjectInfoAutoConfigurationTests {
|
||||
public void buildPropertiesFallbackWithBuildInfoBean() {
|
||||
load(CustomInfoPropertiesConfiguration.class);
|
||||
BuildProperties buildProperties = this.context.getBean(BuildProperties.class);
|
||||
assertThat(buildProperties).isSameAs(this.context.getBean("customBuildProperties"));
|
||||
assertThat(buildProperties)
|
||||
.isSameAs(this.context.getBean("customBuildProperties"));
|
||||
}
|
||||
|
||||
private void load(String... environment) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import javax.jms.JMSException;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.pool.PooledConnectionFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration;
|
||||
@@ -64,21 +63,22 @@ public class ActiveMQAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void customPooledConnectionFactoryConfiguration() {
|
||||
load(EmptyConfiguration.class,
|
||||
"spring.activemq.pool.enabled:true",
|
||||
"spring.activemq.pool.maxConnections:256",
|
||||
"spring.activemq.pool.idleTimeout:512",
|
||||
"spring.activemq.pool.expiryTimeout:4096",
|
||||
"spring.activemq.pool.configuration.maximumActiveSessionPerConnection:1024",
|
||||
"spring.activemq.pool.configuration.timeBetweenExpirationCheckMillis:2048");
|
||||
ConnectionFactory connectionFactory = this.context.getBean(ConnectionFactory.class);
|
||||
load(EmptyConfiguration.class, "spring.activemq.pool.enabled:true",
|
||||
"spring.activemq.pool.maxConnections:256",
|
||||
"spring.activemq.pool.idleTimeout:512",
|
||||
"spring.activemq.pool.expiryTimeout:4096",
|
||||
"spring.activemq.pool.configuration.maximumActiveSessionPerConnection:1024",
|
||||
"spring.activemq.pool.configuration.timeBetweenExpirationCheckMillis:2048");
|
||||
ConnectionFactory connectionFactory = this.context
|
||||
.getBean(ConnectionFactory.class);
|
||||
assertThat(connectionFactory).isInstanceOf(PooledConnectionFactory.class);
|
||||
|
||||
PooledConnectionFactory pooledConnectionFactory = (PooledConnectionFactory) connectionFactory;
|
||||
assertThat(pooledConnectionFactory.getMaxConnections()).isEqualTo(256);
|
||||
assertThat(pooledConnectionFactory.getIdleTimeout()).isEqualTo(512);
|
||||
assertThat(pooledConnectionFactory.getMaximumActiveSessionPerConnection()).isEqualTo(1024);
|
||||
assertThat(pooledConnectionFactory.getTimeBetweenExpirationCheckMillis()).isEqualTo(2048);
|
||||
assertThat(pooledConnectionFactory.getMaximumActiveSessionPerConnection())
|
||||
.isEqualTo(1024);
|
||||
assertThat(pooledConnectionFactory.getTimeBetweenExpirationCheckMillis())
|
||||
.isEqualTo(2048);
|
||||
assertThat(pooledConnectionFactory.getExpiryTimeout()).isEqualTo(4096);
|
||||
}
|
||||
|
||||
@@ -119,6 +119,7 @@ public class ActiveMQAutoConfigurationTests {
|
||||
public ConnectionFactory connectionFactory() {
|
||||
return mock(ConnectionFactory.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.junit.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ActiveMQProperties} and ActiveMQConnectionFactoryFactory.
|
||||
* Tests for {@link ActiveMQProperties} and {@link ActiveMQConnectionFactoryFactory}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Aurélien Leboulanger
|
||||
|
||||
Reference in New Issue
Block a user