Reformat code use Eclipse Mars

pull/4212/head
Phillip Webb 9 years ago
parent ba7c1fda72
commit 6ab376e2e8

@ -135,8 +135,8 @@ public class AuditEvent implements Serializable {
@Override
public String toString() {
return "AuditEvent [timestamp=" + this.timestamp + ", principal="
+ this.principal + ", type=" + this.type + ", data=" + this.data + "]";
return "AuditEvent [timestamp=" + this.timestamp + ", principal=" + this.principal
+ ", type=" + this.type + ", data=" + this.data + "]";
}
}

@ -40,7 +40,8 @@ public class AuditApplicationEvent extends ApplicationEvent {
* @param data the event data
* @see AuditEvent#AuditEvent(String, String, Map)
*/
public AuditApplicationEvent(String principal, String type, Map<String, Object> data) {
public AuditApplicationEvent(String principal, String type,
Map<String, Object> data) {
this(new AuditEvent(principal, type, data));
}

@ -104,11 +104,11 @@ import org.springframework.util.StringUtils;
* infrastructure add beans of type {@link CrshShellProperties} to the application
* context.
* <p>
* Additional shell commands can be implemented using the guide and documentation at <a
* href="http://www.crashub.org">crashub.org</a>. By default Boot will search for commands
* using the following classpath scanning pattern <code>classpath*:/commands/**</code>. To
* add different locations or override the default use
* <code>shell.command_path_patterns</code> in your application configuration.
* Additional shell commands can be implemented using the guide and documentation at
* <a href="http://www.crashub.org">crashub.org</a>. By default Boot will search for
* commands using the following classpath scanning pattern
* <code>classpath*:/commands/**</code>. To add different locations or override the
* default use <code>shell.command_path_patterns</code> in your application configuration.
*
* @author Christian Dupuis
* @see ShellProperties
@ -180,8 +180,8 @@ public class CrshAutoConfiguration {
// ConfigurationProperties.
SpringAuthenticationProperties authenticationProperties = new SpringAuthenticationProperties();
if (this.management != null) {
authenticationProperties.setRoles(new String[] { this.management
.getSecurity().getRole() });
authenticationProperties.setRoles(
new String[] { this.management.getSecurity().getRole() });
}
return authenticationProperties;
}
@ -240,8 +240,8 @@ public class CrshAutoConfiguration {
pathPattern, this.resourceLoader, filterPatterns)));
}
catch (IOException ex) {
throw new IllegalStateException("Failed to mount file system for '"
+ pathPattern + "'", ex);
throw new IllegalStateException(
"Failed to mount file system for '" + pathPattern + "'", ex);
}
}
return fileSystem;
@ -273,9 +273,9 @@ public class CrshAutoConfiguration {
private static class AuthenticationManagerAdapter extends
CRaSHPlugin<AuthenticationPlugin> implements AuthenticationPlugin<String> {
private static final PropertyDescriptor<String> ROLES = PropertyDescriptor
.create("auth.spring.roles", "ADMIN",
"Comma separated list of roles required to access the shell");
private static final PropertyDescriptor<String> ROLES = PropertyDescriptor.create(
"auth.spring.roles", "ADMIN",
"Comma separated list of roles required to access the shell");
@Autowired
private AuthenticationManager authenticationManager;
@ -347,8 +347,8 @@ public class CrshAutoConfiguration {
* {@link ServiceLoaderDiscovery} to expose {@link CRaSHPlugin} Beans from Spring and
* deal with filtering disabled plugins.
*/
private static class BeanFactoryFilteringPluginDiscovery extends
ServiceLoaderDiscovery {
private static class BeanFactoryFilteringPluginDiscovery
extends ServiceLoaderDiscovery {
private final ListableBeanFactory beanFactory;
@ -356,7 +356,7 @@ public class CrshAutoConfiguration {
public BeanFactoryFilteringPluginDiscovery(ClassLoader classLoader,
ListableBeanFactory beanFactory, String[] disabledPlugins)
throws NullPointerException {
throws NullPointerException {
super(classLoader);
this.beanFactory = beanFactory;
this.disabledPlugins = disabledPlugins;
@ -373,8 +373,8 @@ public class CrshAutoConfiguration {
}
}
Collection<CRaSHPlugin> pluginBeans = this.beanFactory.getBeansOfType(
CRaSHPlugin.class).values();
Collection<CRaSHPlugin> pluginBeans = this.beanFactory
.getBeansOfType(CRaSHPlugin.class).values();
for (CRaSHPlugin<?> pluginBean : pluginBeans) {
if (isEnabled(pluginBean)) {
plugins.add(pluginBean);
@ -405,8 +405,8 @@ public class CrshAutoConfiguration {
private boolean isEnabled(Class<?> pluginClass) {
for (String disabledPlugin : this.disabledPlugins) {
if (ClassUtils.getShortName(pluginClass).equalsIgnoreCase(disabledPlugin)
|| ClassUtils.getQualifiedName(pluginClass).equalsIgnoreCase(
disabledPlugin)) {
|| ClassUtils.getQualifiedName(pluginClass)
.equalsIgnoreCase(disabledPlugin)) {
return false;
}
}
@ -507,7 +507,8 @@ public class CrshAutoConfiguration {
Resource[] resources = this.resourceLoader.getResources(getName());
List<ResourceHandle> files = new ArrayList<ResourceHandle>();
for (Resource resource : resources) {
if (!resource.getURL().getPath().endsWith("/") && !shouldFilter(resource)) {
if (!resource.getURL().getPath().endsWith("/")
&& !shouldFilter(resource)) {
files.add(new FileHandle(resource.getFilename(), resource));
}
}

@ -234,8 +234,8 @@ public class EndpointAutoConfiguration {
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 ? ""
: (this.id.length() > 7 ? this.id.substring(0, 7) : this.id);
}
public void setId(String id) {

@ -74,12 +74,13 @@ public class EndpointMBeanExportAutoConfiguration {
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
String endpointEnabled = context.getEnvironment().getProperty(
"endpoints.jmx.enabled", "true");
String jmxEnabled = context.getEnvironment().getProperty(
"spring.jmx.enabled", "true");
return new ConditionOutcome("true".equalsIgnoreCase(endpointEnabled)
&& "true".equalsIgnoreCase(jmxEnabled),
String endpointEnabled = context.getEnvironment()
.getProperty("endpoints.jmx.enabled", "true");
String jmxEnabled = context.getEnvironment().getProperty("spring.jmx.enabled",
"true");
return new ConditionOutcome(
"true".equalsIgnoreCase(endpointEnabled)
&& "true".equalsIgnoreCase(jmxEnabled),
"JMX endpoint and JMX enabled");
}

@ -94,8 +94,8 @@ import org.springframework.web.servlet.DispatcherServlet;
EmbeddedServletContainerAutoConfiguration.class, WebMvcAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class })
@EnableConfigurationProperties(HealthMvcEndpointProperties.class)
public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
SmartInitializingSingleton {
public class EndpointWebMvcAutoConfiguration
implements ApplicationContextAware, SmartInitializingSingleton {
private static Log logger = LogFactory.getLog(EndpointWebMvcAutoConfiguration.class);
@ -119,9 +119,10 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
@Bean
@ConditionalOnMissingBean
public EndpointHandlerMapping endpointHandlerMapping() {
EndpointHandlerMapping mapping = new EndpointHandlerMapping(mvcEndpoints()
.getEndpoints());
boolean disabled = ManagementServerPort.get(this.applicationContext) != ManagementServerPort.SAME;
EndpointHandlerMapping mapping = new EndpointHandlerMapping(
mvcEndpoints().getEndpoints());
boolean disabled = ManagementServerPort
.get(this.applicationContext) != ManagementServerPort.SAME;
mapping.setDisabled(disabled);
if (!disabled) {
mapping.setPrefix(this.managementServerProperties.getContextPath());
@ -144,10 +145,10 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
.getEmbeddedServletContainer() != null) {
createChildManagementContext();
}
if (managementPort == ManagementServerPort.SAME
&& this.applicationContext.getEnvironment() instanceof ConfigurableEnvironment) {
addLocalManagementPortPropertyAlias((ConfigurableEnvironment) this.applicationContext
.getEnvironment());
if (managementPort == ManagementServerPort.SAME && this.applicationContext
.getEnvironment() instanceof ConfigurableEnvironment) {
addLocalManagementPortPropertyAlias(
(ConfigurableEnvironment) this.applicationContext.getEnvironment());
}
}
@ -172,8 +173,8 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
boolean secure = (security == null || security.isEnabled());
HealthMvcEndpoint healthMvcEndpoint = new HealthMvcEndpoint(delegate, secure);
if (this.healthMvcEndpointProperties.getMapping() != null) {
healthMvcEndpoint.addStatusMapping(this.healthMvcEndpointProperties
.getMapping());
healthMvcEndpoint
.addStatusMapping(this.healthMvcEndpointProperties.getMapping());
}
return healthMvcEndpoint;
}
@ -210,14 +211,16 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
// Ensure close on the parent also closes the child
if (this.applicationContext instanceof ConfigurableApplicationContext) {
((ConfigurableApplicationContext) this.applicationContext)
.addApplicationListener(new ApplicationListener<ContextClosedEvent>() {
@Override
public void onApplicationEvent(ContextClosedEvent event) {
if (event.getApplicationContext() == EndpointWebMvcAutoConfiguration.this.applicationContext) {
childContext.close();
}
}
});
.addApplicationListener(
new ApplicationListener<ContextClosedEvent>() {
@Override
public void onApplicationEvent(ContextClosedEvent event) {
if (event
.getApplicationContext() == EndpointWebMvcAutoConfiguration.this.applicationContext) {
childContext.close();
}
}
});
}
try {
childContext.refresh();
@ -227,7 +230,8 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
// and this is the signature of that happening
if (ex instanceof EmbeddedServletContainerException
|| ex.getCause() instanceof EmbeddedServletContainerException) {
logger.warn("Could not start embedded container (management endpoints are still available through JMX)");
logger.warn(
"Could not start embedded container (management endpoints are still available through JMX)");
}
else {
throw ex;
@ -242,8 +246,8 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
*/
private void addLocalManagementPortPropertyAlias(
final ConfigurableEnvironment environment) {
environment.getPropertySources().addLast(
new PropertySource<Object>("Management Server") {
environment.getPropertySources()
.addLast(new PropertySource<Object>("Management Server") {
@Override
public Object getProperty(String name) {
if ("local.management.port".equals(name)) {
@ -283,7 +287,7 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
throws ServletException, IOException {
if (this.properties == null) {
this.properties = this.applicationContext
.getBean(ManagementServerProperties.class);
@ -328,7 +332,7 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
return ((port == null)
|| (serverProperties.getPort() == null && port.equals(8080))
|| (port != 0 && port.equals(serverProperties.getPort())) ? SAME
: DIFFERENT);
: DIFFERENT);
}
}

@ -79,8 +79,8 @@ public class EndpointWebMvcChildContextConfiguration {
private List<EndpointHandlerMappingCustomizer> mappingCustomizers;
@Configuration
protected static class ServerCustomization implements
EmbeddedServletContainerCustomizer, Ordered {
protected static class ServerCustomization
implements EmbeddedServletContainerCustomizer, Ordered {
@Value("${error.path:/error}")
private String errorPath = "/error";
@ -198,8 +198,8 @@ public class EndpointWebMvcChildContextConfiguration {
*/
@Configuration
@ConditionalOnClass(WebSecurityConfigurerAdapter.class)
protected static class SecureEndpointHandlerMappingConfiguration extends
EndpointHandlerMappingConfiguration {
protected static class SecureEndpointHandlerMappingConfiguration
extends EndpointHandlerMappingConfiguration {
@Override
protected void postProcessMapping(ListableBeanFactory beanFactory,

@ -158,15 +158,16 @@ public class HealthIndicatorAutoConfiguration {
@ConditionalOnMissingBean(name = "mongoHealthIndicator")
public HealthIndicator mongoHealthIndicator() {
if (this.mongoTemplates.size() == 1) {
return new MongoHealthIndicator(this.mongoTemplates.values().iterator()
.next());
return new MongoHealthIndicator(
this.mongoTemplates.values().iterator().next());
}
CompositeHealthIndicator composite = new CompositeHealthIndicator(
this.healthAggregator);
for (Map.Entry<String, MongoTemplate> entry : this.mongoTemplates.entrySet()) {
composite.addHealthIndicator(entry.getKey(), new MongoHealthIndicator(
entry.getValue()));
for (Map.Entry<String, MongoTemplate> entry : this.mongoTemplates
.entrySet()) {
composite.addHealthIndicator(entry.getKey(),
new MongoHealthIndicator(entry.getValue()));
}
return composite;
}
@ -187,16 +188,16 @@ public class HealthIndicatorAutoConfiguration {
@ConditionalOnMissingBean(name = "redisHealthIndicator")
public HealthIndicator redisHealthIndicator() {
if (this.redisConnectionFactories.size() == 1) {
return new RedisHealthIndicator(this.redisConnectionFactories.values()
.iterator().next());
return new RedisHealthIndicator(
this.redisConnectionFactories.values().iterator().next());
}
CompositeHealthIndicator composite = new CompositeHealthIndicator(
this.healthAggregator);
for (Map.Entry<String, RedisConnectionFactory> entry : this.redisConnectionFactories
.entrySet()) {
composite.addHealthIndicator(entry.getKey(), new RedisHealthIndicator(
entry.getValue()));
composite.addHealthIndicator(entry.getKey(),
new RedisHealthIndicator(entry.getValue()));
}
return composite;
}
@ -217,16 +218,16 @@ public class HealthIndicatorAutoConfiguration {
@ConditionalOnMissingBean(name = "rabbitHealthIndicator")
public HealthIndicator rabbitHealthIndicator() {
if (this.rabbitTemplates.size() == 1) {
return new RabbitHealthIndicator(this.rabbitTemplates.values().iterator()
.next());
return new RabbitHealthIndicator(
this.rabbitTemplates.values().iterator().next());
}
CompositeHealthIndicator composite = new CompositeHealthIndicator(
this.healthAggregator);
for (Map.Entry<String, RabbitTemplate> entry : this.rabbitTemplates
.entrySet()) {
composite.addHealthIndicator(entry.getKey(), new RabbitHealthIndicator(
entry.getValue()));
composite.addHealthIndicator(entry.getKey(),
new RabbitHealthIndicator(entry.getValue()));
}
return composite;
}
@ -247,15 +248,15 @@ public class HealthIndicatorAutoConfiguration {
@ConditionalOnMissingBean(name = "solrHealthIndicator")
public HealthIndicator solrHealthIndicator() {
if (this.solrServers.size() == 1) {
return new SolrHealthIndicator(this.solrServers.entrySet().iterator()
.next().getValue());
return new SolrHealthIndicator(
this.solrServers.entrySet().iterator().next().getValue());
}
CompositeHealthIndicator composite = new CompositeHealthIndicator(
this.healthAggregator);
for (Map.Entry<String, SolrServer> entry : this.solrServers.entrySet()) {
composite.addHealthIndicator(entry.getKey(), new SolrHealthIndicator(
entry.getValue()));
composite.addHealthIndicator(entry.getKey(),
new SolrHealthIndicator(entry.getValue()));
}
return composite;
}

@ -44,8 +44,8 @@ import org.springframework.context.annotation.Configuration;
*
* <p>
* Additional configuration parameters for Jolokia can be provided by specifying
* <code>jolokia.config.*</code> properties. See the <a
* href="http://jolokia.org">http://jolokia.org</a> web site for more information on
* <code>jolokia.config.*</code> properties. See the
* <a href="http://jolokia.org">http://jolokia.org</a> web site for more information on
* supported configuration parameters.
*
* @author Christian Dupuis

@ -94,8 +94,8 @@ public class ManagementSecurityAutoConfiguration {
}
@Configuration
protected static class ManagementSecurityPropertiesConfiguration implements
SecurityPrerequisite {
protected static class ManagementSecurityPropertiesConfiguration
implements SecurityPrerequisite {
@Autowired(required = false)
private SecurityProperties security;
@ -115,8 +115,8 @@ public class ManagementSecurityAutoConfiguration {
// Get the ignored paths in early
@Order(SecurityProperties.IGNORED_ORDER + 1)
private static class IgnoredPathsWebSecurityConfigurerAdapter implements
WebSecurityConfigurer<WebSecurity> {
private static class IgnoredPathsWebSecurityConfigurerAdapter
implements WebSecurityConfigurer<WebSecurity> {
@Autowired(required = false)
private ErrorController errorController;
@ -145,8 +145,8 @@ public class ManagementSecurityAutoConfiguration {
List<String> ignored = SpringBootWebSecurityConfiguration
.getIgnored(this.security);
if (!this.management.getSecurity().isEnabled()) {
ignored.addAll(Arrays
.asList(getEndpointPaths(this.endpointHandlerMapping)));
ignored.addAll(
Arrays.asList(getEndpointPaths(this.endpointHandlerMapping)));
}
if (ignored.contains("none")) {
ignored.remove("none");
@ -185,12 +185,13 @@ public class ManagementSecurityAutoConfiguration {
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
String managementEnabled = context.getEnvironment().getProperty(
"management.security.enabled", "true");
String basicEnabled = context.getEnvironment().getProperty(
"security.basic.enabled", "true");
return new ConditionOutcome("true".equalsIgnoreCase(managementEnabled)
&& !"true".equalsIgnoreCase(basicEnabled),
String managementEnabled = context.getEnvironment()
.getProperty("management.security.enabled", "true");
String basicEnabled = context.getEnvironment()
.getProperty("security.basic.enabled", "true");
return new ConditionOutcome(
"true".equalsIgnoreCase(managementEnabled)
&& !"true".equalsIgnoreCase(basicEnabled),
"Management security enabled and basic disabled");
}
@ -200,8 +201,8 @@ public class ManagementSecurityAutoConfiguration {
@ConditionalOnMissingBean({ ManagementWebSecurityConfigurerAdapter.class })
@ConditionalOnProperty(prefix = "management.security", name = "enabled", matchIfMissing = true)
@Order(ManagementServerProperties.BASIC_AUTH_ORDER)
protected static class ManagementWebSecurityConfigurerAdapter extends
WebSecurityConfigurerAdapter {
protected static class ManagementWebSecurityConfigurerAdapter
extends WebSecurityConfigurerAdapter {
@Autowired
private SecurityProperties security;
@ -233,8 +234,8 @@ public class ManagementSecurityAutoConfiguration {
http.exceptionHandling().authenticationEntryPoint(entryPoint);
paths = this.server.getPathsArray(paths);
http.requestMatchers().antMatchers(paths);
String[] endpointPaths = this.server.getPathsArray(getEndpointPaths(
this.endpointHandlerMapping, false));
String[] endpointPaths = this.server.getPathsArray(
getEndpointPaths(this.endpointHandlerMapping, false));
configureAuthorizeRequests(endpointPaths, http.authorizeRequests());
http.httpBasic().authenticationEntryPoint(entryPoint);
// No cookies for management endpoints by default
@ -252,8 +253,7 @@ public class ManagementSecurityAutoConfiguration {
return entryPoint;
}
private void configureAuthorizeRequests(
String[] endpointPaths,
private void configureAuthorizeRequests(String[] endpointPaths,
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry requests) {
requests.antMatchers(endpointPaths).permitAll();
requests.anyRequest().hasRole(this.management.getSecurity().getRole());
@ -261,7 +261,8 @@ public class ManagementSecurityAutoConfiguration {
}
private static String[] getEndpointPaths(EndpointHandlerMapping endpointHandlerMapping) {
private static String[] getEndpointPaths(
EndpointHandlerMapping endpointHandlerMapping) {
return StringUtils.mergeStringArrays(
getEndpointPaths(endpointHandlerMapping, false),
getEndpointPaths(endpointHandlerMapping, true));

@ -53,7 +53,8 @@ public class ManagementServerProperties implements SecurityPrerequisite {
* management endpoints. This is a useful place to put user-defined access rules if
* you want to override the default access rules.
*/
public static final int ACCESS_OVERRIDE_ORDER = ManagementServerProperties.BASIC_AUTH_ORDER - 1;
public static final int ACCESS_OVERRIDE_ORDER = ManagementServerProperties.BASIC_AUTH_ORDER
- 1;
/**
* Management endpoint HTTP port. Use the same port as the applicationby default.

@ -162,7 +162,8 @@ public class MetricRepositoryAutoConfiguration {
}
@Bean
public DropwizardMetricWriter dropwizardMetricWriter(MetricRegistry metricRegistry) {
public DropwizardMetricWriter dropwizardMetricWriter(
MetricRegistry metricRegistry) {
return new DropwizardMetricWriter(metricRegistry);
}

@ -67,8 +67,8 @@ final class MetricsFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain chain) throws ServletException,
IOException {
HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {
StopWatch stopWatch = createStopWatchIfNecessary(request);
String path = new UrlPathHelper().getPathWithinApplication(request);
int status = HttpStatus.INTERNAL_SERVER_ERROR.value();

@ -51,7 +51,8 @@ public class ShellProperties {
private boolean defaultAuth = true;
@Autowired(required = false)
private CrshShellProperties[] additionalProperties = new CrshShellProperties[] { new SimpleAuthenticationProperties() };
private CrshShellProperties[] additionalProperties = new CrshShellProperties[] {
new SimpleAuthenticationProperties() };
/**
* Scan for changes and update the command if necessary (in seconds).
@ -216,8 +217,8 @@ public class ShellProperties {
/**
* Base class for Auth specific properties.
*/
public static abstract class CrshShellAuthenticationProperties extends
CrshShellProperties {
public static abstract class CrshShellAuthenticationProperties
extends CrshShellProperties {
}
@ -326,8 +327,8 @@ public class ShellProperties {
* Auth specific properties for JAAS authentication
*/
@ConfigurationProperties(prefix = "shell.auth.jaas", ignoreUnknownFields = false)
public static class JaasAuthenticationProperties extends
CrshShellAuthenticationProperties {
public static class JaasAuthenticationProperties
extends CrshShellAuthenticationProperties {
/**
* JAAS domain.
@ -355,8 +356,8 @@ public class ShellProperties {
* Auth specific properties for key authentication
*/
@ConfigurationProperties(prefix = "shell.auth.key", ignoreUnknownFields = false)
public static class KeyAuthenticationProperties extends
CrshShellAuthenticationProperties {
public static class KeyAuthenticationProperties
extends CrshShellAuthenticationProperties {
/**
* Path to the authentication key. This should point to a valid ".pem" file.
@ -386,8 +387,8 @@ public class ShellProperties {
* Auth specific properties for simple authentication
*/
@ConfigurationProperties(prefix = "shell.auth.simple", ignoreUnknownFields = false)
public static class SimpleAuthenticationProperties extends
CrshShellAuthenticationProperties {
public static class SimpleAuthenticationProperties
extends CrshShellAuthenticationProperties {
private static Log logger = LogFactory
.getLog(SimpleAuthenticationProperties.class);
@ -461,8 +462,8 @@ public class ShellProperties {
* Auth specific properties for Spring authentication
*/
@ConfigurationProperties(prefix = "shell.auth.spring", ignoreUnknownFields = false)
public static class SpringAuthenticationProperties extends
CrshShellAuthenticationProperties {
public static class SpringAuthenticationProperties
extends CrshShellAuthenticationProperties {
/**
* Comma-separated list of required roles to login to the CRaSH console.

@ -53,8 +53,8 @@ class OnEnabledEndpointCondition extends SpringBootCondition {
if (resolver.containsProperty("enabled") || !enabledByDefault) {
boolean match = resolver.getProperty("enabled", Boolean.class,
enabledByDefault);
return new ConditionOutcome(match, "The " + endpointName + " is "
+ (match ? "enabled" : "disabled"));
return new ConditionOutcome(match,
"The " + endpointName + " is " + (match ? "enabled" : "disabled"));
}
return null;
}
@ -63,8 +63,8 @@ class OnEnabledEndpointCondition extends SpringBootCondition {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
context.getEnvironment(), "endpoints.");
boolean match = Boolean.valueOf(resolver.getProperty("enabled", "true"));
return new ConditionOutcome(match, "All endpoints are "
+ (match ? "enabled" : "disabled") + " by default");
return new ConditionOutcome(match,
"All endpoints are " + (match ? "enabled" : "disabled") + " by default");
}
}

@ -109,8 +109,8 @@ public abstract class AbstractEndpoint<T> implements Endpoint<T>, EnvironmentAwa
return this.enabled;
}
if (this.environment != null) {
return this.environment.getProperty(ENDPOINTS_ENABLED_PROPERTY,
Boolean.class, true);
return this.environment.getProperty(ENDPOINTS_ENABLED_PROPERTY, Boolean.class,
true);
}
return true;
}

@ -36,8 +36,8 @@ import org.springframework.core.env.Environment;
* @author Dave Syer
*/
@ConfigurationProperties(prefix = "endpoints.beans", ignoreUnknownFields = false)
public class BeansEndpoint extends AbstractEndpoint<List<Object>> implements
ApplicationContextAware {
public class BeansEndpoint extends AbstractEndpoint<List<Object>>
implements ApplicationContextAware {
private final LiveBeansView liveBeansView = new LiveBeansView();

@ -71,8 +71,8 @@ import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
* @author Dave Syer
*/
@ConfigurationProperties(prefix = "endpoints.configprops", ignoreUnknownFields = false)
public class ConfigurationPropertiesReportEndpoint extends
AbstractEndpoint<Map<String, Object>> implements ApplicationContextAware {
public class ConfigurationPropertiesReportEndpoint
extends AbstractEndpoint<Map<String, Object>> implements ApplicationContextAware {
private static final String CGLIB_FILTER_ID = "cglibFilter";
@ -128,7 +128,8 @@ public class ConfigurationPropertiesReportEndpoint extends
private Map<String, Object> extract(ApplicationContext context, ObjectMapper mapper) {
Map<String, Object> result = new HashMap<String, Object>();
ConfigurationBeanFactoryMetaData beanFactoryMetaData = getBeanFactoryMetaData(context);
ConfigurationBeanFactoryMetaData beanFactoryMetaData = getBeanFactoryMetaData(
context);
Map<String, Object> beans = getConfigurationPropertiesBeans(context,
beanFactoryMetaData);
for (Map.Entry<String, Object> entry : beans.entrySet()) {
@ -179,8 +180,8 @@ public class ConfigurationPropertiesReportEndpoint extends
}
try {
@SuppressWarnings("unchecked")
Map<String, Object> result = new HashMap<String, Object>(mapper.convertValue(
this.metadata.extractMap(bean, prefix), Map.class));
Map<String, Object> result = new HashMap<String, Object>(mapper
.convertValue(this.metadata.extractMap(bean, prefix), Map.class));
return result;
}
catch (Exception ex) {
@ -230,8 +231,8 @@ public class ConfigurationPropertiesReportEndpoint extends
ConfigurationProperties annotation = context.findAnnotationOnBean(beanName,
ConfigurationProperties.class);
if (beanFactoryMetaData != null) {
ConfigurationProperties override = beanFactoryMetaData.findFactoryAnnotation(
beanName, ConfigurationProperties.class);
ConfigurationProperties override = beanFactoryMetaData
.findFactoryAnnotation(beanName, ConfigurationProperties.class);
if (override != null) {
// The @Bean-level @ConfigurationProperties overrides the one at type
// level when binding. Arguably we should render them both, but this one
@ -267,8 +268,8 @@ public class ConfigurationPropertiesReportEndpoint extends
* properties.
*/
@SuppressWarnings("serial")
private static class CglibAnnotationIntrospector extends
JacksonAnnotationIntrospector {
private static class CglibAnnotationIntrospector
extends JacksonAnnotationIntrospector {
@Override
public Object findFilterId(Annotated a) {
@ -330,9 +331,8 @@ public class ConfigurationPropertiesReportEndpoint extends
// that its a nested class used solely for binding to config props, so it
// should be kosher. This filter is not used if there is JSON metadata for
// the property, so it's mainly for user-defined beans.
return (setter != null)
|| ClassUtils.getPackageName(parentType).equals(
ClassUtils.getPackageName(type));
return (setter != null) || ClassUtils.getPackageName(parentType)
.equals(ClassUtils.getPackageName(type));
}
private AnnotatedMethod findSetter(BeanDescription beanDesc,
@ -387,9 +387,8 @@ public class ConfigurationPropertiesReportEndpoint extends
private Set<String> findKeys(String prefix) {
HashSet<String> keys = new HashSet<String>();
for (String key : getKeys()) {
if (key.length() > prefix.length()
&& key.startsWith(prefix)
&& ".".equals(key.substring(prefix.length(), prefix.length() + 1))) {
if (key.length() > prefix.length() && key.startsWith(prefix) && "."
.equals(key.substring(prefix.length(), prefix.length() + 1))) {
keys.add(key.substring(prefix.length() + 1));
}
}
@ -416,8 +415,8 @@ public class ConfigurationPropertiesReportEndpoint extends
}
@SuppressWarnings("unchecked")
private void addKeys(ObjectMapper mapper, Resource resource) throws IOException,
JsonParseException, JsonMappingException {
private void addKeys(ObjectMapper mapper, Resource resource)
throws IOException, JsonParseException, JsonMappingException {
InputStream inputStream = resource.getInputStream();
Map<String, Object> map = mapper.readValue(inputStream, Map.class);
Collection<Map<String, Object>> metadata = (Collection<Map<String, Object>>) map
@ -448,8 +447,8 @@ public class ConfigurationPropertiesReportEndpoint extends
@SuppressWarnings("unchecked")
private void addProperty(Object bean, String key, Map<String, Object> map) {
String prefix = (key.contains(".") ? StringUtils.split(key, ".")[0] : key);
String suffix = (key.length() > prefix.length() ? key.substring(prefix
.length() + 1) : null);
String suffix = (key.length() > prefix.length()
? key.substring(prefix.length() + 1) : null);
String property = prefix;
if (bean instanceof Map) {
Map<String, Object> value = (Map<String, Object>) bean;

@ -84,7 +84,8 @@ public class DataSourcePublicMetrics implements PublicMetrics {
return metrics;
}
private <T extends Number> void addMetric(Set<Metric<?>> metrics, String name, T value) {
private <T extends Number> void addMetric(Set<Metric<?>> metrics, String name,
T value) {
if (value != null) {
metrics.add(new Metric<T>(name, value));
}

@ -40,8 +40,8 @@ public class DumpEndpoint extends AbstractEndpoint<List<ThreadInfo>> {
@Override
public List<ThreadInfo> invoke() {
return Arrays.asList(ManagementFactory.getThreadMXBean().dumpAllThreads(true,
true));
return Arrays
.asList(ManagementFactory.getThreadMXBean().dumpAllThreads(true, true));
}
}

@ -84,11 +84,12 @@ public class RequestMappingEndpoint extends AbstractEndpoint<Map<String, Object>
protected void extractMethodMappings(ApplicationContext applicationContext,
Map<String, Object> result) {
if (applicationContext != null) {
for (String name : applicationContext.getBeansOfType(
AbstractHandlerMethodMapping.class).keySet()) {
for (String name : applicationContext
.getBeansOfType(AbstractHandlerMethodMapping.class).keySet()) {
@SuppressWarnings("unchecked")
Map<?, HandlerMethod> methods = applicationContext.getBean(name,
AbstractHandlerMethodMapping.class).getHandlerMethods();
Map<?, HandlerMethod> methods = applicationContext
.getBean(name, AbstractHandlerMethodMapping.class)
.getHandlerMethods();
for (Object key : methods.keySet()) {
Map<String, String> map = new LinkedHashMap<String, String>();
map.put("bean", name);
@ -142,10 +143,8 @@ public class RequestMappingEndpoint extends AbstractEndpoint<Map<String, Object>
for (AbstractHandlerMethodMapping<?> mapping : methodMappings) {
Map<?, HandlerMethod> methods = mapping.getHandlerMethods();
for (Map.Entry<?, HandlerMethod> entry : methods.entrySet()) {
result.put(
String.valueOf(entry.getKey()),
Collections.singletonMap("method",
String.valueOf(entry.getValue())));
result.put(String.valueOf(entry.getKey()), Collections
.singletonMap("method", String.valueOf(entry.getValue())));
}
}
}

@ -51,11 +51,13 @@ public class RichGaugeReaderPublicMetrics implements PublicMetrics {
private List<Metric<?>> convert(RichGauge gauge) {
List<Metric<?>> result = new ArrayList<Metric<?>>(6);
result.add(new Metric<Double>(gauge.getName() + RichGauge.AVG, gauge.getAverage()));
result.add(
new Metric<Double>(gauge.getName() + RichGauge.AVG, gauge.getAverage()));
result.add(new Metric<Double>(gauge.getName() + RichGauge.VAL, gauge.getValue()));
result.add(new Metric<Double>(gauge.getName() + RichGauge.MIN, gauge.getMin()));
result.add(new Metric<Double>(gauge.getName() + RichGauge.MAX, gauge.getMax()));
result.add(new Metric<Double>(gauge.getName() + RichGauge.ALPHA, gauge.getAlpha()));
result.add(
new Metric<Double>(gauge.getName() + RichGauge.ALPHA, gauge.getAlpha()));
result.add(new Metric<Long>(gauge.getName() + RichGauge.COUNT, gauge.getCount()));
return result;
}

@ -32,8 +32,8 @@ import org.springframework.context.ConfigurableApplicationContext;
* @author Christian Dupuis
*/
@ConfigurationProperties(prefix = "endpoints.shutdown", ignoreUnknownFields = false)
public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>> implements
ApplicationContextAware {
public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>>
implements ApplicationContextAware {
private ConfigurableApplicationContext context;

@ -66,11 +66,12 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
protected void addBasicMetrics(Collection<Metric<?>> result) {
// NOTE: ManagementFactory must not be used here since it fails on GAE
result.add(new Metric<Long>("mem", Runtime.getRuntime().totalMemory() / 1024));
result.add(new Metric<Long>("mem.free", Runtime.getRuntime().freeMemory() / 1024));
result.add(new Metric<Integer>("processors", Runtime.getRuntime()
.availableProcessors()));
result.add(new Metric<Long>("instance.uptime", System.currentTimeMillis()
- this.timestamp));
result.add(
new Metric<Long>("mem.free", Runtime.getRuntime().freeMemory() / 1024));
result.add(new Metric<Integer>("processors",
Runtime.getRuntime().availableProcessors()));
result.add(new Metric<Long>("instance.uptime",
System.currentTimeMillis() - this.timestamp));
}
/**
@ -80,10 +81,10 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
private void addManagementMetrics(Collection<Metric<?>> result) {
try {
// Add JVM up time in ms
result.add(new Metric<Long>("uptime", ManagementFactory.getRuntimeMXBean()
.getUptime()));
result.add(new Metric<Double>("systemload.average", ManagementFactory
.getOperatingSystemMXBean().getSystemLoadAverage()));
result.add(new Metric<Long>("uptime",
ManagementFactory.getRuntimeMXBean().getUptime()));
result.add(new Metric<Double>("systemload.average",
ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage()));
addHeapMetrics(result);
addThreadMetrics(result);
addClassLoadingMetrics(result);
@ -113,10 +114,10 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
*/
protected void addThreadMetrics(Collection<Metric<?>> result) {
ThreadMXBean threadMxBean = ManagementFactory.getThreadMXBean();
result.add(new Metric<Long>("threads.peak", (long) threadMxBean
.getPeakThreadCount()));
result.add(new Metric<Long>("threads.daemon", (long) threadMxBean
.getDaemonThreadCount()));
result.add(new Metric<Long>("threads.peak",
(long) threadMxBean.getPeakThreadCount()));
result.add(new Metric<Long>("threads.daemon",
(long) threadMxBean.getDaemonThreadCount()));
result.add(new Metric<Long>("threads", (long) threadMxBean.getThreadCount()));
}
@ -126,12 +127,12 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
*/
protected void addClassLoadingMetrics(Collection<Metric<?>> result) {
ClassLoadingMXBean classLoadingMxBean = ManagementFactory.getClassLoadingMXBean();
result.add(new Metric<Long>("classes", (long) classLoadingMxBean
.getLoadedClassCount()));
result.add(new Metric<Long>("classes.loaded", classLoadingMxBean
.getTotalLoadedClassCount()));
result.add(new Metric<Long>("classes.unloaded", classLoadingMxBean
.getUnloadedClassCount()));
result.add(new Metric<Long>("classes",
(long) classLoadingMxBean.getLoadedClassCount()));
result.add(new Metric<Long>("classes.loaded",
classLoadingMxBean.getTotalLoadedClassCount()));
result.add(new Metric<Long>("classes.unloaded",
classLoadingMxBean.getUnloadedClassCount()));
}
/**
@ -143,10 +144,10 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
.getGarbageCollectorMXBeans();
for (GarbageCollectorMXBean garbageCollectorMXBean : garbageCollectorMxBeans) {
String name = beautifyGcName(garbageCollectorMXBean.getName());
result.add(new Metric<Long>("gc." + name + ".count", garbageCollectorMXBean
.getCollectionCount()));
result.add(new Metric<Long>("gc." + name + ".time", garbageCollectorMXBean
.getCollectionTime()));
result.add(new Metric<Long>("gc." + name + ".count",
garbageCollectorMXBean.getCollectionCount()));
result.add(new Metric<Long>("gc." + name + ".time",
garbageCollectorMXBean.getCollectionTime()));
}
}

@ -47,7 +47,8 @@ public class TomcatPublicMetrics implements PublicMetrics, ApplicationContextAwa
@Override
public Collection<Metric<?>> metrics() {
if (this.applicationContext instanceof EmbeddedWebApplicationContext) {
Manager manager = getManager((EmbeddedWebApplicationContext) this.applicationContext);
Manager manager = getManager(
(EmbeddedWebApplicationContext) this.applicationContext);
if (manager != null) {
return metrics(manager);
}
@ -65,7 +66,8 @@ public class TomcatPublicMetrics implements PublicMetrics, ApplicationContextAwa
}
private Manager getManager(TomcatEmbeddedServletContainer servletContainer) {
for (Container container : servletContainer.getTomcat().getHost().findChildren()) {
for (Container container : servletContainer.getTomcat().getHost()
.findChildren()) {
if (container instanceof Context) {
return ((Context) container).getManager();
}

@ -56,8 +56,8 @@ import org.springframework.util.ObjectUtils;
*
* @author Christian Dupuis
*/
public class EndpointMBeanExporter extends MBeanExporter implements SmartLifecycle,
BeanFactoryAware, ApplicationContextAware {
public class EndpointMBeanExporter extends MBeanExporter
implements SmartLifecycle, BeanFactoryAware, ApplicationContextAware {
public static final String DEFAULT_DOMAIN = "org.springframework.boot";
@ -121,7 +121,8 @@ public class EndpointMBeanExporter extends MBeanExporter implements SmartLifecyc
}
@Override
public void setEnsureUniqueRuntimeObjectNames(boolean ensureUniqueRuntimeObjectNames) {
public void setEnsureUniqueRuntimeObjectNames(
boolean ensureUniqueRuntimeObjectNames) {
super.setEnsureUniqueRuntimeObjectNames(ensureUniqueRuntimeObjectNames);
this.ensureUniqueRuntimeObjectNames = ensureUniqueRuntimeObjectNames;
}
@ -191,9 +192,8 @@ public class EndpointMBeanExporter extends MBeanExporter implements SmartLifecyc
+ ObjectUtils.getIdentityHexString(this.applicationContext));
}
if (this.ensureUniqueRuntimeObjectNames) {
builder.append(",identity="
+ ObjectUtils.getIdentityHexString(((EndpointMBean) bean)
.getEndpoint()));
builder.append(",identity=" + ObjectUtils
.getIdentityHexString(((EndpointMBean) bean).getEndpoint()));
}
builder.append(getStaticNames());
return ObjectNameManager.getInstance(builder.toString());

@ -48,8 +48,8 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
* @author Christian Dupuis
* @author Dave Syer
*/
public class EndpointHandlerMapping extends RequestMappingHandlerMapping implements
ApplicationContextAware {
public class EndpointHandlerMapping extends RequestMappingHandlerMapping
implements ApplicationContextAware {
private final Set<MvcEndpoint> endpoints;

@ -33,8 +33,8 @@ import org.springframework.web.bind.annotation.ResponseStatus;
* @author Christian Dupuis
* @author Andy Wilkinson
*/
public class EnvironmentMvcEndpoint extends EndpointMvcAdapter implements
EnvironmentAware {
public class EnvironmentMvcEndpoint extends EndpointMvcAdapter
implements EnvironmentAware {
private Environment environment;

@ -124,8 +124,9 @@ public class HealthMvcEndpoint implements MvcEndpoint, EnvironmentAware {
public Object invoke(Principal principal) {
if (!this.delegate.isEnabled()) {
// Shouldn't happen because the request mapping should not be registered
return new ResponseEntity<Map<String, String>>(Collections.singletonMap(
"message", "This endpoint is disabled"), HttpStatus.NOT_FOUND);
return new ResponseEntity<Map<String, String>>(
Collections.singletonMap("message", "This endpoint is disabled"),
HttpStatus.NOT_FOUND);
}
Health health = getHealth(principal);
HttpStatus status = this.statusMapping.get(health.getStatus().getCode());
@ -159,8 +160,8 @@ public class HealthMvcEndpoint implements MvcEndpoint, EnvironmentAware {
}
private boolean isSecure(Principal principal) {
return (principal != null && !principal.getClass().getName()
.contains("Anonymous"));
return (principal != null
&& !principal.getClass().getName().contains("Anonymous"));
}
private boolean isUnrestricted() {

@ -52,13 +52,14 @@ public class MvcEndpoints implements ApplicationContextAware, InitializingBean {
@Override
public void afterPropertiesSet() throws Exception {
Collection<MvcEndpoint> existing = this.applicationContext.getBeansOfType(
MvcEndpoint.class).values();
Collection<MvcEndpoint> existing = this.applicationContext
.getBeansOfType(MvcEndpoint.class).values();
this.endpoints.addAll(existing);
this.customTypes = findEndpointClasses(existing);
@SuppressWarnings("rawtypes")
Collection<Endpoint> delegates = BeanFactoryUtils.beansOfTypeIncludingAncestors(
this.applicationContext, Endpoint.class).values();
Collection<Endpoint> delegates = BeanFactoryUtils
.beansOfTypeIncludingAncestors(this.applicationContext, Endpoint.class)
.values();
for (Endpoint<?> endpoint : delegates) {
if (isGenericEndpoint(endpoint.getClass()) && endpoint.isEnabled()) {
this.endpoints.add(new EndpointMvcAdapter(endpoint));

@ -42,8 +42,9 @@ public class ShutdownMvcEndpoint extends EndpointMvcAdapter {
@Override
public Object invoke() {
if (!getDelegate().isEnabled()) {
return new ResponseEntity<Map<String, String>>(Collections.singletonMap(
"message", "This endpoint is disabled"), HttpStatus.NOT_FOUND);
return new ResponseEntity<Map<String, String>>(
Collections.singletonMap("message", "This endpoint is disabled"),
HttpStatus.NOT_FOUND);
}
return super.invoke();
}

@ -48,14 +48,15 @@ import org.springframework.util.StringUtils;
* @author Stephane Nicoll
* @since 1.1.0
*/
public class DataSourceHealthIndicator extends AbstractHealthIndicator implements
InitializingBean {
public class DataSourceHealthIndicator extends AbstractHealthIndicator
implements InitializingBean {
private static final Map<String, String> PRODUCT_SPECIFIC_QUERIES;
static {
Map<String, String> queries = new HashMap<String, String>();
queries.put("HSQL Database Engine", "SELECT COUNT(*) FROM "
+ "INFORMATION_SCHEMA.SYSTEM_USERS");
queries.put("HSQL Database Engine",
"SELECT COUNT(*) FROM " + "INFORMATION_SCHEMA.SYSTEM_USERS");
queries.put("Oracle", "SELECT 'Hello' from DUAL");
queries.put("Apache Derby", "SELECT 1 FROM SYSIBM.SYSDUMMY1");
PRODUCT_SPECIFIC_QUERIES = Collections.unmodifiableMap(queries);
@ -133,8 +134,8 @@ public class DataSourceHealthIndicator extends AbstractHealthIndicator implement
private String getProduct() {
return this.jdbcTemplate.execute(new ConnectionCallback<String>() {
@Override
public String doInConnection(Connection connection) throws SQLException,
DataAccessException {
public String doInConnection(Connection connection)
throws SQLException, DataAccessException {
return connection.getMetaData().getDatabaseProductName();
}
});

@ -50,9 +50,10 @@ public class DiskSpaceHealthIndicator extends AbstractHealthIndicator {
builder.up();
}
else {
logger.warn(String.format("Free disk space below threshold. "
+ "Available: %d bytes (threshold: %d bytes)", diskFreeInBytes,
this.properties.getThreshold()));
logger.warn(String.format(
"Free disk space below threshold. "
+ "Available: %d bytes (threshold: %d bytes)",
diskFreeInBytes, this.properties.getThreshold()));
builder.down();
}
builder.withDetail("free", diskFreeInBytes).withDetail("threshold",

@ -91,8 +91,8 @@ public class Metric<T extends Number> {
* @return a new {@link Metric} instance
*/
public Metric<Long> increment(int amount) {
return new Metric<Long>(this.getName(), new Long(this.getValue().longValue()
+ amount));
return new Metric<Long>(this.getName(),
new Long(this.getValue().longValue() + amount));
}
/**

@ -43,8 +43,8 @@ public abstract class AbstractMetricExporter implements Exporter {
private final String prefix;
public AbstractMetricExporter(String prefix) {
this.prefix = !StringUtils.hasText(prefix) ? "" : (prefix.endsWith(".") ? prefix
: prefix + ".");
this.prefix = !StringUtils.hasText(prefix) ? ""
: (prefix.endsWith(".") ? prefix : prefix + ".");
}
/**
@ -76,7 +76,8 @@ public abstract class AbstractMetricExporter implements Exporter {
Metric<?> value = new Metric<Number>(this.prefix + metric.getName(),
metric.getValue(), metric.getTimestamp());
Date timestamp = metric.getTimestamp();
if (!this.ignoreTimestamps && this.earliestTimestamp.after(timestamp)) {
if (!this.ignoreTimestamps
&& this.earliestTimestamp.after(timestamp)) {
continue;
}
values.add(value);

@ -45,7 +45,8 @@ public class PrefixMetricGroupExporter extends AbstractMetricExporter {
* @param reader a reader as the source of metrics
* @param writer the writer to send the metrics to
*/
public PrefixMetricGroupExporter(PrefixMetricReader reader, PrefixMetricWriter writer) {
public PrefixMetricGroupExporter(PrefixMetricReader reader,
PrefixMetricWriter writer) {
this(reader, writer, "");
}
@ -56,8 +57,8 @@ public class PrefixMetricGroupExporter extends AbstractMetricExporter {
* @param writer the writer to send the metrics to
* @param prefix the prefix for metrics to export
*/
public PrefixMetricGroupExporter(PrefixMetricReader reader,
PrefixMetricWriter writer, String prefix) {
public PrefixMetricGroupExporter(PrefixMetricReader reader, PrefixMetricWriter writer,
String prefix) {
super(prefix);
this.reader = reader;
this.writer = writer;

@ -240,8 +240,8 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
result = new HashSet<String>();
}
if (result.isEmpty()) {
for (PropertyDescriptor descriptor : BeanUtils.getPropertyDescriptors(metric
.getClass())) {
for (PropertyDescriptor descriptor : BeanUtils
.getPropertyDescriptors(metric.getClass())) {
if (ClassUtils.isAssignable(Number.class, descriptor.getPropertyType())) {
result.add(descriptor.getName());
}

@ -34,8 +34,8 @@ import org.springframework.boot.actuate.metrics.writer.Delta;
*
* @author Dave Syer
*/
public class InMemoryMetricRepository implements MetricRepository, MultiMetricRepository,
PrefixMetricReader {
public class InMemoryMetricRepository
implements MetricRepository, MultiMetricRepository, PrefixMetricReader {
private final SimpleInMemoryRepository<Metric<?>> metrics = new SimpleInMemoryRepository<Metric<?>>();
@ -55,8 +55,8 @@ public class InMemoryMetricRepository implements MetricRepository, MultiMetricRe
public Metric<?> modify(Metric<?> current) {
if (current != null) {
Metric<? extends Number> metric = current;
return new Metric<Long>(metricName, metric.increment(amount)
.getValue(), timestamp);
return new Metric<Long>(metricName,
metric.increment(amount).getValue(), timestamp);
}
else {
return new Metric<Long>(metricName, new Long(amount), timestamp);

@ -146,8 +146,8 @@ public class RedisMetricRepository implements MetricRepository {
String name = delta.getName();
String key = keyFor(name);
trackMembership(key);
double value = this.zSetOperations.incrementScore(key, delta.getValue()
.doubleValue());
double value = this.zSetOperations.incrementScore(key,
delta.getValue().doubleValue());
String raw = serialize(new Metric<Double>(name, value, delta.getTimestamp()));
this.redisOperations.opsForValue().set(key, raw);
}

@ -108,8 +108,8 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
.boundZSetOps(groupKey);
String key = keyFor(delta.getName());
double value = zSetOperations.incrementScore(key, delta.getValue().doubleValue());
String raw = serialize(new Metric<Double>(delta.getName(), value,
delta.getTimestamp()));
String raw = serialize(
new Metric<Double>(delta.getName(), value, delta.getTimestamp()));
this.redisOperations.opsForValue().set(key, raw);
}

@ -23,8 +23,8 @@ import org.springframework.util.Assert;
* <p>
* The value of the average will depend on whether a weight ('alpha') is set for the
* gauge. If it is unset, the average will contain a simple arithmetic mean. If a weight
* is set, an exponential moving average will be calculated as defined in this <a
* href="http://www.itl.nist.gov/div898/handbook/pmc/section4/pmc431.htm">NIST
* is set, an exponential moving average will be calculated as defined in this
* <a href="http://www.itl.nist.gov/div898/handbook/pmc/section4/pmc431.htm">NIST
* document</a>.
*
* @author Luke Taylor

@ -94,8 +94,8 @@ public class SimpleInMemoryRepository<T> {
if (!prefix.endsWith(".")) {
prefix = prefix + ".";
}
return new ArrayList<T>(this.values.subMap(prefix, false, prefix + "~", true)
.values());
return new ArrayList<T>(
this.values.subMap(prefix, false, prefix + "~", true).values());
}
public void setValues(ConcurrentNavigableMap<String, T> values) {

@ -47,7 +47,8 @@ public class AuthorizationAuditListener implements
@Override
public void onApplicationEvent(AbstractAuthorizationEvent event) {
if (event instanceof AuthenticationCredentialsNotFoundEvent) {
onAuthenticationCredentialsNotFoundEvent((AuthenticationCredentialsNotFoundEvent) event);
onAuthenticationCredentialsNotFoundEvent(
(AuthenticationCredentialsNotFoundEvent) event);
}
else if (event instanceof AuthorizationFailureEvent) {
onAuthorizationFailureEvent((AuthorizationFailureEvent) event);

@ -43,8 +43,8 @@ import org.springframework.util.Assert;
* @author Phillip Webb
* @since 1.2.0
*/
public class ApplicationPidFileWriter implements
ApplicationListener<SpringApplicationEvent>, Ordered {
public class ApplicationPidFileWriter
implements ApplicationListener<SpringApplicationEvent>, Ordered {
private static final Log logger = LogFactory.getLog(ApplicationPidFileWriter.class);
@ -108,7 +108,8 @@ public class ApplicationPidFileWriter implements
writePidFile(event);
}
catch (Exception ex) {
logger.warn(String.format("Cannot create pid file %s", this.file), ex);
logger.warn(String.format("Cannot create pid file %s", this.file),
ex);
}
}
}

@ -39,8 +39,8 @@ import org.springframework.util.StringUtils;
*
* @since 1.2.0
*/
public class EmbeddedServerPortFileWriter implements
ApplicationListener<EmbeddedServletContainerInitializedEvent> {
public class EmbeddedServerPortFileWriter
implements ApplicationListener<EmbeddedServletContainerInitializedEvent> {
private static final String DEFAULT_FILE_NAME = "application.port";

@ -31,8 +31,8 @@ class SystemProperties {
}
}
catch (Throwable ex) {
System.err.println("Could not resolve '" + property
+ "' as system property: " + ex);
System.err.println(
"Could not resolve '" + property + "' as system property: " + ex);
}
}
return null;

@ -85,7 +85,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
throws ServletException, IOException {
Map<String, Object> trace = getTrace(request);
if (this.logger.isTraceEnabled()) {
@ -147,8 +147,8 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
.getAttribute("javax.servlet.error.exception");
if (exception != null && this.errorAttributes != null) {
RequestAttributes requestAttributes = new ServletRequestAttributes(request);
Map<String, Object> error = this.errorAttributes.getErrorAttributes(
requestAttributes, true);
Map<String, Object> error = this.errorAttributes
.getErrorAttributes(requestAttributes, true);
trace.put("error", error);
}
return trace;

@ -32,8 +32,8 @@ public class AuditEventTests {
@Test
public void testNowEvent() throws Exception {
AuditEvent event = new AuditEvent("phil", "UNKNOWN", Collections.singletonMap(
"a", (Object) "b"));
AuditEvent event = new AuditEvent("phil", "UNKNOWN",
Collections.singletonMap("a", (Object) "b"));
assertEquals("b", event.getData().get("a"));
assertEquals("UNKNOWN", event.getType());
assertEquals("phil", event.getPrincipal());

@ -193,8 +193,8 @@ public class CrshAutoConfigurationTests {
PluginContext pluginContext = lifeCycle.getContext();
int count = 0;
Iterator<AuthenticationPlugin> plugins = pluginContext.getPlugins(
AuthenticationPlugin.class).iterator();
Iterator<AuthenticationPlugin> plugins = pluginContext
.getPlugins(AuthenticationPlugin.class).iterator();
while (plugins.hasNext()) {
count++;
plugins.next();
@ -229,8 +229,8 @@ public class CrshAutoConfigurationTests {
PluginLifeCycle lifeCycle = this.context.getBean(PluginLifeCycle.class);
assertEquals("jaas", lifeCycle.getConfig().get("crash.auth"));
assertEquals("my-test-domain", lifeCycle.getConfig()
.get("crash.auth.jaas.domain"));
assertEquals("my-test-domain",
lifeCycle.getConfig().get("crash.auth.jaas.domain"));
}
@Test
@ -269,8 +269,8 @@ public class CrshAutoConfigurationTests {
AuthenticationPlugin<String> authenticationPlugin = null;
String authentication = lifeCycle.getConfig().getProperty("crash.auth");
assertNotNull(authentication);
for (AuthenticationPlugin plugin : lifeCycle.getContext().getPlugins(
AuthenticationPlugin.class)) {
for (AuthenticationPlugin plugin : lifeCycle.getContext()
.getPlugins(AuthenticationPlugin.class)) {
if (authentication.equals(plugin.getName())) {
authenticationPlugin = plugin;
break;
@ -298,8 +298,8 @@ public class CrshAutoConfigurationTests {
AuthenticationPlugin<String> authenticationPlugin = null;
String authentication = lifeCycle.getConfig().getProperty("crash.auth");
assertNotNull(authentication);
for (AuthenticationPlugin plugin : lifeCycle.getContext().getPlugins(
AuthenticationPlugin.class)) {
for (AuthenticationPlugin plugin : lifeCycle.getContext()
.getPlugins(AuthenticationPlugin.class)) {
if (authentication.equals(plugin.getName())) {
authenticationPlugin = plugin;
break;
@ -313,7 +313,8 @@ public class CrshAutoConfigurationTests {
}
@Test
public void testSpringAuthenticationProviderAsDefaultConfiguration() throws Exception {
public void testSpringAuthenticationProviderAsDefaultConfiguration()
throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(ManagementServerPropertiesAutoConfiguration.class);
@ -327,8 +328,8 @@ public class CrshAutoConfigurationTests {
AuthenticationPlugin<String> authenticationPlugin = null;
String authentication = lifeCycle.getConfig().getProperty("crash.auth");
assertNotNull(authentication);
for (AuthenticationPlugin plugin : lifeCycle.getContext().getPlugins(
AuthenticationPlugin.class)) {
for (AuthenticationPlugin plugin : lifeCycle.getContext()
.getPlugins(AuthenticationPlugin.class)) {
if (authentication.equals(plugin.getName())) {
authenticationPlugin = plugin;
break;
@ -359,12 +360,12 @@ public class CrshAutoConfigurationTests {
&& authentication.getCredentials().equals(PASSWORD)) {
authentication = new UsernamePasswordAuthenticationToken(
authentication.getPrincipal(),
authentication.getCredentials(),
Collections
authentication.getCredentials(), Collections
.singleton(new SimpleGrantedAuthority("ADMIN")));
}
else {
throw new BadCredentialsException("Invalid username and password");
throw new BadCredentialsException(
"Invalid username and password");
}
return authentication;
}

@ -98,8 +98,7 @@ public class EndpointMBeanExportAutoConfigurationTests {
throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
NestedInManagedEndpoint.class,
EndpointMBeanExportAutoConfiguration.class,
NestedInManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(EndpointMBeanExporter.class));
@ -116,8 +115,7 @@ public class EndpointMBeanExportAutoConfigurationTests {
environment.setProperty("endpoints.jmx.enabled", "false");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class,
EndpointAutoConfiguration.class,
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
@ -133,26 +131,24 @@ public class EndpointMBeanExportAutoConfigurationTests {
environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class,
EndpointAutoConfiguration.class,
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertNotNull(mbeanExporter.getServer().getMBeanInfo(
ObjectNameManager.getInstance(getObjectName("test-domain",
"healthEndpoint", this.context).toString()
+ ",key1=value1,key2=value2")));
assertNotNull(mbeanExporter.getServer()
.getMBeanInfo(ObjectNameManager.getInstance(
getObjectName("test-domain", "healthEndpoint", this.context)
.toString() + ",key1=value1,key2=value2")));
}
@Test
public void testEndpointMBeanExporterInParentChild() throws IntrospectionException,
InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
this.context = new AnnotationConfigApplicationContext();
this.context.register(JmxAutoConfiguration.class,
EndpointAutoConfiguration.class,
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
@ -177,10 +173,8 @@ public class EndpointMBeanExportAutoConfigurationTests {
}
if (applicationContext.getEnvironment().getProperty("endpoints.jmx.unique_names",
Boolean.class, false)) {
name = name
+ ",identity="
+ ObjectUtils.getIdentityHexString(applicationContext
.getBean(beanKey));
name = name + ",identity=" + ObjectUtils
.getIdentityHexString(applicationContext.getBean(beanKey));
}
if (applicationContext.getParent() != null) {
return ObjectNameManager.getInstance(String.format(name, domain, beanKey,

@ -82,8 +82,8 @@ public class EndpointMvcIntegrationTests {
@Test
public void envEndpointNotHidden() throws InterruptedException {
String body = new TestRestTemplate().getForObject("http://localhost:" + this.port
+ "/env/user.dir", String.class);
String body = new TestRestTemplate().getForObject(
"http://localhost:" + this.port + "/env/user.dir", String.class);
assertNotNull(body);
assertTrue("Wrong body: \n" + body, body.contains("spring-boot-actuator"));
assertTrue(this.interceptor.invoked());
@ -95,8 +95,8 @@ public class EndpointMvcIntegrationTests {
@Import({ EmbeddedServletContainerAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
ErrorMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })
protected static @interface MinimalWebConfiguration {
}

@ -160,10 +160,10 @@ public class EndpointWebMvcAutoConfigurationTests {
DifferentPortConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
ServletContext servletContext = mock(ServletContext.class);
given(servletContext.getInitParameterNames()).willReturn(
new Vector<String>().elements());
given(servletContext.getAttributeNames()).willReturn(
new Vector<String>().elements());
given(servletContext.getInitParameterNames())
.willReturn(new Vector<String>().elements());
given(servletContext.getAttributeNames())
.willReturn(new Vector<String>().elements());
this.applicationContext.setServletContext(servletContext);
this.applicationContext.refresh();
assertContent("/controller", ports.get().management, null);
@ -205,8 +205,9 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test
public void specificPortsViaProperties() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, "server.port:"
+ ports.get().server, "management.port:" + ports.get().management);
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"server.port:" + ports.get().server,
"management.port:" + ports.get().management);
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class);
@ -245,8 +246,8 @@ public class EndpointWebMvcAutoConfigurationTests {
new ServerPortInfoApplicationContextInitializer()
.initialize(this.applicationContext);
this.applicationContext.refresh();
Integer localServerPort = this.applicationContext.getEnvironment().getProperty(
"local.server.port", Integer.class);
Integer localServerPort = this.applicationContext.getEnvironment()
.getProperty("local.server.port", Integer.class);
Integer localManagementPort = this.applicationContext.getEnvironment()
.getProperty("local.management.port", Integer.class);
assertThat(localServerPort, notNullValue());
@ -264,8 +265,8 @@ public class EndpointWebMvcAutoConfigurationTests {
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class);
this.applicationContext.refresh();
Integer localServerPort = this.applicationContext.getEnvironment().getProperty(
"local.server.port", Integer.class);
Integer localServerPort = this.applicationContext.getEnvironment()
.getProperty("local.server.port", Integer.class);
Integer localManagementPort = this.applicationContext.getEnvironment()
.getProperty("local.management.port", Integer.class);
assertThat(localServerPort, notNullValue());
@ -345,8 +346,9 @@ public class EndpointWebMvcAutoConfigurationTests {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"endpoints.shutdown.enabled:true");
this.applicationContext.refresh();
assertThat(this.applicationContext.getBeansOfType(ShutdownMvcEndpoint.class)
.size(), is(equalTo(1)));
assertThat(
this.applicationContext.getBeansOfType(ShutdownMvcEndpoint.class).size(),
is(equalTo(1)));
}
private void endpointDisabled(String name, Class<? extends MvcEndpoint> type) {
@ -378,8 +380,8 @@ public class EndpointWebMvcAutoConfigurationTests {
public void assertContent(String url, int port, Object expected) throws Exception {
SimpleClientHttpRequestFactory clientHttpRequestFactory = new SimpleClientHttpRequestFactory();
ClientHttpRequest request = clientHttpRequestFactory.createRequest(new URI(
"http://localhost:" + port + url), HttpMethod.GET);
ClientHttpRequest request = clientHttpRequestFactory
.createRequest(new URI("http://localhost:" + port + url), HttpMethod.GET);
try {
ClientHttpResponse response = request.execute();
try {
@ -404,8 +406,8 @@ public class EndpointWebMvcAutoConfigurationTests {
public boolean hasHeader(String url, int port, String header) throws Exception {
SimpleClientHttpRequestFactory clientHttpRequestFactory = new SimpleClientHttpRequestFactory();
ClientHttpRequest request = clientHttpRequestFactory.createRequest(new URI(
"http://localhost:" + port + url), HttpMethod.GET);
ClientHttpRequest request = clientHttpRequestFactory
.createRequest(new URI("http://localhost:" + port + url), HttpMethod.GET);
ClientHttpResponse response = request.execute();
return response.getHeaders().containsKey(header);
}
@ -421,8 +423,7 @@ public class EndpointWebMvcAutoConfigurationTests {
@Configuration
@Import({ PropertyPlaceholderAutoConfiguration.class,
EmbeddedServletContainerAutoConfiguration.class,
EndpointAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
EndpointAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class,
ServerPropertiesAutoConfiguration.class, WebMvcAutoConfiguration.class })
@ -582,8 +583,8 @@ public class EndpointWebMvcAutoConfigurationTests {
}
private static class GrabManagementPort implements
ApplicationListener<EmbeddedServletContainerInitializedEvent> {
private static class GrabManagementPort
implements ApplicationListener<EmbeddedServletContainerInitializedEvent> {
private ApplicationContext rootContext;

@ -84,8 +84,8 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size());
assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next()
.getClass());
assertEquals(ApplicationHealthIndicator.class,
beans.values().iterator().next().getClass());
}
@Test
@ -99,8 +99,8 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size());
assertEquals(RedisHealthIndicator.class, beans.values().iterator().next()
.getClass());
assertEquals(RedisHealthIndicator.class,
beans.values().iterator().next().getClass());
}
@Test
@ -115,8 +115,8 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size());
assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next()
.getClass());
assertEquals(ApplicationHealthIndicator.class,
beans.values().iterator().next().getClass());
}
@Test
@ -131,8 +131,8 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size());
assertEquals(MongoHealthIndicator.class, beans.values().iterator().next()
.getClass());
assertEquals(MongoHealthIndicator.class,
beans.values().iterator().next().getClass());
}
@Test
@ -148,8 +148,8 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size());
assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next()
.getClass());
assertEquals(ApplicationHealthIndicator.class,
beans.values().iterator().next().getClass());
}
@Test
@ -175,8 +175,8 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size());
assertEquals(DataSourceHealthIndicator.class, beans.values().iterator().next()
.getClass());
assertEquals(DataSourceHealthIndicator.class,
beans.values().iterator().next().getClass());
}
@Test
@ -212,8 +212,8 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size());
assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next()
.getClass());
assertEquals(ApplicationHealthIndicator.class,
beans.values().iterator().next().getClass());
}
@Test
@ -227,8 +227,8 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size());
assertEquals(RabbitHealthIndicator.class, beans.values().iterator().next()
.getClass());
assertEquals(RabbitHealthIndicator.class,
beans.values().iterator().next().getClass());
}
@Test
@ -243,8 +243,8 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size());
assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next()
.getClass());
assertEquals(ApplicationHealthIndicator.class,
beans.values().iterator().next().getClass());
}
@Test
@ -258,8 +258,8 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size());
assertEquals(SolrHealthIndicator.class, beans.values().iterator().next()
.getClass());
assertEquals(SolrHealthIndicator.class,
beans.values().iterator().next().getClass());
}
@Test
@ -274,8 +274,8 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size());
assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next()
.getClass());
assertEquals(ApplicationHealthIndicator.class,
beans.values().iterator().next().getClass());
}
@Test
@ -286,8 +286,8 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size());
assertEquals(DiskSpaceHealthIndicator.class, beans.values().iterator().next()
.getClass());
assertEquals(DiskSpaceHealthIndicator.class,
beans.values().iterator().next().getClass());
}
@Configuration

@ -56,8 +56,8 @@ public class HealthMvcEndpointAutoConfigurationTests {
EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
TestHealthIndicator.class);
this.context.refresh();
Health health = (Health) this.context.getBean(HealthMvcEndpoint.class).invoke(
null);
Health health = (Health) this.context.getBean(HealthMvcEndpoint.class)
.invoke(null);
assertEquals(Status.UP, health.getStatus());
assertEquals(null, health.getDetails().get("foo"));
}
@ -73,11 +73,11 @@ public class HealthMvcEndpointAutoConfigurationTests {
EnvironmentTestUtils.addEnvironment(this.context,
"management.security.enabled=false");
this.context.refresh();
Health health = (Health) this.context.getBean(HealthMvcEndpoint.class).invoke(
null);
Health health = (Health) this.context.getBean(HealthMvcEndpoint.class)
.invoke(null);
assertEquals(Status.UP, health.getStatus());
Health map = (Health) health.getDetails().get(
"healthMvcEndpointAutoConfigurationTests.Test");
Health map = (Health) health.getDetails()
.get("healthMvcEndpointAutoConfigurationTests.Test");
assertEquals("bar", map.getDetails().get("foo"));
}

@ -64,7 +64,8 @@ public class JolokiaAutoConfigurationTests {
HttpMessageConvertersAutoConfiguration.class,
JolokiaAutoConfiguration.class);
this.context.refresh();
assertEquals(1, this.context.getBeanNamesForType(JolokiaMvcEndpoint.class).length);
assertEquals(1,
this.context.getBeanNamesForType(JolokiaMvcEndpoint.class).length);
}
@Test
@ -79,7 +80,8 @@ public class JolokiaAutoConfigurationTests {
@Test
public void endpointEnabledAsOverride() throws Exception {
assertEndpointEnabled("endpoints.enabled:false", "endpoints.jolokia.enabled:true");
assertEndpointEnabled("endpoints.enabled:false",
"endpoints.jolokia.enabled:true");
}
private void assertEndpointDisabled(String... pairs) {
@ -91,7 +93,8 @@ public class JolokiaAutoConfigurationTests {
HttpMessageConvertersAutoConfiguration.class,
JolokiaAutoConfiguration.class);
this.context.refresh();
assertEquals(0, this.context.getBeanNamesForType(JolokiaMvcEndpoint.class).length);
assertEquals(0,
this.context.getBeanNamesForType(JolokiaMvcEndpoint.class).length);
}
private void assertEndpointEnabled(String... pairs) {
@ -103,7 +106,8 @@ public class JolokiaAutoConfigurationTests {
HttpMessageConvertersAutoConfiguration.class,
JolokiaAutoConfiguration.class);
this.context.refresh();
assertEquals(1, this.context.getBeanNamesForType(JolokiaMvcEndpoint.class).length);
assertEquals(1,
this.context.getBeanNamesForType(JolokiaMvcEndpoint.class).length);
}
@Configuration

@ -94,7 +94,8 @@ public class ManagementSecurityAutoConfigurationTests {
assertThat(filterChainProxy.getFilters("/beans"), hasSize(greaterThan(0)));
assertThat(filterChainProxy.getFilters("/beans/"), hasSize(greaterThan(0)));
assertThat(filterChainProxy.getFilters("/beans.foo"), hasSize(greaterThan(0)));
assertThat(filterChainProxy.getFilters("/beans/foo/bar"), hasSize(greaterThan(0)));
assertThat(filterChainProxy.getFilters("/beans/foo/bar"),
hasSize(greaterThan(0)));
}
@Test
@ -116,9 +117,8 @@ public class ManagementSecurityAutoConfigurationTests {
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
UserDetails user = getUser();
assertTrue(user.getAuthorities().containsAll(
AuthorityUtils
.commaSeparatedStringToAuthorityList("ROLE_USER,ROLE_ADMIN")));
assertTrue(user.getAuthorities().containsAll(AuthorityUtils
.commaSeparatedStringToAuthorityList("ROLE_USER,ROLE_ADMIN")));
}
private UserDetails getUser() {
@ -126,8 +126,8 @@ public class ManagementSecurityAutoConfigurationTests {
.getBean(AuthenticationManager.class);
DaoAuthenticationProvider provider = (DaoAuthenticationProvider) parent
.getProviders().get(0);
UserDetailsService service = (UserDetailsService) ReflectionTestUtils.getField(
provider, "userDetailsService");
UserDetailsService service = (UserDetailsService) ReflectionTestUtils
.getField(provider, "userDetailsService");
UserDetails user = service.loadUserByUsername("user");
return user;
}
@ -144,8 +144,8 @@ public class ManagementSecurityAutoConfigurationTests {
EnvironmentTestUtils.addEnvironment(this.context, "security.ignored:none");
this.context.refresh();
// Just the application and management endpoints now
assertEquals(2, this.context.getBean(FilterChainProxy.class).getFilterChains()
.size());
assertEquals(2,
this.context.getBean(FilterChainProxy.class).getFilterChains().size());
}
@Test
@ -163,8 +163,8 @@ public class ManagementSecurityAutoConfigurationTests {
this.context.refresh();
// Just the management endpoints (one filter) and ignores now plus the backup
// filter on app endpoints
assertEquals(6, this.context.getBean(FilterChainProxy.class).getFilterChains()
.size());
assertEquals(6,
this.context.getBean(FilterChainProxy.class).getFilterChains().size());
}
@Test
@ -200,8 +200,7 @@ public class ManagementSecurityAutoConfigurationTests {
public void realmSameForManagement() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(AuthenticationConfig.class,
SecurityAutoConfiguration.class,
this.context.register(AuthenticationConfig.class, SecurityAutoConfiguration.class,
ManagementSecurityAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class,
EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,

@ -110,10 +110,10 @@ public class MetricFilterAutoConfigurationTests {
MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController())
.addFilter(filter).build();
mvc.perform(get("/templateVarTest/foo")).andExpect(status().isOk());
verify(context.getBean(CounterService.class)).increment(
"status.200.templateVarTest.someVariable");
verify(context.getBean(GaugeService.class)).submit(
eq("response.templateVarTest.someVariable"), anyDouble());
verify(context.getBean(CounterService.class))
.increment("status.200.templateVarTest.someVariable");
verify(context.getBean(GaugeService.class))
.submit(eq("response.templateVarTest.someVariable"), anyDouble());
context.close();
}
@ -126,10 +126,10 @@ public class MetricFilterAutoConfigurationTests {
MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController())
.addFilter(filter).build();
mvc.perform(get("/knownPath/foo")).andExpect(status().isNotFound());
verify(context.getBean(CounterService.class)).increment(
"status.404.knownPath.someVariable");
verify(context.getBean(GaugeService.class)).submit(
eq("response.knownPath.someVariable"), anyDouble());
verify(context.getBean(CounterService.class))
.increment("status.404.knownPath.someVariable");
verify(context.getBean(GaugeService.class))
.submit(eq("response.knownPath.someVariable"), anyDouble());
context.close();
}
@ -142,10 +142,10 @@ public class MetricFilterAutoConfigurationTests {
.addFilter(filter).build();
mvc.perform(get("/unknownPath/1")).andExpect(status().isNotFound());
mvc.perform(get("/unknownPath/2")).andExpect(status().isNotFound());
verify(context.getBean(CounterService.class), times(2)).increment(
"status.404.unmapped");
verify(context.getBean(GaugeService.class), times(2)).submit(
eq("response.unmapped"), anyDouble());
verify(context.getBean(CounterService.class), times(2))
.increment("status.404.unmapped");
verify(context.getBean(GaugeService.class), times(2))
.submit(eq("response.unmapped"), anyDouble());
context.close();
}
@ -159,10 +159,10 @@ public class MetricFilterAutoConfigurationTests {
.build();
mvc.perform(get("/unknownPath/1")).andExpect(status().is3xxRedirection());
mvc.perform(get("/unknownPath/2")).andExpect(status().is3xxRedirection());
verify(context.getBean(CounterService.class), times(2)).increment(
"status.302.unmapped");
verify(context.getBean(GaugeService.class), times(2)).submit(
eq("response.unmapped"), anyDouble());
verify(context.getBean(CounterService.class), times(2))
.increment("status.302.unmapped");
verify(context.getBean(GaugeService.class), times(2))
.submit(eq("response.unmapped"), anyDouble());
context.close();
}
@ -182,16 +182,16 @@ public class MetricFilterAutoConfigurationTests {
MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController())
.addFilter(filter).build();
try {
mvc.perform(get("/unhandledException")).andExpect(
status().isInternalServerError());
mvc.perform(get("/unhandledException"))
.andExpect(status().isInternalServerError());
}
catch (NestedServletException ex) {
// Expected
}
verify(context.getBean(CounterService.class)).increment(
"status.500.unhandledException");
verify(context.getBean(GaugeService.class)).submit(
eq("response.unhandledException"), anyDouble());
verify(context.getBean(CounterService.class))
.increment("status.500.unhandledException");
verify(context.getBean(GaugeService.class))
.submit(eq("response.unhandledException"), anyDouble());
context.close();
}
@ -206,10 +206,10 @@ public class MetricFilterAutoConfigurationTests {
MockMvc mvc = MockMvcBuilders.standaloneSetup(new MetricFilterTestController())
.addFilter(filter).build();
mvc.perform(get("/templateVarTest/foo")).andExpect(status().isOk());
verify(context.getBean(CounterService.class)).increment(
"status.200.templateVarTest.someVariable");
verify(context.getBean(GaugeService.class)).submit(
eq("response.templateVarTest.someVariable"), anyDouble());
verify(context.getBean(CounterService.class))
.increment("status.200.templateVarTest.someVariable");
verify(context.getBean(GaugeService.class))
.submit(eq("response.templateVarTest.someVariable"), anyDouble());
context.close();
}
@ -237,7 +237,8 @@ public class MetricFilterAutoConfigurationTests {
}
@Test
public void correctlyRecordsMetricsForFailedDeferredResultResponse() throws Exception {
public void correctlyRecordsMetricsForFailedDeferredResultResponse()
throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
Config.class, MetricFilterAutoConfiguration.class);
MetricsFilter filter = context.getBean(MetricsFilter.class);
@ -259,8 +260,8 @@ public class MetricFilterAutoConfigurationTests {
}
catch (Exception ex) {
assertThat(result.getRequest().getAttribute(attributeName), is(nullValue()));
verify(context.getBean(CounterService.class)).increment(
"status.500.createFailure");
verify(context.getBean(CounterService.class))
.increment("status.500.createFailure");
}
finally {
context.close();
@ -321,8 +322,8 @@ public class MetricFilterAutoConfigurationTests {
public void run() {
try {
MetricFilterTestController.this.latch.await();
result.setResult(new ResponseEntity<String>("Done",
HttpStatus.CREATED));
result.setResult(
new ResponseEntity<String>("Done", HttpStatus.CREATED));
}
catch (InterruptedException ex) {
}
@ -357,8 +358,8 @@ public class MetricFilterAutoConfigurationTests {
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain chain) throws ServletException,
IOException {
HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {
// send redirect before filter chain is executed, like Spring Security sending
// us back to a login page
response.sendRedirect("http://example.com");

@ -73,8 +73,8 @@ public class MetricRepositoryAutoConfigurationTests {
assertNotNull(gaugeService);
assertNotNull(context.getBean(DefaultCounterService.class));
gaugeService.submit("foo", 2.7);
assertEquals(2.7, context.getBean(MetricReader.class).findOne("gauge.foo")
.getValue());
assertEquals(2.7,
context.getBean(MetricReader.class).findOne("gauge.foo").getValue());
context.close();
}
@ -111,7 +111,8 @@ public class MetricRepositoryAutoConfigurationTests {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
Config.class, MetricRepositoryAutoConfiguration.class);
assertThat(context.getBeansOfType(DefaultGaugeService.class).size(), equalTo(0));
assertThat(context.getBeansOfType(DefaultCounterService.class).size(), equalTo(0));
assertThat(context.getBeansOfType(DefaultCounterService.class).size(),
equalTo(0));
context.close();
}

@ -86,8 +86,8 @@ public class PublicMetricsAutoConfigurationTests {
@Test
public void metricReaderPublicMetrics() throws Exception {
load();
assertEquals(1, this.context.getBeansOfType(MetricReaderPublicMetrics.class)
.size());
assertEquals(1,
this.context.getBeansOfType(MetricReaderPublicMetrics.class).size());
}
@Test
@ -98,8 +98,8 @@ public class PublicMetricsAutoConfigurationTests {
RichGaugeReader richGaugeReader = context.getBean(RichGaugeReader.class);
assertNotNull(richGaugeReader);
given(richGaugeReader.findAll()).willReturn(
Collections.singletonList(new RichGauge("bar", 3.7d)));
given(richGaugeReader.findAll())
.willReturn(Collections.singletonList(new RichGauge("bar", 3.7d)));
RichGaugeReaderPublicMetrics publicMetrics = context
.getBean(RichGaugeReaderPublicMetrics.class);
@ -122,7 +122,8 @@ public class PublicMetricsAutoConfigurationTests {
@Test
public void noDataSource() {
load();
assertEquals(0, this.context.getBeansOfType(DataSourcePublicMetrics.class).size());
assertEquals(0,
this.context.getBeansOfType(DataSourcePublicMetrics.class).size());
}
@Test
@ -142,12 +143,12 @@ public class PublicMetricsAutoConfigurationTests {
"datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");
// Hikari won't work unless a first connection has been retrieved
JdbcTemplate jdbcTemplate = new JdbcTemplate(this.context.getBean("hikariDS",
DataSource.class));
JdbcTemplate jdbcTemplate = new JdbcTemplate(
this.context.getBean("hikariDS", DataSource.class));
jdbcTemplate.execute(new ConnectionCallback<Void>() {
@Override
public Void doInConnection(Connection connection) throws SQLException,
DataAccessException {
public Void doInConnection(Connection connection)
throws SQLException, DataAccessException {
return null;
}
});

@ -56,8 +56,8 @@ public class ShellPropertiesTests {
public void testBindingAuth() {
ShellProperties props = new ShellProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
binder.bind(new MutablePropertyValues(Collections.singletonMap("shell.auth",
"spring")));
binder.bind(new MutablePropertyValues(
Collections.singletonMap("shell.auth", "spring")));
assertFalse(binder.getBindingResult().hasErrors());
assertEquals("spring", props.getAuth());
}
@ -66,7 +66,8 @@ public class ShellPropertiesTests {
public void testBindingAuthIfEmpty() {
ShellProperties props = new ShellProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
binder.bind(new MutablePropertyValues(Collections.singletonMap("shell.auth", "")));
binder.bind(
new MutablePropertyValues(Collections.singletonMap("shell.auth", "")));
assertTrue(binder.getBindingResult().hasErrors());
assertEquals("simple", props.getAuth());
}
@ -76,8 +77,8 @@ public class ShellPropertiesTests {
ShellProperties props = new ShellProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
binder.setConversionService(new DefaultConversionService());
binder.bind(new MutablePropertyValues(Collections.singletonMap(
"shell.command_refresh_interval", "1")));
binder.bind(new MutablePropertyValues(
Collections.singletonMap("shell.command_refresh_interval", "1")));
assertFalse(binder.getBindingResult().hasErrors());
assertEquals(1, props.getCommandRefreshInterval());
}
@ -87,8 +88,8 @@ public class ShellPropertiesTests {
ShellProperties props = new ShellProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
binder.setConversionService(new DefaultConversionService());
binder.bind(new MutablePropertyValues(Collections.singletonMap(
"shell.command_path_patterns", "pattern1, pattern2")));
binder.bind(new MutablePropertyValues(Collections
.singletonMap("shell.command_path_patterns", "pattern1, pattern2")));
assertFalse(binder.getBindingResult().hasErrors());
assertEquals(2, props.getCommandPathPatterns().length);
Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" },
@ -100,8 +101,8 @@ public class ShellPropertiesTests {
ShellProperties props = new ShellProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
binder.setConversionService(new DefaultConversionService());
binder.bind(new MutablePropertyValues(Collections.singletonMap(
"shell.config_path_patterns", "pattern1, pattern2")));
binder.bind(new MutablePropertyValues(Collections
.singletonMap("shell.config_path_patterns", "pattern1, pattern2")));
assertFalse(binder.getBindingResult().hasErrors());
assertEquals(2, props.getConfigPathPatterns().length);
Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" },
@ -113,8 +114,8 @@ public class ShellPropertiesTests {
ShellProperties props = new ShellProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
binder.setConversionService(new DefaultConversionService());
binder.bind(new MutablePropertyValues(Collections.singletonMap(
"shell.disabled_plugins", "pattern1, pattern2")));
binder.bind(new MutablePropertyValues(Collections
.singletonMap("shell.disabled_plugins", "pattern1, pattern2")));
assertFalse(binder.getBindingResult().hasErrors());
assertEquals(2, props.getDisabledPlugins().length);
assertArrayEquals(new String[] { "pattern1", "pattern2" },
@ -126,8 +127,8 @@ public class ShellPropertiesTests {
ShellProperties props = new ShellProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
binder.setConversionService(new DefaultConversionService());
binder.bind(new MutablePropertyValues(Collections.singletonMap(
"shell.disabled_commands", "pattern1, pattern2")));
binder.bind(new MutablePropertyValues(Collections
.singletonMap("shell.disabled_commands", "pattern1, pattern2")));
assertFalse(binder.getBindingResult().hasErrors());
assertEquals(2, props.getDisabledCommands().length);
assertArrayEquals(new String[] { "pattern1", "pattern2" },
@ -271,8 +272,8 @@ public class ShellPropertiesTests {
public void testDefaultPasswordAutogeneratedIfUnresolovedPlaceholder() {
SimpleAuthenticationProperties security = new SimpleAuthenticationProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(security, "security");
binder.bind(new MutablePropertyValues(Collections.singletonMap(
"shell.auth.simple.user.password", "${ADMIN_PASSWORD}")));
binder.bind(new MutablePropertyValues(Collections
.singletonMap("shell.auth.simple.user.password", "${ADMIN_PASSWORD}")));
assertFalse(binder.getBindingResult().hasErrors());
assertTrue(security.getUser().isDefaultPassword());
}
@ -281,8 +282,8 @@ public class ShellPropertiesTests {
public void testDefaultPasswordAutogeneratedIfEmpty() {
SimpleAuthenticationProperties security = new SimpleAuthenticationProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(security, "security");
binder.bind(new MutablePropertyValues(Collections.singletonMap(
"shell.auth.simple.user.password", "")));
binder.bind(new MutablePropertyValues(
Collections.singletonMap("shell.auth.simple.user.password", "")));
assertFalse(binder.getBindingResult().hasErrors());
assertTrue(security.getUser().isDefaultPassword());
}
@ -291,8 +292,8 @@ public class ShellPropertiesTests {
public void testBindingSpring() {
SpringAuthenticationProperties props = new SpringAuthenticationProperties();
RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell.auth.spring");
binder.bind(new MutablePropertyValues(Collections.singletonMap(
"shell.auth.spring.roles", "role1, role2")));
binder.bind(new MutablePropertyValues(
Collections.singletonMap("shell.auth.spring.roles", "role1, role2")));
assertFalse(binder.getBindingResult().hasErrors());
Properties p = new Properties();

@ -46,8 +46,8 @@ public class SpringApplicationHierarchyTests {
@Test
public void testChild() {
this.context = new SpringApplicationBuilder(Parent.class).child(Child.class).run(
"--server.port=0");
this.context = new SpringApplicationBuilder(Parent.class).child(Child.class)
.run("--server.port=0");
}
@EnableAutoConfiguration

@ -113,9 +113,8 @@ public abstract class AbstractEndpointTests<T extends Endpoint<?>> {
@Test
public void isEnabledFallbackToEnvironment() throws Exception {
this.context = new AnnotationConfigApplicationContext();
PropertySource<?> propertySource = new MapPropertySource("test",
Collections.<String, Object>singletonMap(this.property + ".enabled",
false));
PropertySource<?> propertySource = new MapPropertySource("test", Collections
.<String, Object>singletonMap(this.property + ".enabled", false));
this.context.getEnvironment().getPropertySources().addFirst(propertySource);
this.context.register(this.configClass);
this.context.refresh();
@ -126,9 +125,8 @@ public abstract class AbstractEndpointTests<T extends Endpoint<?>> {
@SuppressWarnings("rawtypes")
public void isExplicitlyEnabled() throws Exception {
this.context = new AnnotationConfigApplicationContext();
PropertySource<?> propertySource = new MapPropertySource("test",
Collections.<String, Object>singletonMap(this.property + ".enabled",
false));
PropertySource<?> propertySource = new MapPropertySource("test", Collections
.<String, Object>singletonMap(this.property + ".enabled", false));
this.context.getEnvironment().getPropertySources().addFirst(propertySource);
this.context.register(this.configClass);
this.context.refresh();

@ -38,8 +38,8 @@ import static org.mockito.Mockito.mock;
* @author Greg Turnquist
* @author Phillip Webb
*/
public class AutoConfigurationReportEndpointTests extends
AbstractEndpointTests<AutoConfigurationReportEndpoint> {
public class AutoConfigurationReportEndpointTests
extends AbstractEndpointTests<AutoConfigurationReportEndpoint> {
public AutoConfigurationReportEndpointTests() {
super(Config.class, AutoConfigurationReportEndpoint.class, "autoconfig", true,
@ -62,8 +62,8 @@ public class AutoConfigurationReportEndpointTests extends
@PostConstruct
public void setupAutoConfigurationReport() {
ConditionEvaluationReport report = ConditionEvaluationReport.get(this.context
.getBeanFactory());
ConditionEvaluationReport report = ConditionEvaluationReport
.get(this.context.getBeanFactory());
report.recordConditionEvaluation("a", mock(Condition.class),
mock(ConditionOutcome.class));
}

@ -66,8 +66,8 @@ public class ConfigurationPropertiesReportEndpointProxyTests {
public void testWithProxyClass() throws Exception {
this.context.register(Config.class, SqlExecutor.class);
this.context.refresh();
Map<String, Object> report = this.context.getBean(
ConfigurationPropertiesReportEndpoint.class).invoke();
Map<String, Object> report = this.context
.getBean(ConfigurationPropertiesReportEndpoint.class).invoke();
assertThat(report.toString(), containsString("prefix=executor.sql"));
}

@ -37,8 +37,8 @@ import static org.junit.Assert.assertThat;
*
* @author Dave Syer
*/
public class ConfigurationPropertiesReportEndpointTests extends
AbstractEndpointTests<ConfigurationPropertiesReportEndpoint> {
public class ConfigurationPropertiesReportEndpointTests
extends AbstractEndpointTests<ConfigurationPropertiesReportEndpoint> {
public ConfigurationPropertiesReportEndpointTests() {
super(Config.class, ConfigurationPropertiesReportEndpoint.class, "configprops",

@ -54,10 +54,10 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
public void testCompositeSource() throws Exception {
EnvironmentEndpoint report = getEndpointBean();
CompositePropertySource source = new CompositePropertySource("composite");
source.addPropertySource(new MapPropertySource("one", Collections.singletonMap(
"foo", (Object) "bar")));
source.addPropertySource(new MapPropertySource("two", Collections.singletonMap(
"foo", (Object) "spam")));
source.addPropertySource(new MapPropertySource("one",
Collections.singletonMap("foo", (Object) "bar")));
source.addPropertySource(new MapPropertySource("two",
Collections.singletonMap("foo", (Object) "spam")));
this.context.getEnvironment().getPropertySources().addFirst(source);
Map<String, Object> env = report.invoke();
assertEquals("bar", ((Map<String, Object>) env.get("composite:one")).get("foo"));

@ -62,8 +62,8 @@ public class MetricsEndpointTests extends AbstractEndpointTests<MetricsEndpoint>
@Test
public void ordered() {
List<PublicMetrics> publicMetrics = new ArrayList<PublicMetrics>();
publicMetrics.add(new TestPublicMetrics(2, this.metric2, this.metric2,
this.metric3));
publicMetrics
.add(new TestPublicMetrics(2, this.metric2, this.metric2, this.metric3));
publicMetrics.add(new TestPublicMetrics(1, this.metric1));
Map<String, Object> metrics = new MetricsEndpoint(publicMetrics).invoke();
Iterator<Entry<String, Object>> iterator = metrics.entrySet().iterator();

@ -52,8 +52,8 @@ public class RequestMappingEndpointTests {
mapping.setUrlMap(Collections.singletonMap("/foo", new Object()));
mapping.setApplicationContext(new StaticApplicationContext());
mapping.initApplicationContext();
this.endpoint.setHandlerMappings(Collections
.<AbstractUrlHandlerMapping>singletonList(mapping));
this.endpoint.setHandlerMappings(
Collections.<AbstractUrlHandlerMapping>singletonList(mapping));
Map<String, Object> result = this.endpoint.invoke();
assertEquals(1, result.size());
@SuppressWarnings("unchecked")
@ -113,8 +113,8 @@ public class RequestMappingEndpointTests {
Arrays.asList(new EndpointMvcAdapter(new DumpEndpoint())));
mapping.setApplicationContext(new StaticApplicationContext());
mapping.afterPropertiesSet();
this.endpoint.setMethodMappings(Collections
.<AbstractHandlerMethodMapping<?>>singletonList(mapping));
this.endpoint.setMethodMappings(
Collections.<AbstractHandlerMethodMapping<?>>singletonList(mapping));
Map<String, Object> result = this.endpoint.invoke();
assertEquals(1, result.size());
assertTrue(result.keySet().iterator().next().contains("/dump"));

@ -62,14 +62,14 @@ public class EndpointMBeanExporterTests {
this.context = new GenericApplicationContext();
this.context.registerBeanDefinition("endpointMbeanExporter",
new RootBeanDefinition(EndpointMBeanExporter.class));
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(
TestEndpoint.class));
this.context.registerBeanDefinition("endpoint1",
new RootBeanDefinition(TestEndpoint.class));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
MBeanInfo mbeanInfo = mbeanExporter.getServer().getMBeanInfo(
getObjectName("endpoint1", this.context));
MBeanInfo mbeanInfo = mbeanExporter.getServer()
.getMBeanInfo(getObjectName("endpoint1", this.context));
assertNotNull(mbeanInfo);
assertEquals(3, mbeanInfo.getOperations().length);
assertEquals(3, mbeanInfo.getAttributes().length);
@ -82,12 +82,12 @@ public class EndpointMBeanExporterTests {
new RootBeanDefinition(EndpointMBeanExporter.class));
MutablePropertyValues mvp = new MutablePropertyValues();
mvp.add("enabled", Boolean.FALSE);
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(
TestEndpoint.class, null, mvp));
this.context.registerBeanDefinition("endpoint1",
new RootBeanDefinition(TestEndpoint.class, null, mvp));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertFalse(mbeanExporter.getServer().isRegistered(
getObjectName("endpoint1", this.context)));
assertFalse(mbeanExporter.getServer()
.isRegistered(getObjectName("endpoint1", this.context)));
}
@Test
@ -97,12 +97,12 @@ public class EndpointMBeanExporterTests {
new RootBeanDefinition(EndpointMBeanExporter.class));
MutablePropertyValues mvp = new MutablePropertyValues();
mvp.add("enabled", Boolean.TRUE);
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(
TestEndpoint.class, null, mvp));
this.context.registerBeanDefinition("endpoint1",
new RootBeanDefinition(TestEndpoint.class, null, mvp));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertTrue(mbeanExporter.getServer().isRegistered(
getObjectName("endpoint1", this.context)));
assertTrue(mbeanExporter.getServer()
.isRegistered(getObjectName("endpoint1", this.context)));
}
@Test
@ -110,30 +110,29 @@ public class EndpointMBeanExporterTests {
this.context = new GenericApplicationContext();
this.context.registerBeanDefinition("endpointMbeanExporter",
new RootBeanDefinition(EndpointMBeanExporter.class));
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(
TestEndpoint.class));
this.context.registerBeanDefinition("endpoint2", new RootBeanDefinition(
TestEndpoint.class));
this.context.registerBeanDefinition("endpoint1",
new RootBeanDefinition(TestEndpoint.class));
this.context.registerBeanDefinition("endpoint2",
new RootBeanDefinition(TestEndpoint.class));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertNotNull(mbeanExporter.getServer().getMBeanInfo(
getObjectName("endpoint1", this.context)));
assertNotNull(mbeanExporter.getServer().getMBeanInfo(
getObjectName("endpoint2", this.context)));
assertNotNull(mbeanExporter.getServer()
.getMBeanInfo(getObjectName("endpoint1", this.context)));
assertNotNull(mbeanExporter.getServer()
.getMBeanInfo(getObjectName("endpoint2", this.context)));
}
@Test
public void testRegistrationWithDifferentDomain() throws Exception {
this.context = new GenericApplicationContext();
this.context.registerBeanDefinition(
"endpointMbeanExporter",
this.context.registerBeanDefinition("endpointMbeanExporter",
new RootBeanDefinition(EndpointMBeanExporter.class, null,
new MutablePropertyValues(Collections.singletonMap("domain",
"test-domain"))));
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(
TestEndpoint.class));
new MutablePropertyValues(
Collections.singletonMap("domain", "test-domain"))));
this.context.registerBeanDefinition("endpoint1",
new RootBeanDefinition(TestEndpoint.class));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
@ -151,8 +150,8 @@ public class EndpointMBeanExporterTests {
this.context.registerBeanDefinition("endpointMbeanExporter",
new RootBeanDefinition(EndpointMBeanExporter.class, null,
new MutablePropertyValues(properties)));
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(
TestEndpoint.class));
this.context.registerBeanDefinition("endpoint1",
new RootBeanDefinition(TestEndpoint.class));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
@ -175,16 +174,16 @@ public class EndpointMBeanExporterTests {
this.context.registerBeanDefinition("endpointMbeanExporter",
new RootBeanDefinition(EndpointMBeanExporter.class, null,
new MutablePropertyValues(properties)));
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(
TestEndpoint.class));
this.context.registerBeanDefinition("endpoint1",
new RootBeanDefinition(TestEndpoint.class));
this.context.refresh();
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertNotNull(mbeanExporter.getServer().getMBeanInfo(
ObjectNameManager.getInstance(getObjectName("test-domain", "endpoint1",
true, this.context).toString()
+ ",key1=value1,key2=value2")));
assertNotNull(mbeanExporter.getServer()
.getMBeanInfo(ObjectNameManager.getInstance(
getObjectName("test-domain", "endpoint1", true, this.context)
.toString() + ",key1=value1,key2=value2")));
}
@Test
@ -192,8 +191,8 @@ public class EndpointMBeanExporterTests {
this.context = new GenericApplicationContext();
this.context.registerBeanDefinition("endpointMbeanExporter",
new RootBeanDefinition(EndpointMBeanExporter.class));
this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(
TestEndpoint.class));
this.context.registerBeanDefinition("endpoint1",
new RootBeanDefinition(TestEndpoint.class));
GenericApplicationContext parent = new GenericApplicationContext();
this.context.setParent(parent);
@ -202,8 +201,8 @@ public class EndpointMBeanExporterTests {
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertNotNull(mbeanExporter.getServer().getMBeanInfo(
getObjectName("endpoint1", this.context)));
assertNotNull(mbeanExporter.getServer()
.getMBeanInfo(getObjectName("endpoint1", this.context)));
parent.close();
}
@ -215,17 +214,15 @@ public class EndpointMBeanExporterTests {
private ObjectName getObjectName(String domain, String beanKey,
boolean includeIdentity, ApplicationContext applicationContext)
throws MalformedObjectNameException {
throws MalformedObjectNameException {
if (includeIdentity) {
return ObjectNameManager
.getInstance(String.format("%s:type=Endpoint,name=%s,identity=%s",
domain, beanKey, ObjectUtils
.getIdentityHexString(applicationContext
.getBean(beanKey))));
return ObjectNameManager.getInstance(String.format(
"%s:type=Endpoint,name=%s,identity=%s", domain, beanKey, ObjectUtils
.getIdentityHexString(applicationContext.getBean(beanKey))));
}
else {
return ObjectNameManager.getInstance(String.format(
"%s:type=Endpoint,name=%s", domain, beanKey));
return ObjectNameManager.getInstance(
String.format("%s:type=Endpoint,name=%s", domain, beanKey));
}
}

@ -56,15 +56,15 @@ public class EndpointHandlerMappingTests {
public void withoutPrefix() throws Exception {
TestMvcEndpoint endpointA = new TestMvcEndpoint(new TestEndpoint("/a"));
TestMvcEndpoint endpointB = new TestMvcEndpoint(new TestEndpoint("/b"));
EndpointHandlerMapping mapping = new EndpointHandlerMapping(Arrays.asList(
endpointA, endpointB));
EndpointHandlerMapping mapping = new EndpointHandlerMapping(
Arrays.asList(endpointA, endpointB));
mapping.setApplicationContext(this.context);
mapping.afterPropertiesSet();
assertThat(mapping.getHandler(new MockHttpServletRequest("GET", "/a"))
.getHandler(),
assertThat(
mapping.getHandler(new MockHttpServletRequest("GET", "/a")).getHandler(),
equalTo((Object) new HandlerMethod(endpointA, this.method)));
assertThat(mapping.getHandler(new MockHttpServletRequest("GET", "/b"))
.getHandler(),
assertThat(
mapping.getHandler(new MockHttpServletRequest("GET", "/b")).getHandler(),
equalTo((Object) new HandlerMethod(endpointB, this.method)));
assertThat(mapping.getHandler(new MockHttpServletRequest("GET", "/c")),
nullValue());
@ -74,16 +74,18 @@ public class EndpointHandlerMappingTests {
public void withPrefix() throws Exception {
TestMvcEndpoint endpointA = new TestMvcEndpoint(new TestEndpoint("/a"));
TestMvcEndpoint endpointB = new TestMvcEndpoint(new TestEndpoint("/b"));
EndpointHandlerMapping mapping = new EndpointHandlerMapping(Arrays.asList(
endpointA, endpointB));
EndpointHandlerMapping mapping = new EndpointHandlerMapping(
Arrays.asList(endpointA, endpointB));
mapping.setApplicationContext(this.context);
mapping.setPrefix("/a");
mapping.afterPropertiesSet();
assertThat(mapping.getHandler(new MockHttpServletRequest("GET", "/a/a"))
.getHandler(),
assertThat(
mapping.getHandler(new MockHttpServletRequest("GET", "/a/a"))
.getHandler(),
equalTo((Object) new HandlerMethod(endpointA, this.method)));
assertThat(mapping.getHandler(new MockHttpServletRequest("GET", "/a/b"))
.getHandler(),
assertThat(
mapping.getHandler(new MockHttpServletRequest("GET", "/a/b"))
.getHandler(),
equalTo((Object) new HandlerMethod(endpointB, this.method)));
assertThat(mapping.getHandler(new MockHttpServletRequest("GET", "/a")),
nullValue());
@ -137,8 +139,8 @@ public class EndpointHandlerMappingTests {
public void duplicatePath() throws Exception {
TestMvcEndpoint endpoint = new TestMvcEndpoint(new TestEndpoint("/a"));
TestActionEndpoint other = new TestActionEndpoint(new TestEndpoint("/a"));
EndpointHandlerMapping mapping = new EndpointHandlerMapping(Arrays.asList(
endpoint, other));
EndpointHandlerMapping mapping = new EndpointHandlerMapping(
Arrays.asList(endpoint, other));
mapping.setDisabled(true);
mapping.setApplicationContext(this.context);
mapping.afterPropertiesSet();

@ -63,8 +63,8 @@ public class EnvironmentMvcEndpointTests {
public void setUp() {
this.context.getBean(EnvironmentEndpoint.class).setEnabled(true);
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
EnvironmentTestUtils.addEnvironment(
(ConfigurableApplicationContext) this.context, "foo:bar");
EnvironmentTestUtils.addEnvironment((ConfigurableApplicationContext) this.context,
"foo:bar");
}
@Test

@ -93,10 +93,10 @@ public class HealthMvcEndpointTests {
@SuppressWarnings("unchecked")
@Test
public void customMapping() {
given(this.endpoint.invoke()).willReturn(
new Health.Builder().status("OK").build());
this.mvc.setStatusMapping(Collections.singletonMap("OK",
HttpStatus.INTERNAL_SERVER_ERROR));
given(this.endpoint.invoke())
.willReturn(new Health.Builder().status("OK").build());
this.mvc.setStatusMapping(
Collections.singletonMap("OK", HttpStatus.INTERNAL_SERVER_ERROR));
Object result = this.mvc.invoke(null);
assertTrue(result instanceof ResponseEntity);
ResponseEntity<Health> response = (ResponseEntity<Health>) result;
@ -106,8 +106,8 @@ public class HealthMvcEndpointTests {
@Test
public void secure() {
given(this.endpoint.invoke()).willReturn(
new Health.Builder().up().withDetail("foo", "bar").build());
given(this.endpoint.invoke())
.willReturn(new Health.Builder().up().withDetail("foo", "bar").build());
given(this.endpoint.isSensitive()).willReturn(false);
Object result = this.mvc.invoke(this.user);
assertTrue(result instanceof Health);
@ -119,8 +119,8 @@ public class HealthMvcEndpointTests {
public void healthIsCached() {
given(this.endpoint.getTimeToLive()).willReturn(10000L);
given(this.endpoint.isSensitive()).willReturn(true);
given(this.endpoint.invoke()).willReturn(
new Health.Builder().up().withDetail("foo", "bar").build());
given(this.endpoint.invoke())
.willReturn(new Health.Builder().up().withDetail("foo", "bar").build());
Object result = this.mvc.invoke(this.user);
assertTrue(result instanceof Health);
Health health = (Health) result;
@ -140,8 +140,8 @@ public class HealthMvcEndpointTests {
@Test
public void unsecureAnonymousAccessUnrestricted() {
this.environment.getPropertySources().addLast(NON_SENSITIVE);
given(this.endpoint.invoke()).willReturn(
new Health.Builder().up().withDetail("foo", "bar").build());
given(this.endpoint.invoke())
.willReturn(new Health.Builder().up().withDetail("foo", "bar").build());
Object result = this.mvc.invoke(null);
assertTrue(result instanceof Health);
assertTrue(((Health) result).getStatus() == Status.UP);
@ -151,8 +151,8 @@ public class HealthMvcEndpointTests {
@Test
public void noCachingWhenTimeToLiveIsZero() {
given(this.endpoint.getTimeToLive()).willReturn(0L);
given(this.endpoint.invoke()).willReturn(
new Health.Builder().up().withDetail("foo", "bar").build());
given(this.endpoint.invoke())
.willReturn(new Health.Builder().up().withDetail("foo", "bar").build());
Object result = this.mvc.invoke(null);
assertTrue(result instanceof Health);
assertTrue(((Health) result).getStatus() == Status.UP);
@ -167,8 +167,8 @@ public class HealthMvcEndpointTests {
public void newValueIsReturnedOnceTtlExpires() throws InterruptedException {
given(this.endpoint.getTimeToLive()).willReturn(50L);
given(this.endpoint.isSensitive()).willReturn(false);
given(this.endpoint.invoke()).willReturn(
new Health.Builder().up().withDetail("foo", "bar").build());
given(this.endpoint.invoke())
.willReturn(new Health.Builder().up().withDetail("foo", "bar").build());
Object result = this.mvc.invoke(null);
assertTrue(result instanceof Health);
assertTrue(((Health) result).getStatus() == Status.UP);

@ -49,7 +49,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
* @author Dave Syer
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = { Config.class }, initializers = ContextPathListener.class)
@SpringApplicationConfiguration(classes = {
Config.class }, initializers = ContextPathListener.class)
@WebAppConfiguration
public class JolokiaMvcEndpointContextPathTests {
@ -64,8 +65,8 @@ public class JolokiaMvcEndpointContextPathTests {
@Before
public void setUp() {
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
EnvironmentTestUtils.addEnvironment(
(ConfigurableApplicationContext) this.context, "foo:bar");
EnvironmentTestUtils.addEnvironment((ConfigurableApplicationContext) this.context,
"foo:bar");
}
@Test
@ -83,8 +84,8 @@ public class JolokiaMvcEndpointContextPathTests {
public static class Config {
}
public static class ContextPathListener implements
ApplicationContextInitializer<ConfigurableApplicationContext> {
public static class ContextPathListener
implements ApplicationContextInitializer<ConfigurableApplicationContext> {
@Override
public void initialize(ConfigurableApplicationContext context) {
EnvironmentTestUtils.addEnvironment(context, "management.contextPath:/admin");

@ -68,8 +68,8 @@ public class JolokiaMvcEndpointTests {
@Before
public void setUp() {
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
EnvironmentTestUtils.addEnvironment(
(ConfigurableApplicationContext) this.context, "foo:bar");
EnvironmentTestUtils.addEnvironment((ConfigurableApplicationContext) this.context,
"foo:bar");
}
@Test

@ -55,12 +55,12 @@ public class CompositeHealthIndicatorTests {
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
given(this.one.health()).willReturn(
new Health.Builder().unknown().withDetail("1", "1").build());
given(this.two.health()).willReturn(
new Health.Builder().unknown().withDetail("2", "2").build());
given(this.three.health()).willReturn(
new Health.Builder().unknown().withDetail("3", "3").build());
given(this.one.health())
.willReturn(new Health.Builder().unknown().withDetail("1", "1").build());
given(this.two.health())
.willReturn(new Health.Builder().unknown().withDetail("2", "2").build());
given(this.three.health())
.willReturn(new Health.Builder().unknown().withDetail("3", "3").build());
this.healthAggregator = new OrderedHealthAggregator();
}
@ -74,16 +74,10 @@ public class CompositeHealthIndicatorTests {
this.healthAggregator, indicators);
Health result = composite.health();
assertThat(result.getDetails().size(), equalTo(2));
assertThat(
result.getDetails(),
hasEntry("one",
(Object) new Health.Builder().unknown().withDetail("1", "1")
.build()));
assertThat(
result.getDetails(),
hasEntry("two",
(Object) new Health.Builder().unknown().withDetail("2", "2")
.build()));
assertThat(result.getDetails(), hasEntry("one",
(Object) new Health.Builder().unknown().withDetail("1", "1").build()));
assertThat(result.getDetails(), hasEntry("two",
(Object) new Health.Builder().unknown().withDetail("2", "2").build()));
}
@Test
@ -96,21 +90,12 @@ public class CompositeHealthIndicatorTests {
composite.addHealthIndicator("three", this.three);
Health result = composite.health();
assertThat(result.getDetails().size(), equalTo(3));
assertThat(
result.getDetails(),
hasEntry("one",
(Object) new Health.Builder().unknown().withDetail("1", "1")
.build()));
assertThat(
result.getDetails(),
hasEntry("two",
(Object) new Health.Builder().unknown().withDetail("2", "2")
.build()));
assertThat(
result.getDetails(),
hasEntry("three",
(Object) new Health.Builder().unknown().withDetail("3", "3")
.build()));
assertThat(result.getDetails(), hasEntry("one",
(Object) new Health.Builder().unknown().withDetail("1", "1").build()));
assertThat(result.getDetails(), hasEntry("two",
(Object) new Health.Builder().unknown().withDetail("2", "2").build()));
assertThat(result.getDetails(), hasEntry("three",
(Object) new Health.Builder().unknown().withDetail("3", "3").build()));
}
@Test
@ -121,16 +106,10 @@ public class CompositeHealthIndicatorTests {
composite.addHealthIndicator("two", this.two);
Health result = composite.health();
assertThat(result.getDetails().size(), equalTo(2));
assertThat(
result.getDetails(),
hasEntry("one",
(Object) new Health.Builder().unknown().withDetail("1", "1")
.build()));
assertThat(
result.getDetails(),
hasEntry("two",
(Object) new Health.Builder().unknown().withDetail("2", "2")
.build()));
assertThat(result.getDetails(), hasEntry("one",
(Object) new Health.Builder().unknown().withDetail("1", "1").build()));
assertThat(result.getDetails(), hasEntry("two",
(Object) new Health.Builder().unknown().withDetail("2", "2").build()));
}
@Test
@ -147,9 +126,10 @@ public class CompositeHealthIndicatorTests {
Health result = composite.health();
ObjectMapper mapper = new ObjectMapper();
assertEquals("{\"status\":\"UNKNOWN\",\"db\":{\"status\":\"UNKNOWN\""
+ ",\"db1\":{\"status\":\"UNKNOWN\",\"1\":\"1\"},"
+ "\"db2\":{\"status\":\"UNKNOWN\",\"2\":\"2\"}}}",
assertEquals(
"{\"status\":\"UNKNOWN\",\"db\":{\"status\":\"UNKNOWN\""
+ ",\"db1\":{\"status\":\"UNKNOWN\",\"1\":\"1\"},"
+ "\"db2\":{\"status\":\"UNKNOWN\",\"2\":\"2\"}}}",
mapper.writeValueAsString(result));
}

@ -88,8 +88,8 @@ public class DataSourceHealthIndicatorTests {
public void connectionClosed() throws Exception {
DataSource dataSource = mock(DataSource.class);
Connection connection = mock(Connection.class);
given(connection.getMetaData()).willReturn(
this.dataSource.getConnection().getMetaData());
given(connection.getMetaData())
.willReturn(this.dataSource.getConnection().getMetaData());
given(dataSource.getConnection()).willReturn(connection);
this.indicator.setDataSource(dataSource);
Health health = this.indicator.health();

@ -51,8 +51,8 @@ public class DiskSpaceHealthIndicatorTests {
public void setUp() throws Exception {
given(this.fileMock.exists()).willReturn(true);
given(this.fileMock.canRead()).willReturn(true);
this.healthIndicator = new DiskSpaceHealthIndicator(createProperties(
this.fileMock, THRESHOLD_BYTES));
this.healthIndicator = new DiskSpaceHealthIndicator(
createProperties(this.fileMock, THRESHOLD_BYTES));
}
@Test
@ -73,7 +73,8 @@ public class DiskSpaceHealthIndicatorTests {
assertEquals(THRESHOLD_BYTES - 10, health.getDetails().get("free"));
}
private DiskSpaceHealthIndicatorProperties createProperties(File path, long threshold) {
private DiskSpaceHealthIndicatorProperties createProperties(File path,
long threshold) {
DiskSpaceHealthIndicatorProperties properties = new DiskSpaceHealthIndicatorProperties();
properties.setPath(path);
properties.setThreshold(threshold);

@ -83,8 +83,8 @@ public class MongoHealthIndicatorTests {
@Test
public void mongoIsDown() throws Exception {
MongoTemplate mongoTemplate = mock(MongoTemplate.class);
given(mongoTemplate.executeCommand("{ buildInfo: 1 }")).willThrow(
new MongoException("Connection failed"));
given(mongoTemplate.executeCommand("{ buildInfo: 1 }"))
.willThrow(new MongoException("Connection failed"));
MongoHealthIndicator healthIndicator = new MongoHealthIndicator(mongoTemplate);
Health health = healthIndicator.health();

@ -58,7 +58,8 @@ public class OrderedHealthAggregatorTests {
healths.put("h2", new Health.Builder().status(Status.UP).build());
healths.put("h3", new Health.Builder().status(Status.UNKNOWN).build());
healths.put("h4", new Health.Builder().status(Status.OUT_OF_SERVICE).build());
assertEquals(Status.UNKNOWN, this.healthAggregator.aggregate(healths).getStatus());
assertEquals(Status.UNKNOWN,
this.healthAggregator.aggregate(healths).getStatus());
}
@Test
@ -74,8 +75,8 @@ public class OrderedHealthAggregatorTests {
@Test
public void customOrderWithCustomStatus() {
this.healthAggregator.setStatusOrder(Arrays.asList("DOWN", "OUT_OF_SERVICE",
"UP", "UNKNOWN", "CUSTOM"));
this.healthAggregator.setStatusOrder(
Arrays.asList("DOWN", "OUT_OF_SERVICE", "UP", "UNKNOWN", "CUSTOM"));
Map<String, Health> healths = new HashMap<String, Health>();
healths.put("h1", new Health.Builder().status(Status.DOWN).build());
healths.put("h2", new Health.Builder().status(Status.UP).build());

@ -47,9 +47,8 @@ public class RabbitHealthIndicatorTests {
@Test
public void indicatorExists() {
this.context = new AnnotationConfigApplicationContext(
PropertyPlaceholderAutoConfiguration.class,
RabbitAutoConfiguration.class, EndpointAutoConfiguration.class,
HealthIndicatorAutoConfiguration.class);
PropertyPlaceholderAutoConfiguration.class, RabbitAutoConfiguration.class,
EndpointAutoConfiguration.class, HealthIndicatorAutoConfiguration.class);
assertEquals(1, this.context.getBeanNamesForType(RabbitAdmin.class).length);
RabbitHealthIndicator healthIndicator = this.context
.getBean(RabbitHealthIndicator.class);

@ -70,7 +70,8 @@ public class RedisHealthIndicatorTests {
info.put("redis_version", "2.8.9");
RedisConnection redisConnection = mock(RedisConnection.class);
RedisConnectionFactory redisConnectionFactory = mock(RedisConnectionFactory.class);
RedisConnectionFactory redisConnectionFactory = mock(
RedisConnectionFactory.class);
given(redisConnectionFactory.getConnection()).willReturn(redisConnection);
given(redisConnection.info()).willReturn(info);
RedisHealthIndicator healthIndicator = new RedisHealthIndicator(
@ -87,10 +88,11 @@ public class RedisHealthIndicatorTests {
@Test
public void redisIsDown() throws Exception {
RedisConnection redisConnection = mock(RedisConnection.class);
RedisConnectionFactory redisConnectionFactory = mock(RedisConnectionFactory.class);
RedisConnectionFactory redisConnectionFactory = mock(
RedisConnectionFactory.class);
given(redisConnectionFactory.getConnection()).willReturn(redisConnection);
given(redisConnection.info()).willThrow(
new RedisConnectionFailureException("Connection failed"));
given(redisConnection.info())
.willThrow(new RedisConnectionFailureException("Connection failed"));
RedisHealthIndicator healthIndicator = new RedisHealthIndicator(
redisConnectionFactory);

@ -42,7 +42,8 @@ public class RedisMetricRepositoryTests {
@Before
public void init() {
this.prefix = "spring.test." + System.currentTimeMillis();
this.repository = new RedisMetricRepository(this.redis.getResource(), this.prefix);
this.repository = new RedisMetricRepository(this.redis.getResource(),
this.prefix);
}
@After
@ -51,8 +52,8 @@ public class RedisMetricRepositoryTests {
.get(this.prefix + ".foo"));
this.repository.reset("foo");
this.repository.reset("bar");
assertNull(new StringRedisTemplate(this.redis.getResource()).opsForValue().get(
this.prefix + ".foo"));
assertNull(new StringRedisTemplate(this.redis.getResource()).opsForValue()
.get(this.prefix + ".foo"));
}
@Test

@ -72,14 +72,14 @@ public class RedisMultiMetricRepositoryTests {
@After
public void clear() {
assertTrue(new StringRedisTemplate(this.redis.getResource()).opsForZSet().size(
"keys." + this.prefix) > 0);
assertTrue(new StringRedisTemplate(this.redis.getResource()).opsForZSet()
.size("keys." + this.prefix) > 0);
this.repository.reset("foo");
this.repository.reset("bar");
assertNull(new StringRedisTemplate(this.redis.getResource()).opsForValue().get(
this.prefix + ".foo"));
assertNull(new StringRedisTemplate(this.redis.getResource()).opsForValue().get(
this.prefix + ".bar"));
assertNull(new StringRedisTemplate(this.redis.getResource()).opsForValue()
.get(this.prefix + ".foo"));
assertNull(new StringRedisTemplate(this.redis.getResource()).opsForValue()
.get(this.prefix + ".bar"));
}
@Test
@ -88,23 +88,26 @@ public class RedisMultiMetricRepositoryTests {
Arrays.<Metric<?>>asList(new Metric<Number>("foo.bar", 12.3)));
this.repository.set("foo",
Arrays.<Metric<?>>asList(new Metric<Number>("foo.bar", 15.3)));
assertEquals(15.3, Iterables.collection(this.repository.findAll("foo"))
.iterator().next().getValue());
assertEquals(15.3, Iterables.collection(this.repository.findAll("foo")).iterator()
.next().getValue());
}
@Test
public void setAndGetMultiple() {
this.repository.set("foo", Arrays.<Metric<?>>asList(new Metric<Number>("foo.val",
12.3), new Metric<Number>("foo.bar", 11.3)));
this.repository.set("foo",
Arrays.<Metric<?>>asList(new Metric<Number>("foo.val", 12.3),
new Metric<Number>("foo.bar", 11.3)));
assertEquals(2, Iterables.collection(this.repository.findAll("foo")).size());
}
@Test
public void groups() {
this.repository.set("foo", Arrays.<Metric<?>>asList(new Metric<Number>("foo.val",
12.3), new Metric<Number>("foo.bar", 11.3)));
this.repository.set("bar", Arrays.<Metric<?>>asList(new Metric<Number>("bar.val",
12.3), new Metric<Number>("bar.foo", 11.3)));
this.repository.set("foo",
Arrays.<Metric<?>>asList(new Metric<Number>("foo.val", 12.3),
new Metric<Number>("foo.bar", 11.3)));
this.repository.set("bar",
Arrays.<Metric<?>>asList(new Metric<Number>("bar.val", 12.3),
new Metric<Number>("bar.foo", 11.3)));
Collection<String> groups = Iterables.collection(this.repository.groups());
assertEquals(2, groups.size());
assertTrue("Wrong groups: " + groups, groups.contains("foo"));
@ -112,10 +115,12 @@ public class RedisMultiMetricRepositoryTests {
@Test
public void count() {
this.repository.set("foo", Arrays.<Metric<?>>asList(new Metric<Number>("foo.val",
12.3), new Metric<Number>("foo.bar", 11.3)));
this.repository.set("bar", Arrays.<Metric<?>>asList(new Metric<Number>("bar.val",
12.3), new Metric<Number>("bar.foo", 11.3)));
this.repository.set("foo",
Arrays.<Metric<?>>asList(new Metric<Number>("foo.val", 12.3),
new Metric<Number>("foo.bar", 11.3)));
this.repository.set("bar",
Arrays.<Metric<?>>asList(new Metric<Number>("bar.val", 12.3),
new Metric<Number>("bar.foo", 11.3)));
assertEquals(2, this.repository.countGroups());
}

@ -97,9 +97,10 @@ public class RedisServer implements TestRule {
@Override
public void evaluate() throws Throwable {
Assume.assumeTrue("Skipping test due to "
+ RedisServer.this.resourceDescription
+ " not being available", false);
Assume.assumeTrue(
"Skipping test due to " + RedisServer.this.resourceDescription
+ " not being available",
false);
}
};
}

@ -35,7 +35,8 @@ public class MultiMetricRichGaugeReaderTests {
private MultiMetricRichGaugeReader reader = new MultiMetricRichGaugeReader(
this.repository);
private InMemoryRichGaugeRepository data = new InMemoryRichGaugeRepository();
private RichGaugeExporter exporter = new RichGaugeExporter(this.data, this.repository);
private RichGaugeExporter exporter = new RichGaugeExporter(this.data,
this.repository);
@Test
public void countOne() {

@ -74,7 +74,8 @@ public class InMemoryRepositoryTests {
this.repository.set("foo.bar", "one");
this.repository.set("foo.min", "two");
this.repository.set("foo.max", "three");
assertEquals(3, ((Collection<?>) this.repository.findAllWithPrefix("foo")).size());
assertEquals(3,
((Collection<?>) this.repository.findAllWithPrefix("foo")).size());
}
@Test

@ -54,8 +54,8 @@ public class MessageChannelMetricWriterTests {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
MessageChannelMetricWriterTests.this.handler.handleMessage(invocation
.getArgumentAt(0, Message.class));
MessageChannelMetricWriterTests.this.handler
.handleMessage(invocation.getArgumentAt(0, Message.class));
return true;
}

@ -39,7 +39,8 @@ public class AuthenticationAuditListenerTests {
private final AuthenticationAuditListener listener = new AuthenticationAuditListener();
private final ApplicationEventPublisher publisher = mock(ApplicationEventPublisher.class);
private final ApplicationEventPublisher publisher = mock(
ApplicationEventPublisher.class);
@Before
public void init() {
@ -64,9 +65,9 @@ public class AuthenticationAuditListenerTests {
@Test
public void testAuthenticationSwitch() {
this.listener.onApplicationEvent(new AuthenticationSwitchUserEvent(
new UsernamePasswordAuthenticationToken("user", "password"), new User(
"user", "password", AuthorityUtils
.commaSeparatedStringToAuthorityList("USER"))));
new UsernamePasswordAuthenticationToken("user", "password"),
new User("user", "password",
AuthorityUtils.commaSeparatedStringToAuthorityList("USER"))));
verify(this.publisher).publishEvent((ApplicationEvent) anyObject());
}

@ -39,7 +39,8 @@ public class AuthorizationAuditListenerTests {
private final AuthorizationAuditListener listener = new AuthorizationAuditListener();
private final ApplicationEventPublisher publisher = mock(ApplicationEventPublisher.class);
private final ApplicationEventPublisher publisher = mock(
ApplicationEventPublisher.class);
@Before
public void init() {
@ -48,8 +49,8 @@ public class AuthorizationAuditListenerTests {
@Test
public void testAuthenticationSuccess() {
this.listener.onApplicationEvent(new AuthorizationFailureEvent(this, Arrays
.<ConfigAttribute>asList(new SecurityConfig("USER")),
this.listener.onApplicationEvent(new AuthorizationFailureEvent(this,
Arrays.<ConfigAttribute>asList(new SecurityConfig("USER")),
new UsernamePasswordAuthenticationToken("user", "password"),
new AccessDeniedException("Bad user")));
verify(this.publisher).publishEvent((ApplicationEvent) anyObject());

@ -68,7 +68,8 @@ public class ApplicationPidFileWriterTests {
File file = this.temporaryFolder.newFile();
ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file);
listener.onApplicationEvent(EVENT);
assertThat(FileCopyUtils.copyToString(new FileReader(file)), not(isEmptyString()));
assertThat(FileCopyUtils.copyToString(new FileReader(file)),
not(isEmptyString()));
}
@Test
@ -89,13 +90,15 @@ public class ApplicationPidFileWriterTests {
MockPropertySource propertySource = new MockPropertySource();
propertySource.setProperty("spring.pidfile", file.getAbsolutePath());
environment.getPropertySources().addLast(propertySource);
ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
ConfigurableApplicationContext context = mock(
ConfigurableApplicationContext.class);
given(context.getEnvironment()).willReturn(environment);
ApplicationPreparedEvent event = new ApplicationPreparedEvent(
new SpringApplication(), new String[] {}, context);
ApplicationPidFileWriter listener = new ApplicationPidFileWriter();
listener.onApplicationEvent(event);
assertThat(FileCopyUtils.copyToString(new FileReader(file)), not(isEmptyString()));
assertThat(FileCopyUtils.copyToString(new FileReader(file)),
not(isEmptyString()));
}
@Test
@ -112,7 +115,8 @@ public class ApplicationPidFileWriterTests {
assertThat(FileCopyUtils.copyToString(new FileReader(file)), isEmptyString());
listener.setTriggerEventType(ApplicationEnvironmentPreparedEvent.class);
listener.onApplicationEvent(event);
assertThat(FileCopyUtils.copyToString(new FileReader(file)), not(isEmptyString()));
assertThat(FileCopyUtils.copyToString(new FileReader(file)),
not(isEmptyString()));
}
@Test
@ -120,9 +124,10 @@ public class ApplicationPidFileWriterTests {
File file = this.temporaryFolder.newFile();
ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file);
listener.setTriggerEventType(ApplicationStartedEvent.class);
listener.onApplicationEvent(new ApplicationStartedEvent(new SpringApplication(),
new String[] {}));
assertThat(FileCopyUtils.copyToString(new FileReader(file)), not(isEmptyString()));
listener.onApplicationEvent(
new ApplicationStartedEvent(new SpringApplication(), new String[] {}));
assertThat(FileCopyUtils.copyToString(new FileReader(file)),
not(isEmptyString()));
}
}

@ -70,8 +70,8 @@ public class EmbeddedServerPortFileWriterTests {
System.setProperty("PORTFILE", this.temporaryFolder.newFile().getAbsolutePath());
EmbeddedServerPortFileWriter listener = new EmbeddedServerPortFileWriter(file);
listener.onApplicationEvent(mockEvent("", 8080));
assertThat(FileCopyUtils.copyToString(new FileReader(System
.getProperty("PORTFILE"))), equalTo("8080"));
assertThat(FileCopyUtils.copyToString(
new FileReader(System.getProperty("PORTFILE"))), equalTo("8080"));
}
@Test
@ -86,8 +86,10 @@ public class EmbeddedServerPortFileWriterTests {
- StringUtils.getFilenameExtension(managementFile).length() - 1);
managementFile = managementFile + "-management."
+ StringUtils.getFilenameExtension(file.getName());
assertThat(FileCopyUtils.copyToString(new FileReader(new File(file
.getParentFile(), managementFile))), equalTo("9090"));
assertThat(
FileCopyUtils.copyToString(
new FileReader(new File(file.getParentFile(), managementFile))),
equalTo("9090"));
assertThat(collectFileNames(file.getParentFile()), hasItem(managementFile));
}
@ -102,13 +104,16 @@ public class EmbeddedServerPortFileWriterTests {
- StringUtils.getFilenameExtension(managementFile).length() - 1);
managementFile = managementFile + "-MANAGEMENT."
+ StringUtils.getFilenameExtension(file.getName());
assertThat(FileCopyUtils.copyToString(new FileReader(new File(file
.getParentFile(), managementFile))), equalTo("9090"));
assertThat(
FileCopyUtils.copyToString(
new FileReader(new File(file.getParentFile(), managementFile))),
equalTo("9090"));
assertThat(collectFileNames(file.getParentFile()), hasItem(managementFile));
}
private EmbeddedServletContainerInitializedEvent mockEvent(String name, int port) {
EmbeddedWebApplicationContext applicationContext = mock(EmbeddedWebApplicationContext.class);
EmbeddedWebApplicationContext applicationContext = mock(
EmbeddedWebApplicationContext.class);
EmbeddedServletContainer source = mock(EmbeddedServletContainer.class);
given(applicationContext.getNamespace()).willReturn(name);
given(source.getPort()).willReturn(port);

@ -56,8 +56,8 @@ public class WebRequestTraceFilterTests {
this.filter.enhanceTrace(trace, response);
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) trace.get("headers");
assertEquals("{Content-Type=application/json, status=200}", map.get("response")
.toString());
assertEquals("{Content-Type=application/json, status=200}",
map.get("response").toString());
}
@Test
@ -80,8 +80,8 @@ public class WebRequestTraceFilterTests {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
MockHttpServletResponse response = new MockHttpServletResponse();
response.setStatus(500);
request.setAttribute("javax.servlet.error.exception", new IllegalStateException(
"Foo"));
request.setAttribute("javax.servlet.error.exception",
new IllegalStateException("Foo"));
response.addHeader("Content-Type", "application/json");
Map<String, Object> trace = this.filter.getTrace(request);
this.filter.enhanceTrace(trace, response);

@ -110,8 +110,8 @@ public abstract class AutoConfigurationPackages {
private static String[] addBasePackages(
ConstructorArgumentValues constructorArguments, String[] packageNames) {
String[] existing = (String[]) constructorArguments.getIndexedArgumentValue(0,
String[].class).getValue();
String[] existing = (String[]) constructorArguments
.getIndexedArgumentValue(0, String[].class).getValue();
Set<String> merged = new LinkedHashSet<String>();
merged.addAll(Arrays.asList(existing));
merged.addAll(Arrays.asList(packageNames));

@ -156,8 +156,8 @@ class AutoConfigurationSorter {
}
private Set<String> getAnnotationValue(Class<?> annotation) {
Map<String, Object> attributes = this.metadata.getAnnotationAttributes(
annotation.getName(), true);
Map<String, Object> attributes = this.metadata
.getAnnotationAttributes(annotation.getName(), true);
if (attributes == null) {
return Collections.emptySet();
}

@ -42,8 +42,8 @@ import org.springframework.util.Assert;
* @see EnableAutoConfiguration
*/
@Order(Ordered.LOWEST_PRECEDENCE)
class EnableAutoConfigurationImportSelector implements DeferredImportSelector,
BeanClassLoaderAware, ResourceLoaderAware {
class EnableAutoConfigurationImportSelector
implements DeferredImportSelector, BeanClassLoaderAware, ResourceLoaderAware {
private ClassLoader beanClassLoader;
@ -52,18 +52,19 @@ class EnableAutoConfigurationImportSelector implements DeferredImportSelector,
@Override
public String[] selectImports(AnnotationMetadata metadata) {
try {
AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata
.getAnnotationAttributes(EnableAutoConfiguration.class.getName(),
true));
AnnotationAttributes attributes = AnnotationAttributes
.fromMap(metadata.getAnnotationAttributes(
EnableAutoConfiguration.class.getName(), true));
Assert.notNull(attributes, "No auto-configuration attributes found. Is "
+ metadata.getClassName()
+ " annotated with @EnableAutoConfiguration?");
Assert.notNull(attributes,
"No auto-configuration attributes found. Is "
+ metadata.getClassName()
+ " annotated with @EnableAutoConfiguration?");
// Find all possible auto configuration classes, filtering duplicates
List<String> factories = new ArrayList<String>(new LinkedHashSet<String>(
SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class,
this.beanClassLoader)));
List<String> factories = new ArrayList<String>(
new LinkedHashSet<String>(SpringFactoriesLoader.loadFactoryNames(
EnableAutoConfiguration.class, this.beanClassLoader)));
// Remove those specifically disabled
factories.removeAll(Arrays.asList(attributes.getStringArray("exclude")));

@ -81,8 +81,8 @@ public class MessageSourceAutoConfiguration {
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
if (StringUtils.hasText(this.basename)) {
messageSource
.setBasenames(commaDelimitedListToStringArray(trimAllWhitespace(this.basename)));
messageSource.setBasenames(
commaDelimitedListToStringArray(trimAllWhitespace(this.basename)));
}
messageSource.setDefaultEncoding(this.encoding);
messageSource.setCacheSeconds(this.cacheSeconds);
@ -120,8 +120,8 @@ public class MessageSourceAutoConfiguration {
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
String basename = context.getEnvironment().getProperty(
"spring.messages.basename", "messages");
String basename = context.getEnvironment()
.getProperty("spring.messages.basename", "messages");
ConditionOutcome outcome = cache.get(basename);
if (outcome == null) {
outcome = getMatchOutcomeForBasename(context, basename);
@ -132,7 +132,8 @@ public class MessageSourceAutoConfiguration {
private ConditionOutcome getMatchOutcomeForBasename(ConditionContext context,
String basename) {
for (String name : commaDelimitedListToStringArray(trimAllWhitespace(basename))) {
for (String name : commaDelimitedListToStringArray(
trimAllWhitespace(basename))) {
for (Resource resource : getResources(context.getClassLoader(), name)) {
if (resource.exists()) {
return ConditionOutcome.match("Bundle found for "
@ -140,8 +141,8 @@ public class MessageSourceAutoConfiguration {
}
}
}
return ConditionOutcome.noMatch("No bundle found for "
+ "spring.messages.basename: " + basename);
return ConditionOutcome.noMatch(
"No bundle found for " + "spring.messages.basename: " + basename);
}
private Resource[] getResources(ClassLoader classLoader, String name) {
@ -160,10 +161,11 @@ public class MessageSourceAutoConfiguration {
* {@link PathMatchingResourcePatternResolver} that skips well known JARs that don't
* contain messages.properties.
*/
private static class SkipPatternPathMatchingResourcePatternResolver extends
PathMatchingResourcePatternResolver {
private static class SkipPatternPathMatchingResourcePatternResolver
extends PathMatchingResourcePatternResolver {
private static final ClassLoader ROOT_CLASSLOADER;
static {
ClassLoader classLoader = null;
try {
@ -203,7 +205,8 @@ public class MessageSourceAutoConfiguration {
protected Set<Resource> doFindAllClassPathResources(String path)
throws IOException {
Set<Resource> resources = super.doFindAllClassPathResources(path);
for (Iterator<Resource> iterator = resources.iterator(); iterator.hasNext();) {
for (Iterator<Resource> iterator = resources.iterator(); iterator
.hasNext();) {
Resource resource = iterator.next();
for (String skipped : SKIPPED) {
if (resource.getFilename().startsWith(skipped)) {

@ -42,30 +42,25 @@ import com.rabbitmq.client.Channel;
* <P>
* Registers the following beans:
* <ul>
* <li>
* {@link org.springframework.amqp.rabbit.core.RabbitTemplate RabbitTemplate} if there is
* no other bean of the same type in the context.</li>
* <li>
* {@link org.springframework.amqp.rabbit.connection.CachingConnectionFactory
* <li>{@link org.springframework.amqp.rabbit.core.RabbitTemplate RabbitTemplate} if there
* is no other bean of the same type in the context.</li>
* <li>{@link org.springframework.amqp.rabbit.connection.CachingConnectionFactory
* CachingConnectionFactory} instance if there is no other bean of the same type in the
* context.</li>
* <li>
* {@link org.springframework.amqp.core.AmqpAdmin } instance as long as
* <li>{@link org.springframework.amqp.core.AmqpAdmin } instance as long as
* {@literal spring.rabbitmq.dynamic=true}.</li>
* </ul>
* <p>
* The {@link org.springframework.amqp.rabbit.connection.CachingConnectionFactory} honors
* the following properties:
* <ul>
* <li>
* {@literal spring.rabbitmq.port} is used to specify the port to which the client should
* connect, and defaults to 5672.</li>
* <li>
* {@literal spring.rabbitmq.username} is used to specify the (optional) username.</li>
* <li>
* {@literal spring.rabbitmq.password} is used to specify the (optional) password.</li>
* <li>
* {@literal spring.rabbitmq.host} is used to specify the host, and defaults to
* <li>{@literal spring.rabbitmq.port} is used to specify the port to which the client
* should connect, and defaults to 5672.</li>
* <li>{@literal spring.rabbitmq.username} is used to specify the (optional) username.
* </li>
* <li>{@literal spring.rabbitmq.password} is used to specify the (optional) password.
* </li>
* <li>{@literal spring.rabbitmq.host} is used to specify the host, and defaults to
* {@literal localhost}.</li>
* <li>{@literal spring.rabbitmq.virtualHost} is used to specify the (optional) virtual
* host to which the client should connect.</li>

@ -124,8 +124,8 @@ public class RabbitProperties {
}
result.add(address);
}
return (result.isEmpty() ? null : StringUtils
.collectionToCommaDelimitedString(result));
return (result.isEmpty() ? null
: StringUtils.collectionToCommaDelimitedString(result));
}
public void setPort(int port) {

@ -127,7 +127,8 @@ public class BasicBatchConfigurer implements BatchConfigurer {
JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
factory.setDataSource(this.dataSource);
if (this.entityManagerFactory != null) {
logger.warn("JPA does not support custom isolation levels, so locks may not be taken when launching Jobs");
logger.warn(
"JPA does not support custom isolation levels, so locks may not be taken when launching Jobs");
factory.setIsolationLevelForCreate("ISOLATION_DEFAULT");
}
factory.setTransactionManager(getTransactionManager());

@ -109,7 +109,8 @@ public class BatchAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public JobOperator jobOperator(JobExplorer jobExplorer, JobLauncher jobLauncher,
ListableJobLocator jobRegistry, JobRepository jobRepository) throws Exception {
ListableJobLocator jobRegistry, JobRepository jobRepository)
throws Exception {
SimpleJobOperator factory = new SimpleJobOperator();
factory.setJobExplorer(jobExplorer);
factory.setJobLauncher(jobLauncher);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save