Consistently log Class.getName() instead of Class.toString(), avoiding double class term in log message

Issue: SPR-11804
(cherry picked from commit 2619955)
This commit is contained in:
Juergen Hoeller
2014-05-19 20:18:50 +02:00
parent a2ef2c9d3e
commit 1120680c65

View File

@@ -187,7 +187,7 @@ public class TestContextManager {
// Use defaults? // Use defaults?
if (descriptor == null) { if (descriptor == null) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("@TestExecutionListeners is not present for class [" + clazz + "]: using defaults."); logger.debug("@TestExecutionListeners is not present for class [" + clazz.getName() + "]: using defaults.");
} }
classesList.addAll(getDefaultTestExecutionListenerClasses()); classesList.addAll(getDefaultTestExecutionListenerClasses());
} }
@@ -198,7 +198,7 @@ public class TestContextManager {
AnnotationAttributes annAttrs = descriptor.getAnnotationAttributes(); AnnotationAttributes annAttrs = descriptor.getAnnotationAttributes();
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
logger.trace(String.format("Retrieved @TestExecutionListeners attributes [%s] for declaring class [%s].", logger.trace(String.format("Retrieved @TestExecutionListeners attributes [%s] for declaring class [%s].",
annAttrs, declaringClass)); annAttrs, declaringClass.getName()));
} }
Class<? extends TestExecutionListener>[] valueListenerClasses = Class<? extends TestExecutionListener>[] valueListenerClasses =
@@ -208,7 +208,7 @@ public class TestContextManager {
if (!ObjectUtils.isEmpty(valueListenerClasses) && !ObjectUtils.isEmpty(listenerClasses)) { if (!ObjectUtils.isEmpty(valueListenerClasses) && !ObjectUtils.isEmpty(listenerClasses)) {
throw new IllegalStateException(String.format("Class [%s] configured with @TestExecutionListeners' " + throw new IllegalStateException(String.format("Class [%s] configured with @TestExecutionListeners' " +
"'value' [%s] and 'listeners' [%s] attributes. Use one or the other, but not both.", "'value' [%s] and 'listeners' [%s] attributes. Use one or the other, but not both.",
declaringClass, ObjectUtils.nullSafeToString(valueListenerClasses), declaringClass.getName(), ObjectUtils.nullSafeToString(valueListenerClasses),
ObjectUtils.nullSafeToString(listenerClasses))); ObjectUtils.nullSafeToString(listenerClasses)));
} }
else if (!ObjectUtils.isEmpty(valueListenerClasses)) { else if (!ObjectUtils.isEmpty(valueListenerClasses)) {
@@ -289,7 +289,7 @@ public class TestContextManager {
public void beforeTestClass() throws Exception { public void beforeTestClass() throws Exception {
Class<?> testClass = getTestContext().getTestClass(); Class<?> testClass = getTestContext().getTestClass();
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
logger.trace("beforeTestClass(): class [" + testClass + "]"); logger.trace("beforeTestClass(): class [" + testClass.getName() + "]");
} }
getTestContext().updateState(null, null, null); getTestContext().updateState(null, null, null);
@@ -403,8 +403,8 @@ public class TestContextManager {
public void afterTestMethod(Object testInstance, Method testMethod, Throwable exception) throws Exception { public void afterTestMethod(Object testInstance, Method testMethod, Throwable exception) throws Exception {
Assert.notNull(testInstance, "testInstance must not be null"); Assert.notNull(testInstance, "testInstance must not be null");
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
logger.trace("afterTestMethod(): instance [" + testInstance + "], method [" + testMethod + "], exception [" logger.trace("afterTestMethod(): instance [" + testInstance + "], method [" + testMethod +
+ exception + "]"); "], exception [" + exception + "]");
} }
getTestContext().updateState(testInstance, testMethod, exception); getTestContext().updateState(testInstance, testMethod, exception);
@@ -446,7 +446,7 @@ public class TestContextManager {
public void afterTestClass() throws Exception { public void afterTestClass() throws Exception {
Class<?> testClass = getTestContext().getTestClass(); Class<?> testClass = getTestContext().getTestClass();
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
logger.trace("afterTestClass(): class [" + testClass + "]"); logger.trace("afterTestClass(): class [" + testClass.getName() + "]");
} }
getTestContext().updateState(null, null, null); getTestContext().updateState(null, null, null);