Polish
This commit is contained in:
@@ -140,16 +140,20 @@ public class RabbitAutoConfiguration {
|
||||
factory.getObject());
|
||||
connectionFactory.setAddresses(config.getAddresses());
|
||||
if (config.getCache().getChannel().getSize() != null) {
|
||||
connectionFactory.setChannelCacheSize(config.getCache().getChannel().getSize());
|
||||
connectionFactory
|
||||
.setChannelCacheSize(config.getCache().getChannel().getSize());
|
||||
}
|
||||
if (config.getCache().getConnection().getMode() != null) {
|
||||
connectionFactory.setCacheMode(config.getCache().getConnection().getMode());
|
||||
connectionFactory
|
||||
.setCacheMode(config.getCache().getConnection().getMode());
|
||||
}
|
||||
if (config.getCache().getConnection().getSize() != null) {
|
||||
connectionFactory.setConnectionCacheSize(config.getCache().getConnection().getSize());
|
||||
connectionFactory.setConnectionCacheSize(
|
||||
config.getCache().getConnection().getSize());
|
||||
}
|
||||
if (config.getCache().getChannel().getCheckoutTimeout() != null) {
|
||||
connectionFactory.setChannelCheckoutTimeout(config.getCache().getChannel().getCheckoutTimeout());
|
||||
connectionFactory.setChannelCheckoutTimeout(
|
||||
config.getCache().getChannel().getCheckoutTimeout());
|
||||
}
|
||||
return connectionFactory;
|
||||
}
|
||||
|
||||
@@ -287,14 +287,14 @@ public class RabbitProperties {
|
||||
public static class Channel {
|
||||
|
||||
/**
|
||||
* Number of channels to retain in the cache. When "check-timeout" > 0, max
|
||||
* Number of channels to retain in the cache. When "check-timeout" > 0, max
|
||||
* channels per connection.
|
||||
*/
|
||||
private Integer size;
|
||||
|
||||
/**
|
||||
* Number of milliseconds to wait to obtain a channel if the cache size
|
||||
* has been reached. If 0, always create a new channel.
|
||||
* Number of milliseconds to wait to obtain a channel if the cache size has
|
||||
* been reached. If 0, always create a new channel.
|
||||
*/
|
||||
private Long checkoutTimeout;
|
||||
|
||||
|
||||
@@ -118,8 +118,8 @@ public class CacheProperties {
|
||||
public static class Caffeine {
|
||||
|
||||
/**
|
||||
* The spec to use to create caches. Check CaffeineSpec for more details on
|
||||
* the spec format.
|
||||
* The spec to use to create caches. Check CaffeineSpec for more details on the
|
||||
* spec format.
|
||||
*/
|
||||
private String spec;
|
||||
|
||||
|
||||
@@ -48,8 +48,11 @@ public class GitInfo {
|
||||
private String time;
|
||||
|
||||
public String getId() {
|
||||
return this.id == null ? ""
|
||||
: (this.id.length() > 7 ? this.id.substring(0, 7) : this.id);
|
||||
return (this.id == null ? "" : getShortId(this.id));
|
||||
}
|
||||
|
||||
private String getShortId(String string) {
|
||||
return string.substring(0, Math.min(this.id.length(), 7));
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
|
||||
@@ -63,17 +63,18 @@ public class ProjectInfoAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
|
||||
static class GitResourceAvailableCondition extends SpringBootCondition {
|
||||
|
||||
private final ResourceLoader defaultResourceLoader = new DefaultResourceLoader();
|
||||
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
ResourceLoader loader = context.getResourceLoader() == null
|
||||
? this.defaultResourceLoader : context.getResourceLoader();
|
||||
PropertyResolver propertyResolver = context.getEnvironment();
|
||||
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(propertyResolver, "spring.info.git.");
|
||||
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
|
||||
propertyResolver, "spring.info.git.");
|
||||
String location = resolver.getProperty("location");
|
||||
if (location == null) {
|
||||
resolver = new RelaxedPropertyResolver(propertyResolver, "spring.git.");
|
||||
@@ -83,8 +84,10 @@ public class ProjectInfoAutoConfiguration {
|
||||
}
|
||||
}
|
||||
boolean match = loader.getResource(location).exists();
|
||||
return new ConditionOutcome(match, "Git info " + (match ? "found" : "not found") + " at " + location);
|
||||
return new ConditionOutcome(match,
|
||||
"Git info " + (match ? "found" : "not found") + " at " + location);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,17 +36,16 @@ public class ProjectInfoProperties {
|
||||
return this.git;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make sure that the "spring.git.properties" legacy key is used by default.
|
||||
* @param defaultGitLocation the default git location to use
|
||||
*/
|
||||
@Autowired
|
||||
void setDefaultGitLocation(@Value("${spring.git.properties:classpath:git.properties}") Resource defaultGitLocation) {
|
||||
void setDefaultGitLocation(
|
||||
@Value("${spring.git.properties:classpath:git.properties}") Resource defaultGitLocation) {
|
||||
getGit().setLocation(defaultGitLocation);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Git specific info properties.
|
||||
*/
|
||||
|
||||
@@ -134,10 +134,9 @@ public class RabbitAutoConfigurationTests {
|
||||
@Test
|
||||
public void testRabbitTemplateMessageConverters() {
|
||||
load(MessageConvertersConfiguration.class);
|
||||
RabbitTemplate rabbitTemplate = this.context
|
||||
.getBean(RabbitTemplate.class);
|
||||
assertThat(rabbitTemplate.getMessageConverter()).isSameAs(
|
||||
this.context.getBean("myMessageConverter"));
|
||||
RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
|
||||
assertThat(rabbitTemplate.getMessageConverter())
|
||||
.isSameAs(this.context.getBean("myMessageConverter"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -233,8 +232,8 @@ public class RabbitAutoConfigurationTests {
|
||||
assertThat(dfa.getPropertyValue("maxConcurrentConsumers")).isEqualTo(10);
|
||||
assertThat(dfa.getPropertyValue("prefetchCount")).isEqualTo(40);
|
||||
assertThat(dfa.getPropertyValue("txSize")).isEqualTo(20);
|
||||
assertThat(dfa.getPropertyValue("messageConverter")).isSameAs(
|
||||
this.context.getBean("myMessageConverter"));
|
||||
assertThat(dfa.getPropertyValue("messageConverter"))
|
||||
.isSameAs(this.context.getBean("myMessageConverter"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -609,7 +609,8 @@ public class CacheAutoConfigurationTests {
|
||||
Cache foo = cacheManager.getCache("foo");
|
||||
foo.get("1");
|
||||
// See next tests: no spec given so stats should be disabled
|
||||
assertThat(((CaffeineCache) foo).getNativeCache().stats().missCount()).isEqualTo(0L);
|
||||
assertThat(((CaffeineCache) foo).getNativeCache().stats().missCount())
|
||||
.isEqualTo(0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -635,17 +636,19 @@ public class CacheAutoConfigurationTests {
|
||||
@Test
|
||||
public void caffeineCacheExplicitWithSpecString() {
|
||||
load(DefaultCacheConfiguration.class, "spring.cache.type=caffeine",
|
||||
"spring.cache.caffeine.spec=recordStats", "spring.cache.cacheNames[0]=foo",
|
||||
"spring.cache.cacheNames[1]=bar");
|
||||
"spring.cache.caffeine.spec=recordStats",
|
||||
"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
|
||||
validateCaffeineCacheWithStats();
|
||||
}
|
||||
|
||||
private void validateCaffeineCacheWithStats() {
|
||||
CaffeineCacheManager cacheManager = validateCacheManager(CaffeineCacheManager.class);
|
||||
CaffeineCacheManager cacheManager = validateCacheManager(
|
||||
CaffeineCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
|
||||
Cache foo = cacheManager.getCache("foo");
|
||||
foo.get("1");
|
||||
assertThat(((CaffeineCache) foo).getNativeCache().stats().missCount()).isEqualTo(1L);
|
||||
assertThat(((CaffeineCache) foo).getNativeCache().stats().missCount())
|
||||
.isEqualTo(1L);
|
||||
}
|
||||
|
||||
private <T extends CacheManager> T validateCacheManager(Class<T> type) {
|
||||
@@ -866,7 +869,8 @@ public class CacheAutoConfigurationTests {
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
static class CustomCacheResolverFromSupportConfiguration extends CachingConfigurerSupport {
|
||||
static class CustomCacheResolverFromSupportConfiguration
|
||||
extends CachingConfigurerSupport {
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
|
||||
@@ -36,7 +36,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
public class ProjectInfoAutoConfigurationTests {
|
||||
|
||||
|
||||
private AnnotationConfigApplicationContext context;
|
||||
|
||||
@After
|
||||
@@ -49,8 +48,7 @@ public class ProjectInfoAutoConfigurationTests {
|
||||
@Test
|
||||
public void gitInfoUnavailableIfResourceNotAvailable() {
|
||||
load();
|
||||
Map<String, GitInfo> beans = this.context
|
||||
.getBeansOfType(GitInfo.class);
|
||||
Map<String, GitInfo> beans = this.context.getBeansOfType(GitInfo.class);
|
||||
assertThat(beans).hasSize(0);
|
||||
}
|
||||
|
||||
@@ -113,5 +111,7 @@ public class ProjectInfoAutoConfigurationTests {
|
||||
public GitInfo customGitInfo() {
|
||||
return new GitInfo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -235,13 +235,12 @@ public class JmsAutoConfigurationTests {
|
||||
assertThat(listenerContainer.isAutoStartup()).isFalse();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testJmsTemplateWithMessageConverters() {
|
||||
load(MessageConvertersConfiguration.class);
|
||||
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
|
||||
assertThat(jmsTemplate.getMessageConverter()).isSameAs(
|
||||
this.context.getBean("myMessageConverter"));
|
||||
assertThat(jmsTemplate.getMessageConverter())
|
||||
.isSameAs(this.context.getBean("myMessageConverter"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user