pull/12071/merge
Andy Wilkinson 7 years ago
parent e3f0a70df2
commit a9645a3d07

@ -115,7 +115,7 @@ public class ConfigurationPropertiesReportEndpoint
String beanName = entry.getKey(); String beanName = entry.getKey();
Object bean = entry.getValue(); Object bean = entry.getValue();
Map<String, Object> root = new HashMap<String, Object>(); Map<String, Object> root = new HashMap<String, Object>();
String prefix = extractPrefix(context, beanFactoryMetaData, beanName, bean); String prefix = extractPrefix(context, beanFactoryMetaData, beanName);
root.put("prefix", prefix); root.put("prefix", prefix);
root.put("properties", sanitize(prefix, safeSerialize(mapper, bean, prefix))); root.put("properties", sanitize(prefix, safeSerialize(mapper, bean, prefix)));
result.put(beanName, root); result.put(beanName, root);
@ -204,12 +204,10 @@ public class ConfigurationPropertiesReportEndpoint
* @param context the application context * @param context the application context
* @param beanFactoryMetaData the bean factory meta-data * @param beanFactoryMetaData the bean factory meta-data
* @param beanName the bean name * @param beanName the bean name
* @param bean the bean
* @return the prefix * @return the prefix
*/ */
private String extractPrefix(ApplicationContext context, private String extractPrefix(ApplicationContext context,
ConfigurationBeanFactoryMetaData beanFactoryMetaData, String beanName, ConfigurationBeanFactoryMetaData beanFactoryMetaData, String beanName) {
Object bean) {
ConfigurationProperties annotation = context.findAnnotationOnBean(beanName, ConfigurationProperties annotation = context.findAnnotationOnBean(beanName,
ConfigurationProperties.class); ConfigurationProperties.class);
if (beanFactoryMetaData != null) { if (beanFactoryMetaData != null) {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -80,7 +80,7 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
List<String> values = this.redisOperations.opsForValue().multiGet(keys); List<String> values = this.redisOperations.opsForValue().multiGet(keys);
for (String v : values) { for (String v : values) {
String key = keysIt.next(); String key = keysIt.next();
result.add(deserialize(group, key, v, zSetOperations.score(key))); result.add(deserialize(key, v, zSetOperations.score(key)));
} }
return result; return result;
@ -143,7 +143,7 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
this.zSetOperations.remove(groupKey); this.zSetOperations.remove(groupKey);
} }
private Metric<?> deserialize(String group, String redisKey, String v, Double value) { private Metric<?> deserialize(String redisKey, String v, Double value) {
Date timestamp = new Date(Long.valueOf(v)); Date timestamp = new Date(Long.valueOf(v));
return new Metric<Double>(nameFor(redisKey), value, timestamp); return new Metric<Double>(nameFor(redisKey), value, timestamp);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -51,8 +51,7 @@ public class TestCommand extends OptionParsingCommand {
SourceOptions sourceOptions = new SourceOptions(options); SourceOptions sourceOptions = new SourceOptions(options);
TestRunnerConfiguration configuration = new TestRunnerConfigurationAdapter( TestRunnerConfiguration configuration = new TestRunnerConfigurationAdapter(
options, this); options, this);
this.runner = new TestRunner(configuration, sourceOptions.getSourcesArray(), this.runner = new TestRunner(configuration, sourceOptions.getSourcesArray());
sourceOptions.getArgsArray());
this.runner.compileAndRunTests(); this.runner.compileAndRunTests();
return ExitStatus.OK.hangup(); return ExitStatus.OK.hangup();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -46,9 +46,8 @@ public class TestRunner {
* Create a new {@link TestRunner} instance. * Create a new {@link TestRunner} instance.
* @param configuration the configuration * @param configuration the configuration
* @param sources the sources * @param sources the sources
* @param args the args
*/ */
TestRunner(TestRunnerConfiguration configuration, String[] sources, String[] args) { TestRunner(TestRunnerConfiguration configuration, String[] sources) {
this.sources = sources.clone(); this.sources = sources.clone();
this.compiler = new GroovyCompiler(configuration); this.compiler = new GroovyCompiler(configuration);
} }
@ -97,12 +96,11 @@ public class TestRunner {
if (sources.length != 0 && sources[0] instanceof Class) { if (sources.length != 0 && sources[0] instanceof Class) {
setContextClassLoader(((Class<?>) sources[0]).getClassLoader()); setContextClassLoader(((Class<?>) sources[0]).getClassLoader());
} }
this.spockSpecificationClass = loadSpockSpecificationClass( this.spockSpecificationClass = loadSpockSpecificationClass();
getContextClassLoader());
this.testClasses = getTestClasses(sources); this.testClasses = getTestClasses(sources);
} }
private Class<?> loadSpockSpecificationClass(ClassLoader contextClassLoader) { private Class<?> loadSpockSpecificationClass() {
try { try {
return getContextClassLoader().loadClass("spock.lang.Specification"); return getContextClassLoader().loadClass("spock.lang.Specification");
} }

@ -186,7 +186,7 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader {
Set<URL> urls = new HashSet<URL>(); Set<URL> urls = new HashSet<URL>();
findGroovyJarsDirectly(parent, urls); findGroovyJarsDirectly(parent, urls);
if (urls.isEmpty()) { if (urls.isEmpty()) {
findGroovyJarsFromClassPath(parent, urls); findGroovyJarsFromClassPath(urls);
} }
Assert.state(!urls.isEmpty(), "Unable to find groovy JAR"); Assert.state(!urls.isEmpty(), "Unable to find groovy JAR");
return new ArrayList<URL>(urls).toArray(new URL[urls.size()]); return new ArrayList<URL>(urls).toArray(new URL[urls.size()]);
@ -205,7 +205,7 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader {
} }
} }
private void findGroovyJarsFromClassPath(ClassLoader parent, Set<URL> urls) { private void findGroovyJarsFromClassPath(Set<URL> urls) {
String classpath = System.getProperty("java.class.path"); String classpath = System.getProperty("java.class.path");
String[] entries = classpath.split(System.getProperty("path.separator")); String[] entries = classpath.split(System.getProperty("path.separator"));
for (String entry : entries) { for (String entry : entries) {

@ -56,7 +56,7 @@ class SpringApplicationBannerPrinter {
} }
public Banner print(Environment environment, Class<?> sourceClass, Log logger) { public Banner print(Environment environment, Class<?> sourceClass, Log logger) {
Banner banner = getBanner(environment, this.fallbackBanner); Banner banner = getBanner(environment);
try { try {
logger.info(createStringFromBanner(banner, environment, sourceClass)); logger.info(createStringFromBanner(banner, environment, sourceClass));
} }
@ -67,12 +67,12 @@ class SpringApplicationBannerPrinter {
} }
public Banner print(Environment environment, Class<?> sourceClass, PrintStream out) { public Banner print(Environment environment, Class<?> sourceClass, PrintStream out) {
Banner banner = getBanner(environment, this.fallbackBanner); Banner banner = getBanner(environment);
banner.printBanner(environment, sourceClass, out); banner.printBanner(environment, sourceClass, out);
return new PrintedBanner(banner, sourceClass); return new PrintedBanner(banner, sourceClass);
} }
private Banner getBanner(Environment environment, Banner definedBanner) { private Banner getBanner(Environment environment) {
Banners banners = new Banners(); Banners banners = new Banners();
banners.addIfNotNull(getImageBanner(environment)); banners.addIfNotNull(getImageBanner(environment));
banners.addIfNotNull(getTextBanner(environment)); banners.addIfNotNull(getTextBanner(environment));

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -50,10 +50,10 @@ class TomcatErrorPage {
this.location = errorPage.getPath(); this.location = errorPage.getPath();
this.exceptionType = errorPage.getExceptionName(); this.exceptionType = errorPage.getExceptionName();
this.errorCode = errorPage.getStatusCode(); this.errorCode = errorPage.getStatusCode();
this.nativePage = createNativePage(errorPage); this.nativePage = createNativePage();
} }
private Object createNativePage(ErrorPage errorPage) { private Object createNativePage() {
try { try {
if (ClassUtils.isPresent(ERROR_PAGE_CLASS, null)) { if (ClassUtils.isPresent(ERROR_PAGE_CLASS, null)) {
return BeanUtils.instantiate(ClassUtils.forName(ERROR_PAGE_CLASS, null)); return BeanUtils.instantiate(ClassUtils.forName(ERROR_PAGE_CLASS, null));

@ -41,7 +41,7 @@ public class RelaxedConversionServiceTests {
Locale.setDefault(new Locale("tr")); Locale.setDefault(new Locale("tr"));
TestEnum result = this.conversionService TestEnum result = this.conversionService
.convert("accept-case-insensitive-properties", TestEnum.class); .convert("accept-case-insensitive-properties", TestEnum.class);
assertThat(result.equals(TestEnum.ACCEPT_CASE_INSENSITIVE_PROPERTIES)); assertThat(result).isEqualTo(TestEnum.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
} }
finally { finally {
Locale.setDefault(defaultLocale); Locale.setDefault(defaultLocale);

Loading…
Cancel
Save