Minor improvements in spring-test

- Remove final modifier from private method
- Use StandardCharsets
- Remove unnecessary toString calls
- Remove unnecessary static modifiers
- Refactor to use enhanced switch
- Replace concatenated strings with text blocks
- Rely on auto-boxing where appropriate
- Remove unnecessary code
- Fix imports in Kotlin test classes

Closes gh-29413
This commit is contained in:
Kulwant Singh
2022-11-01 21:51:51 +01:00
committed by Sam Brannen
parent 307247b6a3
commit debe78b7f9
33 changed files with 175 additions and 207 deletions

View File

@@ -93,7 +93,7 @@ abstract class AbstractExpressionEvaluatingCondition implements ExecutionConditi
AnnotatedElement element = context.getElement().get();
Optional<A> annotation = findMergedAnnotation(element, annotationType);
if (!annotation.isPresent()) {
if (annotation.isEmpty()) {
String reason = String.format("%s is enabled since @%s is not present", element,
annotationType.getSimpleName());
if (logger.isDebugEnabled()) {

View File

@@ -188,7 +188,7 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
* register a JVM shutdown hook for it
* @return a new application context
*/
private final GenericApplicationContext loadContext(
private GenericApplicationContext loadContext(
MergedContextConfiguration mergedConfig, boolean forAotProcessing) throws Exception {
if (logger.isTraceEnabled()) {

View File

@@ -201,7 +201,7 @@ public abstract class AbstractTestNGSpringContextTests implements IHookable, App
private Throwable getTestResultException(ITestResult testResult) {
Throwable testResultException = testResult.getThrowable();
if (testResultException instanceof InvocationTargetException) {
testResultException = ((InvocationTargetException) testResultException).getCause();
testResultException = testResultException.getCause();
}
return testResultException;
}

View File

@@ -82,7 +82,7 @@ public class XmlExpectationsHelper {
public void assertXmlEqual(String expected, String actual) throws Exception {
XmlUnitDiff diff = new XmlUnitDiff(expected, actual);
if (diff.hasDifferences()) {
AssertionErrors.fail("Body content " + diff.toString());
AssertionErrors.fail("Body content " + diff);
}
}