mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Merge branch '1.2.x'
This commit is contained in:
commit
e473364e4e
@ -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));
|
||||
}
|
||||
|
||||
|
@ -266,8 +266,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) {
|
||||
|
@ -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 application by default.
|
||||
|
@ -91,8 +91,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();
|
||||
|
@ -50,7 +50,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).
|
||||
@ -215,8 +216,8 @@ public class ShellProperties {
|
||||
/**
|
||||
* Base class for Auth specific properties.
|
||||
*/
|
||||
public static abstract class CrshShellAuthenticationProperties extends
|
||||
CrshShellProperties {
|
||||
public static abstract class CrshShellAuthenticationProperties
|
||||
extends CrshShellProperties {
|
||||
|
||||
}
|
||||
|
||||
@ -325,8 +326,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.
|
||||
@ -354,8 +355,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.
|
||||
@ -385,8 +386,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);
|
||||
@ -460,8 +461,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.
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -86,11 +86,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);
|
||||
@ -144,10 +145,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));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,10 +82,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);
|
||||
@ -114,10 +115,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()));
|
||||
}
|
||||
|
||||
@ -127,12 +128,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()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,10 +145,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();
|
||||
}
|
||||
|
@ -37,8 +37,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;
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -53,9 +53,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("total", path.getTotalSpace())
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,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, "");
|
||||
}
|
||||
|
||||
@ -57,8 +58,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());
|
||||
}
|
||||
|
@ -150,8 +150,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
|
||||
|
@ -85,8 +85,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);
|
||||
|
@ -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";
|
||||
|
||||
|
@ -36,8 +36,8 @@ final 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());
|
||||
|
@ -194,8 +194,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();
|
||||
@ -230,8 +230,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
|
||||
@ -270,8 +270,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;
|
||||
@ -299,8 +299,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;
|
||||
@ -314,7 +314,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);
|
||||
@ -328,8 +329,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;
|
||||
@ -360,12 +361,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();
|
||||
@ -174,10 +170,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,
|
||||
|
@ -85,8 +85,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
|
||||
@ -142,8 +142,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
|
||||
@ -157,8 +157,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
|
||||
@ -172,8 +172,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
|
||||
@ -188,8 +188,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
|
||||
@ -213,8 +213,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
|
||||
@ -248,8 +248,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
|
||||
@ -262,8 +262,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
|
||||
@ -277,8 +277,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
|
||||
@ -291,8 +291,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
|
||||
@ -306,8 +306,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
|
||||
@ -317,8 +317,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());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -73,7 +73,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
|
||||
@ -106,7 +107,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) {
|
||||
@ -118,7 +120,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) {
|
||||
@ -130,7 +133,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
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
@ -235,7 +235,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);
|
||||
@ -255,8 +256,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();
|
||||
@ -317,8 +318,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) {
|
||||
}
|
||||
@ -353,8 +354,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");
|
||||
|
@ -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();
|
||||
|
@ -116,9 +116,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();
|
||||
@ -129,9 +128,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();
|
||||
|
@ -42,8 +42,8 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class AutoConfigurationReportEndpointTests extends
|
||||
AbstractEndpointTests<AutoConfigurationReportEndpoint> {
|
||||
public class AutoConfigurationReportEndpointTests
|
||||
extends AbstractEndpointTests<AutoConfigurationReportEndpoint> {
|
||||
|
||||
public AutoConfigurationReportEndpointTests() {
|
||||
super(Config.class, AutoConfigurationReportEndpoint.class, "autoconfig", true,
|
||||
@ -70,8 +70,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));
|
||||
report.recordExclusions(Arrays.asList("com.foo.Bar"));
|
||||
|
@ -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",
|
||||
|
@ -56,10 +56,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"));
|
||||
|
@ -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();
|
||||
|
@ -51,7 +51,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 {
|
||||
|
||||
@ -63,8 +64,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
|
||||
@ -84,8 +85,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");
|
||||
|
@ -72,8 +72,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));
|
||||
}
|
||||
|
||||
|
@ -99,8 +99,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
|
||||
@ -77,7 +77,8 @@ public class DiskSpaceHealthIndicatorTests {
|
||||
assertEquals(THRESHOLD_BYTES * 10, health.getDetails().get("total"));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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));
|
||||
|
@ -155,8 +155,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();
|
||||
}
|
||||
|
@ -43,30 +43,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>
|
||||
|
@ -142,8 +142,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) {
|
||||
|
@ -137,7 +137,8 @@ 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");
|
||||
}
|
||||
String tablePrefix = this.properties.getTablePrefix();
|
||||
|
@ -28,8 +28,8 @@ import org.springframework.context.ApplicationListener;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class JobExecutionExitCodeGenerator implements
|
||||
ApplicationListener<JobExecutionEvent>, ExitCodeGenerator {
|
||||
public class JobExecutionExitCodeGenerator
|
||||
implements ApplicationListener<JobExecutionEvent>, ExitCodeGenerator {
|
||||
|
||||
private final List<JobExecution> executions = new ArrayList<JobExecution>();
|
||||
|
||||
|
@ -62,8 +62,8 @@ import org.springframework.util.StringUtils;
|
||||
* @author Jean-Pierre Bergamin
|
||||
*/
|
||||
@Component
|
||||
public class JobLauncherCommandLineRunner implements CommandLineRunner,
|
||||
ApplicationEventPublisherAware {
|
||||
public class JobLauncherCommandLineRunner
|
||||
implements CommandLineRunner, ApplicationEventPublisherAware {
|
||||
|
||||
private static Log logger = LogFactory.getLog(JobLauncherCommandLineRunner.class);
|
||||
|
||||
@ -81,7 +81,8 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner,
|
||||
|
||||
private ApplicationEventPublisher publisher;
|
||||
|
||||
public JobLauncherCommandLineRunner(JobLauncher jobLauncher, JobExplorer jobExplorer) {
|
||||
public JobLauncherCommandLineRunner(JobLauncher jobLauncher,
|
||||
JobExplorer jobExplorer) {
|
||||
this.jobLauncher = jobLauncher;
|
||||
this.jobExplorer = jobExplorer;
|
||||
}
|
||||
@ -123,7 +124,8 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner,
|
||||
executeRegisteredJobs(jobParameters);
|
||||
}
|
||||
|
||||
private JobParameters getNextJobParameters(Job job, JobParameters additionalParameters) {
|
||||
private JobParameters getNextJobParameters(Job job,
|
||||
JobParameters additionalParameters) {
|
||||
String name = job.getName();
|
||||
JobParameters parameters = new JobParameters();
|
||||
List<JobInstance> lastInstances = this.jobExplorer.getJobInstances(name, 0, 1);
|
||||
@ -165,7 +167,8 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner,
|
||||
}
|
||||
|
||||
private void removeNonIdentifying(Map<String, JobParameter> parameters) {
|
||||
HashMap<String, JobParameter> copy = new HashMap<String, JobParameter>(parameters);
|
||||
HashMap<String, JobParameter> copy = new HashMap<String, JobParameter>(
|
||||
parameters);
|
||||
for (Map.Entry<String, JobParameter> parameter : copy.entrySet()) {
|
||||
if (!parameter.getValue().isIdentifying()) {
|
||||
parameters.remove(parameter.getKey());
|
||||
|
@ -96,8 +96,8 @@ abstract class BeanTypeRegistry {
|
||||
}
|
||||
|
||||
private Class<?> doGetFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory,
|
||||
BeanDefinition definition, String name) throws Exception,
|
||||
ClassNotFoundException, LinkageError {
|
||||
BeanDefinition definition, String name)
|
||||
throws Exception, ClassNotFoundException, LinkageError {
|
||||
if (StringUtils.hasLength(definition.getFactoryBeanName())
|
||||
&& StringUtils.hasLength(definition.getFactoryMethodName())) {
|
||||
return getConfigurationClassFactoryBeanGeneric(beanFactory, definition, name);
|
||||
@ -116,8 +116,8 @@ abstract class BeanTypeRegistry {
|
||||
.as(FactoryBean.class).resolveGeneric();
|
||||
if ((generic == null || generic.equals(Object.class))
|
||||
&& definition.hasAttribute(FACTORY_BEAN_OBJECT_TYPE)) {
|
||||
generic = getTypeFromAttribute(definition
|
||||
.getAttribute(FACTORY_BEAN_OBJECT_TYPE));
|
||||
generic = getTypeFromAttribute(
|
||||
definition.getAttribute(FACTORY_BEAN_OBJECT_TYPE));
|
||||
}
|
||||
return generic;
|
||||
}
|
||||
@ -132,12 +132,12 @@ abstract class BeanTypeRegistry {
|
||||
.getIntrospectedMethod();
|
||||
}
|
||||
}
|
||||
BeanDefinition factoryDefinition = beanFactory.getBeanDefinition(definition
|
||||
.getFactoryBeanName());
|
||||
BeanDefinition factoryDefinition = beanFactory
|
||||
.getBeanDefinition(definition.getFactoryBeanName());
|
||||
Class<?> factoryClass = ClassUtils.forName(factoryDefinition.getBeanClassName(),
|
||||
beanFactory.getBeanClassLoader());
|
||||
return ReflectionUtils
|
||||
.findMethod(factoryClass, definition.getFactoryMethodName());
|
||||
return ReflectionUtils.findMethod(factoryClass,
|
||||
definition.getFactoryMethodName());
|
||||
}
|
||||
|
||||
private Class<?> getDirectFactoryBeanGeneric(
|
||||
@ -145,12 +145,12 @@ abstract class BeanTypeRegistry {
|
||||
String name) throws ClassNotFoundException, LinkageError {
|
||||
Class<?> factoryBeanClass = ClassUtils.forName(definition.getBeanClassName(),
|
||||
beanFactory.getBeanClassLoader());
|
||||
Class<?> generic = ResolvableType.forClass(factoryBeanClass)
|
||||
.as(FactoryBean.class).resolveGeneric();
|
||||
Class<?> generic = ResolvableType.forClass(factoryBeanClass).as(FactoryBean.class)
|
||||
.resolveGeneric();
|
||||
if ((generic == null || generic.equals(Object.class))
|
||||
&& definition.hasAttribute(FACTORY_BEAN_OBJECT_TYPE)) {
|
||||
generic = getTypeFromAttribute(definition
|
||||
.getAttribute(FACTORY_BEAN_OBJECT_TYPE));
|
||||
generic = getTypeFromAttribute(
|
||||
definition.getAttribute(FACTORY_BEAN_OBJECT_TYPE));
|
||||
}
|
||||
return generic;
|
||||
}
|
||||
@ -195,8 +195,8 @@ abstract class BeanTypeRegistry {
|
||||
@Override
|
||||
public Set<String> getNamesForType(Class<?> type) {
|
||||
Set<String> result = new LinkedHashSet<String>();
|
||||
result.addAll(Arrays.asList(this.beanFactory.getBeanNamesForType(type, true,
|
||||
false)));
|
||||
result.addAll(Arrays
|
||||
.asList(this.beanFactory.getBeanNamesForType(type, true, false)));
|
||||
if (this.beanFactory instanceof ConfigurableListableBeanFactory) {
|
||||
collectBeanNamesForTypeFromFactoryBeans(result,
|
||||
(ConfigurableListableBeanFactory) this.beanFactory, type);
|
||||
@ -225,8 +225,8 @@ abstract class BeanTypeRegistry {
|
||||
* {@link BeanTypeRegistry} optimized for {@link DefaultListableBeanFactory}
|
||||
* implementations that allow eager class loading.
|
||||
*/
|
||||
static class OptimizedBeanTypeRegistry extends BeanTypeRegistry implements
|
||||
SmartInitializingSingleton {
|
||||
static class OptimizedBeanTypeRegistry extends BeanTypeRegistry
|
||||
implements SmartInitializingSingleton {
|
||||
|
||||
private static final String BEAN_NAME = BeanTypeRegistry.class.getName();
|
||||
|
||||
@ -249,7 +249,8 @@ abstract class BeanTypeRegistry {
|
||||
|
||||
@Override
|
||||
public Set<String> getNamesForType(Class<?> type) {
|
||||
if (this.lastBeanDefinitionCount != this.beanFactory.getBeanDefinitionCount()) {
|
||||
if (this.lastBeanDefinitionCount != this.beanFactory
|
||||
.getBeanDefinitionCount()) {
|
||||
Iterator<String> names = this.beanFactory.getBeanNamesIterator();
|
||||
while (names.hasNext()) {
|
||||
String name = names.next();
|
||||
@ -315,8 +316,8 @@ abstract class BeanTypeRegistry {
|
||||
|
||||
private boolean requiresEagerInit(String factoryBeanName) {
|
||||
return (factoryBeanName != null
|
||||
&& this.beanFactory.isFactoryBean(factoryBeanName) && !this.beanFactory
|
||||
.containsSingleton(factoryBeanName));
|
||||
&& this.beanFactory.isFactoryBean(factoryBeanName)
|
||||
&& !this.beanFactory.containsSingleton(factoryBeanName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,7 +112,8 @@ public final class ConditionEvaluationReport {
|
||||
*/
|
||||
public Map<String, ConditionAndOutcomes> getConditionAndOutcomesBySource() {
|
||||
if (!this.addedAncestorOutcomes) {
|
||||
for (Map.Entry<String, ConditionAndOutcomes> entry : this.outcomes.entrySet()) {
|
||||
for (Map.Entry<String, ConditionAndOutcomes> entry : this.outcomes
|
||||
.entrySet()) {
|
||||
if (!entry.getValue().isFullMatch()) {
|
||||
addNoMatchOutcomeToAncestors(entry.getKey());
|
||||
}
|
||||
@ -126,8 +127,8 @@ public final class ConditionEvaluationReport {
|
||||
String prefix = source + "$";
|
||||
for (Entry<String, ConditionAndOutcomes> entry : this.outcomes.entrySet()) {
|
||||
if (entry.getKey().startsWith(prefix)) {
|
||||
ConditionOutcome outcome = new ConditionOutcome(false, "Ancestor '"
|
||||
+ source + "' did not match");
|
||||
ConditionOutcome outcome = new ConditionOutcome(false,
|
||||
"Ancestor '" + source + "' did not match");
|
||||
entry.getValue().add(ANCESTOR_CONDITION, outcome);
|
||||
}
|
||||
}
|
||||
@ -250,8 +251,8 @@ public final class ConditionEvaluationReport {
|
||||
}
|
||||
ConditionAndOutcome other = (ConditionAndOutcome) obj;
|
||||
return (ObjectUtils.nullSafeEquals(this.condition.getClass(),
|
||||
other.condition.getClass()) && ObjectUtils.nullSafeEquals(
|
||||
this.outcome, other.outcome));
|
||||
other.condition.getClass())
|
||||
&& ObjectUtils.nullSafeEquals(this.outcome, other.outcome));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,8 +92,8 @@ public class ConditionOutcome {
|
||||
}
|
||||
if (getClass() == obj.getClass()) {
|
||||
ConditionOutcome other = (ConditionOutcome) obj;
|
||||
return (this.match == other.match && ObjectUtils.nullSafeEquals(this.message,
|
||||
other.message));
|
||||
return (this.match == other.match
|
||||
&& ObjectUtils.nullSafeEquals(this.message, other.message));
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
@ -57,15 +57,15 @@ class OnClassCondition extends SpringBootCondition {
|
||||
+ StringUtils.collectionToCommaDelimitedString(missing));
|
||||
}
|
||||
matchMessage.append("@ConditionalOnClass classes found: "
|
||||
+ StringUtils.collectionToCommaDelimitedString(getMatchingClasses(
|
||||
onClasses, MatchType.PRESENT, context)));
|
||||
+ StringUtils.collectionToCommaDelimitedString(
|
||||
getMatchingClasses(onClasses, MatchType.PRESENT, context)));
|
||||
}
|
||||
|
||||
MultiValueMap<String, Object> onMissingClasses = getAttributes(metadata,
|
||||
ConditionalOnMissingClass.class);
|
||||
if (onMissingClasses != null) {
|
||||
List<String> present = getMatchingClasses(onMissingClasses,
|
||||
MatchType.PRESENT, context);
|
||||
List<String> present = getMatchingClasses(onMissingClasses, MatchType.PRESENT,
|
||||
context);
|
||||
if (!present.isEmpty()) {
|
||||
return ConditionOutcome
|
||||
.noMatch("required @ConditionalOnMissing classes found: "
|
||||
|
@ -39,8 +39,9 @@ class OnExpressionCondition extends SpringBootCondition {
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
|
||||
String expression = (String) metadata.getAnnotationAttributes(
|
||||
ConditionalOnExpression.class.getName()).get("value");
|
||||
String expression = (String) metadata
|
||||
.getAnnotationAttributes(ConditionalOnExpression.class.getName())
|
||||
.get("value");
|
||||
String rawExpression = expression;
|
||||
if (!expression.startsWith("#{")) {
|
||||
// For convenience allow user to provide bare expression with no #{} wrapper
|
||||
@ -51,8 +52,8 @@ class OnExpressionCondition extends SpringBootCondition {
|
||||
expression = context.getEnvironment().resolvePlaceholders(expression);
|
||||
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
|
||||
BeanExpressionResolver resolver = beanFactory.getBeanExpressionResolver();
|
||||
BeanExpressionContext expressionContext = (beanFactory != null) ? new BeanExpressionContext(
|
||||
beanFactory, null) : null;
|
||||
BeanExpressionContext expressionContext = (beanFactory != null)
|
||||
? new BeanExpressionContext(beanFactory, null) : null;
|
||||
if (resolver == null) {
|
||||
resolver = new StandardBeanExpressionResolver();
|
||||
}
|
||||
|
@ -55,9 +55,10 @@ class OnJavaCondition extends SpringBootCondition {
|
||||
return new ConditionOutcome(match, getMessage(range, runningVersion, version));
|
||||
}
|
||||
|
||||
private String getMessage(Range range, JavaVersion runningVersion, JavaVersion version) {
|
||||
String expected = String.format(range == Range.EQUAL_OR_NEWER ? "%s or newer"
|
||||
: "older than %s", version);
|
||||
private String getMessage(Range range, JavaVersion runningVersion,
|
||||
JavaVersion version) {
|
||||
String expected = String.format(
|
||||
range == Range.EQUAL_OR_NEWER ? "%s or newer" : "older than %s", version);
|
||||
return "Required JVM version " + expected + " found " + runningVersion;
|
||||
}
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ class OnJndiCondition extends SpringBootCondition {
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(metadata
|
||||
.getAnnotationAttributes(ConditionalOnJndi.class.getName()));
|
||||
AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(
|
||||
metadata.getAnnotationAttributes(ConditionalOnJndi.class.getName()));
|
||||
String[] locations = annotationAttributes.getStringArray("value");
|
||||
try {
|
||||
return getMatchOutcome(locations);
|
||||
@ -62,9 +62,9 @@ class OnJndiCondition extends SpringBootCondition {
|
||||
JndiLocator locator = getJndiLocator(locations);
|
||||
String location = locator.lookupFirstLocation();
|
||||
if (location != null) {
|
||||
return ConditionOutcome.match("JNDI location '" + location
|
||||
+ "' found from candidates "
|
||||
+ StringUtils.arrayToCommaDelimitedString(locations));
|
||||
return ConditionOutcome
|
||||
.match("JNDI location '" + location + "' found from candidates "
|
||||
+ StringUtils.arrayToCommaDelimitedString(locations));
|
||||
}
|
||||
return ConditionOutcome.noMatch("No JNDI location found from candidates "
|
||||
+ StringUtils.arrayToCommaDelimitedString(locations));
|
||||
|
@ -44,8 +44,8 @@ class OnPropertyCondition extends SpringBootCondition {
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
|
||||
AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(metadata
|
||||
.getAnnotationAttributes(ConditionalOnProperty.class.getName()));
|
||||
AnnotationAttributes annotationAttributes = AnnotationAttributes.fromMap(
|
||||
metadata.getAnnotationAttributes(ConditionalOnProperty.class.getName()));
|
||||
|
||||
String prefix = annotationAttributes.getString("prefix").trim();
|
||||
if (StringUtils.hasText(prefix) && !prefix.endsWith(".")) {
|
||||
|
@ -40,11 +40,11 @@ class OnResourceCondition extends SpringBootCondition {
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(
|
||||
ConditionalOnResource.class.getName(), true);
|
||||
MultiValueMap<String, Object> attributes = metadata
|
||||
.getAllAnnotationAttributes(ConditionalOnResource.class.getName(), true);
|
||||
if (attributes != null) {
|
||||
ResourceLoader loader = context.getResourceLoader() == null ? this.defaultResourceLoader
|
||||
: context.getResourceLoader();
|
||||
ResourceLoader loader = context.getResourceLoader() == null
|
||||
? this.defaultResourceLoader : context.getResourceLoader();
|
||||
List<String> locations = new ArrayList<String>();
|
||||
collectValues(locations, attributes.get("resources"));
|
||||
Assert.isTrue(locations.size() > 0,
|
||||
|
@ -39,7 +39,8 @@ public abstract class SpringBootCondition implements Condition {
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Override
|
||||
public final boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
||||
public final boolean matches(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
String classOrMethodName = getClassOrMethodName(metadata);
|
||||
try {
|
||||
ConditionOutcome outcome = getMatchOutcome(context, metadata);
|
||||
@ -55,8 +56,8 @@ public abstract class SpringBootCondition implements Condition {
|
||||
+ "in the default package by mistake)", ex);
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
throw new IllegalStateException("Error processing condition on "
|
||||
+ getName(metadata), ex);
|
||||
throw new IllegalStateException(
|
||||
"Error processing condition on " + getName(metadata), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +89,8 @@ public abstract class SpringBootCondition implements Condition {
|
||||
}
|
||||
}
|
||||
|
||||
private StringBuilder getLogMessage(String classOrMethodName, ConditionOutcome outcome) {
|
||||
private StringBuilder getLogMessage(String classOrMethodName,
|
||||
ConditionOutcome outcome) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append("Condition ");
|
||||
message.append(ClassUtils.getShortName(getClass()));
|
||||
|
@ -42,8 +42,8 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
|
||||
* @author Dave Syer
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public abstract class AbstractRepositoryConfigurationSourceSupport implements
|
||||
BeanFactoryAware, ImportBeanDefinitionRegistrar, ResourceLoaderAware,
|
||||
public abstract class AbstractRepositoryConfigurationSourceSupport
|
||||
implements BeanFactoryAware, ImportBeanDefinitionRegistrar, ResourceLoaderAware,
|
||||
EnvironmentAware {
|
||||
|
||||
private ResourceLoader resourceLoader;
|
||||
@ -55,9 +55,9 @@ public abstract class AbstractRepositoryConfigurationSourceSupport implements
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
|
||||
BeanDefinitionRegistry registry) {
|
||||
new RepositoryConfigurationDelegate(getConfigurationSource(),
|
||||
this.resourceLoader, this.environment).registerRepositoriesIn(registry,
|
||||
getRepositoryConfigurationExtension());
|
||||
new RepositoryConfigurationDelegate(getConfigurationSource(), this.resourceLoader,
|
||||
this.environment).registerRepositoriesIn(registry,
|
||||
getRepositoryConfigurationExtension());
|
||||
}
|
||||
|
||||
private AnnotationRepositoryConfigurationSource getConfigurationSource() {
|
||||
|
@ -32,8 +32,8 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
|
||||
* @author Mohsin Husen
|
||||
* @since 1.1.0
|
||||
*/
|
||||
class ElasticsearchRepositoriesRegistrar extends
|
||||
AbstractRepositoryConfigurationSourceSupport {
|
||||
class ElasticsearchRepositoriesRegistrar
|
||||
extends AbstractRepositoryConfigurationSourceSupport {
|
||||
|
||||
@Override
|
||||
protected Class<? extends Annotation> getAnnotation() {
|
||||
|
@ -31,8 +31,8 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
|
||||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
*/
|
||||
class JpaRepositoriesAutoConfigureRegistrar extends
|
||||
AbstractRepositoryConfigurationSourceSupport {
|
||||
class JpaRepositoriesAutoConfigureRegistrar
|
||||
extends AbstractRepositoryConfigurationSourceSupport {
|
||||
|
||||
@Override
|
||||
protected Class<? extends Annotation> getAnnotation() {
|
||||
|
@ -125,8 +125,8 @@ public class MongoDataAutoConfiguration implements BeanClassLoaderAware {
|
||||
MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver,
|
||||
context);
|
||||
try {
|
||||
mappingConverter.setCustomConversions(beanFactory
|
||||
.getBean(CustomConversions.class));
|
||||
mappingConverter
|
||||
.setCustomConversions(beanFactory.getBean(CustomConversions.class));
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
// Ignore
|
||||
@ -183,8 +183,9 @@ public class MongoDataAutoConfiguration implements BeanClassLoaderAware {
|
||||
@ConditionalOnMissingBean
|
||||
public GridFsTemplate gridFsTemplate(MongoDbFactory mongoDbFactory,
|
||||
MongoTemplate mongoTemplate) {
|
||||
return new GridFsTemplate(new GridFsMongoDbFactory(mongoDbFactory,
|
||||
this.properties), mongoTemplate.getConverter());
|
||||
return new GridFsTemplate(
|
||||
new GridFsMongoDbFactory(mongoDbFactory, this.properties),
|
||||
mongoTemplate.getConverter());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,8 +30,8 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
class MongoRepositoriesAutoConfigureRegistrar extends
|
||||
AbstractRepositoryConfigurationSourceSupport {
|
||||
class MongoRepositoriesAutoConfigureRegistrar
|
||||
extends AbstractRepositoryConfigurationSourceSupport {
|
||||
|
||||
@Override
|
||||
protected Class<? extends Annotation> getAnnotation() {
|
||||
|
@ -83,8 +83,9 @@ public class FlywayAutoConfiguration {
|
||||
Assert.state(!this.properties.getLocations().isEmpty(),
|
||||
"Migration script locations not configured");
|
||||
boolean exists = hasAtLeastOneLocation();
|
||||
Assert.state(exists, "Cannot find migrations location in: "
|
||||
+ this.properties.getLocations()
|
||||
Assert.state(exists,
|
||||
"Cannot find migrations location in: " + this.properties
|
||||
.getLocations()
|
||||
+ " (please add migrations or check your Flyway configuration)");
|
||||
}
|
||||
}
|
||||
@ -104,8 +105,8 @@ public class FlywayAutoConfiguration {
|
||||
Flyway flyway = new Flyway();
|
||||
if (this.properties.isCreateDataSource()) {
|
||||
flyway.setDataSource(this.properties.getUrl(), this.properties.getUser(),
|
||||
this.properties.getPassword(), this.properties.getInitSqls()
|
||||
.toArray(new String[0]));
|
||||
this.properties.getPassword(),
|
||||
this.properties.getInitSqls().toArray(new String[0]));
|
||||
}
|
||||
else if (this.flywayDataSource != null) {
|
||||
flyway.setDataSource(this.flywayDataSource);
|
||||
@ -147,8 +148,8 @@ public class FlywayAutoConfiguration {
|
||||
@Configuration
|
||||
@ConditionalOnClass(LocalContainerEntityManagerFactoryBean.class)
|
||||
@ConditionalOnBean(AbstractEntityManagerFactoryBean.class)
|
||||
protected static class FlywayJpaDependencyConfiguration extends
|
||||
EntityManagerFactoryDependsOnPostProcessor {
|
||||
protected static class FlywayJpaDependencyConfiguration
|
||||
extends EntityManagerFactoryDependsOnPostProcessor {
|
||||
|
||||
public FlywayJpaDependencyConfiguration() {
|
||||
super("flyway");
|
||||
|
@ -29,8 +29,8 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class FreeMarkerTemplateAvailabilityProvider implements
|
||||
TemplateAvailabilityProvider {
|
||||
public class FreeMarkerTemplateAvailabilityProvider
|
||||
implements TemplateAvailabilityProvider {
|
||||
|
||||
@Override
|
||||
public boolean isTemplateAvailable(String view, Environment environment,
|
||||
|
@ -52,12 +52,13 @@ public class GroovyTemplateResolver implements TemplateResolver {
|
||||
public URL resolveTemplate(final String templatePath) throws IOException {
|
||||
MarkupTemplateEngine.TemplateResource templateResource = MarkupTemplateEngine.TemplateResource
|
||||
.parse(templatePath);
|
||||
URL resource = this.templateClassLoader.getResource(templateResource.withLocale(
|
||||
LocaleContextHolder.getLocale().toString().replace("-", "_")).toString());
|
||||
URL resource = this.templateClassLoader.getResource(templateResource
|
||||
.withLocale(LocaleContextHolder.getLocale().toString().replace("-", "_"))
|
||||
.toString());
|
||||
if (resource == null) {
|
||||
// no resource found with the default locale, try without any locale
|
||||
resource = this.templateClassLoader.getResource(templateResource.withLocale(
|
||||
null).toString());
|
||||
resource = this.templateClassLoader
|
||||
.getResource(templateResource.withLocale(null).toString());
|
||||
}
|
||||
if (resource == null) {
|
||||
throw new IOException("Unable to load template:" + templatePath);
|
||||
|
@ -88,8 +88,8 @@ public class HypermediaAutoConfiguration {
|
||||
* {@link BeanPostProcessor} to apply any {@link Jackson2ObjectMapperBuilder}
|
||||
* configuration to the HAL {@link ObjectMapper}.
|
||||
*/
|
||||
private static class HalObjectMapperConfigurer implements BeanPostProcessor,
|
||||
BeanFactoryAware {
|
||||
private static class HalObjectMapperConfigurer
|
||||
implements BeanPostProcessor, BeanFactoryAware {
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
|
@ -78,8 +78,8 @@ public class DataSourceAutoConfiguration {
|
||||
ConfigurableListableBeanFactory beanFactory) {
|
||||
try {
|
||||
BeanDefinition beanDefinition = beanFactory.getBeanDefinition("dataSource");
|
||||
return EmbeddedDataSourceConfiguration.class.getName().equals(
|
||||
beanDefinition.getFactoryBeanName());
|
||||
return EmbeddedDataSourceConfiguration.class.getName()
|
||||
.equals(beanDefinition.getFactoryBeanName());
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
return false;
|
||||
@ -117,8 +117,7 @@ public class DataSourceAutoConfiguration {
|
||||
DataSourceBuilder factory = DataSourceBuilder
|
||||
.create(this.properties.getClassLoader())
|
||||
.driverClassName(this.properties.getDriverClassName())
|
||||
.url(this.properties.getUrl())
|
||||
.username(this.properties.getUsername())
|
||||
.url(this.properties.getUrl()).username(this.properties.getUsername())
|
||||
.password(this.properties.getPassword());
|
||||
if (this.properties.getType() != null) {
|
||||
factory.type(this.properties.getType());
|
||||
@ -212,8 +211,8 @@ public class DataSourceAutoConfiguration {
|
||||
return ConditionOutcome
|
||||
.noMatch("existing non-embedded database detected");
|
||||
}
|
||||
EmbeddedDatabaseType type = EmbeddedDatabaseConnection.get(
|
||||
context.getClassLoader()).getType();
|
||||
EmbeddedDatabaseType type = EmbeddedDatabaseConnection
|
||||
.get(context.getClassLoader()).getType();
|
||||
if (type == null) {
|
||||
return ConditionOutcome.noMatch("no embedded database detected");
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ class DataSourceInitializer implements ApplicationListener<DataSourceInitialized
|
||||
logger.debug("Initialization disabled (not running DDL scripts)");
|
||||
return;
|
||||
}
|
||||
if (this.applicationContext.getBeanNamesForType(DataSource.class, false, false).length > 0) {
|
||||
if (this.applicationContext.getBeanNamesForType(DataSource.class, false,
|
||||
false).length > 0) {
|
||||
this.dataSource = this.applicationContext.getBean(DataSource.class);
|
||||
}
|
||||
if (this.dataSource == null) {
|
||||
@ -78,8 +79,8 @@ class DataSourceInitializer implements ApplicationListener<DataSourceInitialized
|
||||
if (!scripts.isEmpty()) {
|
||||
runScripts(scripts);
|
||||
try {
|
||||
this.applicationContext.publishEvent(new DataSourceInitializedEvent(
|
||||
this.dataSource));
|
||||
this.applicationContext
|
||||
.publishEvent(new DataSourceInitializedEvent(this.dataSource));
|
||||
// The listener might not be registered yet, so don't rely on it.
|
||||
if (!this.initialized) {
|
||||
runDataScripts();
|
||||
@ -132,8 +133,8 @@ class DataSourceInitializer implements ApplicationListener<DataSourceInitialized
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException("Unable to load resource from "
|
||||
+ location, ex);
|
||||
throw new IllegalStateException(
|
||||
"Unable to load resource from " + location, ex);
|
||||
}
|
||||
}
|
||||
return resources;
|
||||
|
@ -33,6 +33,7 @@ class DriverClassNameProvider {
|
||||
private static final String JDBC_URL_PREFIX = "jdbc";
|
||||
|
||||
private static final Map<String, String> DRIVERS;
|
||||
|
||||
static {
|
||||
Map<String, String> drivers = new HashMap<String, String>();
|
||||
drivers.put("derby", "org.apache.derby.jdbc.EmbeddedDriver");
|
||||
@ -59,8 +60,8 @@ class DriverClassNameProvider {
|
||||
*/
|
||||
String getDriverClassName(final String jdbcUrl) {
|
||||
Assert.notNull(jdbcUrl, "JdbcUrl must not be null");
|
||||
Assert.isTrue(jdbcUrl.startsWith(JDBC_URL_PREFIX), "JdbcUrl must start with '"
|
||||
+ JDBC_URL_PREFIX + "'");
|
||||
Assert.isTrue(jdbcUrl.startsWith(JDBC_URL_PREFIX),
|
||||
"JdbcUrl must start with '" + JDBC_URL_PREFIX + "'");
|
||||
String urlWithoutPrefix = jdbcUrl.substring(JDBC_URL_PREFIX.length());
|
||||
for (Map.Entry<String, String> driver : DRIVERS.entrySet()) {
|
||||
if (urlWithoutPrefix.startsWith(":" + driver.getKey() + ":")) {
|
||||
|
@ -107,10 +107,9 @@ public enum EmbeddedDatabaseConnection {
|
||||
* @return true if the driver class is one of the embedded types
|
||||
*/
|
||||
public static boolean isEmbedded(String driverClass) {
|
||||
return driverClass != null
|
||||
&& (driverClass.equals(HSQL.driverClass)
|
||||
|| driverClass.equals(H2.driverClass) || driverClass
|
||||
.equals(DERBY.driverClass));
|
||||
return driverClass != null && (driverClass.equals(HSQL.driverClass)
|
||||
|| driverClass.equals(H2.driverClass)
|
||||
|| driverClass.equals(DERBY.driverClass));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,8 +140,8 @@ public enum EmbeddedDatabaseConnection {
|
||||
return override;
|
||||
}
|
||||
for (EmbeddedDatabaseConnection candidate : EmbeddedDatabaseConnection.values()) {
|
||||
if (candidate != NONE
|
||||
&& ClassUtils.isPresent(candidate.getDriverClassName(), classLoader)) {
|
||||
if (candidate != NONE && ClassUtils.isPresent(candidate.getDriverClassName(),
|
||||
classLoader)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
@ -155,8 +154,8 @@ public enum EmbeddedDatabaseConnection {
|
||||
private static class IsEmbedded implements ConnectionCallback<Boolean> {
|
||||
|
||||
@Override
|
||||
public Boolean doInConnection(Connection connection) throws SQLException,
|
||||
DataAccessException {
|
||||
public Boolean doInConnection(Connection connection)
|
||||
throws SQLException, DataAccessException {
|
||||
String productName = connection.getMetaData().getDatabaseProductName();
|
||||
if (productName == null) {
|
||||
return false;
|
||||
|
@ -25,8 +25,8 @@ import javax.sql.DataSource;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public abstract class AbstractDataSourcePoolMetadata<T extends DataSource> implements
|
||||
DataSourcePoolMetadata {
|
||||
public abstract class AbstractDataSourcePoolMetadata<T extends DataSource>
|
||||
implements DataSourcePoolMetadata {
|
||||
|
||||
private final T dataSource;
|
||||
|
||||
|
@ -26,8 +26,8 @@ import org.apache.commons.dbcp.BasicDataSource;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public class CommonsDbcpDataSourcePoolMetadata extends
|
||||
AbstractDataSourcePoolMetadata<BasicDataSource> {
|
||||
public class CommonsDbcpDataSourcePoolMetadata
|
||||
extends AbstractDataSourcePoolMetadata<BasicDataSource> {
|
||||
|
||||
public CommonsDbcpDataSourcePoolMetadata(BasicDataSource dataSource) {
|
||||
super(dataSource);
|
||||
|
@ -33,7 +33,8 @@ public interface DataSourcePoolMetadata {
|
||||
* <ul>
|
||||
* <li>1 means that the maximum number of connections have been allocated</li>
|
||||
* <li>0 means that no connection is currently active</li>
|
||||
* <li>-1 means there is not limit to the number of connections that can be allocated</li>
|
||||
* <li>-1 means there is not limit to the number of connections that can be allocated
|
||||
* </li>
|
||||
* </ul>
|
||||
* This may also return {@code null} if the data source does not provide the necessary
|
||||
* information to compute the poll usage.
|
||||
|
@ -29,8 +29,8 @@ import com.zaxxer.hikari.pool.HikariPool;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public class HikariDataSourcePoolMetadata extends
|
||||
AbstractDataSourcePoolMetadata<HikariDataSource> {
|
||||
public class HikariDataSourcePoolMetadata
|
||||
extends AbstractDataSourcePoolMetadata<HikariDataSource> {
|
||||
|
||||
public HikariDataSourcePoolMetadata(HikariDataSource dataSource) {
|
||||
super(dataSource);
|
||||
|
@ -24,8 +24,8 @@ import org.apache.tomcat.jdbc.pool.DataSource;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class TomcatDataSourcePoolMetadata extends
|
||||
AbstractDataSourcePoolMetadata<DataSource> {
|
||||
public class TomcatDataSourcePoolMetadata
|
||||
extends AbstractDataSourcePoolMetadata<DataSource> {
|
||||
|
||||
public TomcatDataSourcePoolMetadata(DataSource dataSource) {
|
||||
super(dataSource);
|
||||
|
@ -57,8 +57,7 @@ import org.springframework.web.filter.RequestContextFilter;
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(name = {
|
||||
"org.glassfish.jersey.server.spring.SpringComponentProvider",
|
||||
@ConditionalOnClass(name = { "org.glassfish.jersey.server.spring.SpringComponentProvider",
|
||||
"javax.servlet.ServletRegistration" })
|
||||
@ConditionalOnBean(type = "org.glassfish.jersey.server.ResourceConfig")
|
||||
@ConditionalOnWebApplication
|
||||
|
@ -53,7 +53,8 @@ import org.springframework.util.StringUtils;
|
||||
public class JndiConnectionFactoryAutoConfiguration {
|
||||
|
||||
// Keep these in sync with the condition below
|
||||
private static String[] JNDI_LOCATIONS = { "java:/JmsXA", "java:/XAConnectionFactory" };
|
||||
private static String[] JNDI_LOCATIONS = { "java:/JmsXA",
|
||||
"java:/XAConnectionFactory" };
|
||||
|
||||
@Autowired
|
||||
private JmsProperties properties;
|
||||
|
@ -46,8 +46,8 @@ class ActiveMQConnectionFactoryFactory {
|
||||
return doCreateConnectionFactory(factoryClass);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Unable to create "
|
||||
+ "ActiveMQConnectionFactory", ex);
|
||||
throw new IllegalStateException(
|
||||
"Unable to create " + "ActiveMQConnectionFactory", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,8 @@ class HornetQConnectionFactoryFactory {
|
||||
return doCreateConnectionFactory(factoryClass);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Unable to create "
|
||||
+ "HornetQConnectionFactory", ex);
|
||||
throw new IllegalStateException(
|
||||
"Unable to create " + "HornetQConnectionFactory", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,12 +106,12 @@ class HornetQConnectionFactoryFactory {
|
||||
Class<T> factoryClass) throws Exception {
|
||||
try {
|
||||
TransportConfiguration transportConfiguration = new TransportConfiguration(
|
||||
InVMConnectorFactory.class.getName(), this.properties.getEmbedded()
|
||||
.generateTransportParameters());
|
||||
InVMConnectorFactory.class.getName(),
|
||||
this.properties.getEmbedded().generateTransportParameters());
|
||||
ServerLocator serviceLocator = HornetQClient
|
||||
.createServerLocatorWithoutHA(transportConfiguration);
|
||||
return factoryClass.getConstructor(ServerLocator.class).newInstance(
|
||||
serviceLocator);
|
||||
return factoryClass.getConstructor(ServerLocator.class)
|
||||
.newInstance(serviceLocator);
|
||||
}
|
||||
catch (NoClassDefFoundError ex) {
|
||||
throw new IllegalStateException("Unable to create InVM "
|
||||
|
@ -106,16 +106,15 @@ class HornetQEmbeddedServerConfiguration {
|
||||
private void addQueues(JMSConfiguration configuration, String[] queues) {
|
||||
boolean persistent = this.properties.getEmbedded().isPersistent();
|
||||
for (String queue : queues) {
|
||||
configuration.getQueueConfigurations().add(
|
||||
new JMSQueueConfigurationImpl(queue, null, persistent, "/queue/"
|
||||
+ queue));
|
||||
configuration.getQueueConfigurations().add(new JMSQueueConfigurationImpl(
|
||||
queue, null, persistent, "/queue/" + queue));
|
||||
}
|
||||
}
|
||||
|
||||
private void addTopics(JMSConfiguration configuration, String[] topics) {
|
||||
for (String topic : topics) {
|
||||
configuration.getTopicConfigurations().add(
|
||||
new TopicConfigurationImpl(topic, "/topic/" + topic));
|
||||
configuration.getTopicConfigurations()
|
||||
.add(new TopicConfigurationImpl(topic, "/topic/" + topic));
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user