Merge branch '1.2.x'

This commit is contained in:
Phillip Webb
2015-10-07 23:34:08 -07:00
507 changed files with 2659 additions and 2478 deletions

View File

@@ -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 + "]";
}
}

View File

@@ -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));
}

View File

@@ -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) {

View File

@@ -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.

View File

@@ -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();

View File

@@ -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.

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -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));
}

View File

@@ -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));
}
}

View File

@@ -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())));
}
}
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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()));
}
}

View File

@@ -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();
}

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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())

View File

@@ -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));
}
/**

View File

@@ -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;

View File

@@ -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());
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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";

View File

@@ -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;

View File

@@ -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;

View File

@@ -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());

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -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

View File

@@ -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

View File

@@ -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");

View File

@@ -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();

View File

@@ -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();

View File

@@ -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"));

View File

@@ -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"));
}

View File

@@ -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",

View File

@@ -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"));

View File

@@ -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();

View File

@@ -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"));

View File

@@ -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();

View File

@@ -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");

View File

@@ -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

View File

@@ -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));
}

View File

@@ -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();

View File

@@ -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);

View File

@@ -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();

View File

@@ -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());

View File

@@ -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);

View File

@@ -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);

View File

@@ -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() {

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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());
}

View File

@@ -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());

View File

@@ -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);

View File

@@ -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);