Merge branch '1.5.x' into 2.0.x

This commit is contained in:
Phillip Webb
2018-05-03 12:43:50 -07:00
138 changed files with 274 additions and 269 deletions

View File

@@ -168,10 +168,10 @@ class ImportsContextCustomizer implements ContextCustomizer {
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
BeanDefinition definition = this.beanFactory
.getBeanDefinition(ImportsConfiguration.BEAN_NAME);
Object testClass = (definition == null ? null
: definition.getAttribute(TEST_CLASS_ATTRIBUTE));
return (testClass == null ? NO_IMPORTS
: new String[] { ((Class<?>) testClass).getName() });
Object testClass = (definition != null
? definition.getAttribute(TEST_CLASS_ATTRIBUTE) : null);
return (testClass != null ? new String[] { ((Class<?>) testClass).getName() }
: NO_IMPORTS);
}
}

View File

@@ -79,7 +79,7 @@ final class SpringBootConfigurationFinder {
private String getParentPackage(String sourcePackage) {
int lastDot = sourcePackage.lastIndexOf('.');
return (lastDot == -1 ? "" : sourcePackage.substring(0, lastDot));
return (lastDot != -1 ? sourcePackage.substring(0, lastDot) : "");
}
/**

View File

@@ -44,6 +44,7 @@ import org.springframework.core.annotation.Order;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.ResourceLoader;
import org.springframework.test.context.ContextConfigurationAttributes;
import org.springframework.test.context.ContextCustomizer;
import org.springframework.test.context.ContextLoader;
@@ -109,11 +110,11 @@ public class SpringBootContextLoader extends AbstractContextLoader {
if (!ObjectUtils.isEmpty(config.getActiveProfiles())) {
setActiveProfiles(environment, config.getActiveProfiles());
}
ResourceLoader resourceLoader = (application.getResourceLoader() != null
? application.getResourceLoader()
: new DefaultResourceLoader(getClass().getClassLoader()));
TestPropertySourceUtils.addPropertiesFilesToEnvironment(environment,
application.getResourceLoader() == null
? new DefaultResourceLoader(getClass().getClassLoader())
: application.getResourceLoader(),
config.getPropertySourceLocations());
resourceLoader, config.getPropertySourceLocations());
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment,
getInlinedProperties(config));
application.setEnvironment(environment);

View File

@@ -164,8 +164,8 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
WebAppConfiguration webAppConfiguration = AnnotatedElementUtils
.findMergedAnnotation(mergedConfig.getTestClass(),
WebAppConfiguration.class);
String resourceBasePath = (webAppConfiguration == null ? "src/main/webapp"
: webAppConfiguration.value());
String resourceBasePath = (webAppConfiguration != null
? webAppConfiguration.value() : "src/main/webapp");
mergedConfig = new WebMergedContextConfiguration(mergedConfig,
resourceBasePath);
}
@@ -313,17 +313,17 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
*/
protected WebEnvironment getWebEnvironment(Class<?> testClass) {
SpringBootTest annotation = getAnnotation(testClass);
return (annotation == null ? null : annotation.webEnvironment());
return (annotation != null ? annotation.webEnvironment() : null);
}
protected Class<?>[] getClasses(Class<?> testClass) {
SpringBootTest annotation = getAnnotation(testClass);
return (annotation == null ? null : annotation.classes());
return (annotation != null ? annotation.classes() : null);
}
protected String[] getProperties(Class<?> testClass) {
SpringBootTest annotation = getAnnotation(testClass);
return (annotation == null ? null : annotation.properties());
return (annotation != null ? annotation.properties() : null);
}
protected SpringBootTest getAnnotation(Class<?> testClass) {

View File

@@ -75,7 +75,7 @@ public final class JsonContent<T> implements AssertProvider<JsonContentAssert> {
@Override
public String toString() {
return "JsonContent " + this.json
+ (this.type == null ? "" : " created from " + this.type);
+ (this.type != null ? " created from " + this.type : "");
}
}

View File

@@ -991,7 +991,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
}
try {
return JSONCompare.compareJSON(
(expectedJson == null ? null : expectedJson.toString()),
(expectedJson != null ? expectedJson.toString() : null),
this.actual.toString(), compareMode);
}
catch (Exception ex) {
@@ -1009,7 +1009,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
}
try {
return JSONCompare.compareJSON(
(expectedJson == null ? null : expectedJson.toString()),
(expectedJson != null ? expectedJson.toString() : null),
this.actual.toString(), comparator);
}
catch (Exception ex) {
@@ -1054,7 +1054,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
JsonPathValue(CharSequence expression, Object... args) {
org.springframework.util.Assert.hasText(
(expression == null ? null : expression.toString()),
(expression != null ? expression.toString() : null),
"expression must not be null or empty");
this.expression = String.format(expression.toString(), args);
this.jsonPath = JsonPath.compile(this.expression);
@@ -1107,7 +1107,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
public Object getValue(boolean required) {
try {
CharSequence json = JsonContentAssert.this.actual;
return this.jsonPath.read(json == null ? null : json.toString());
return this.jsonPath.read(json != null ? json.toString() : null);
}
catch (Exception ex) {
if (!required) {

View File

@@ -43,7 +43,7 @@ class JsonLoader {
JsonLoader(Class<?> resourceLoadClass, Charset charset) {
this.resourceLoadClass = resourceLoadClass;
this.charset = charset == null ? StandardCharsets.UTF_8 : charset;
this.charset = (charset != null ? charset : StandardCharsets.UTF_8);
}
Class<?> getResourceLoadClass() {

View File

@@ -63,7 +63,7 @@ public final class ObjectContent<T> implements AssertProvider<ObjectContentAsser
@Override
public String toString() {
return "ObjectContent " + this.object
+ (this.type == null ? "" : " created from " + this.type);
+ (this.type != null ? " created from " + this.type : "");
}
}