fixed TypeDescriptor rendering (SPR-8508)
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4673 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
4c7603a407
commit
f39e560739
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -43,8 +43,9 @@ public class FormatHelper {
|
|||
}
|
||||
TypeDescriptor typeDescriptor = argumentTypes.get(i);
|
||||
if (typeDescriptor != null) {
|
||||
sb.append(formatClassNameForMessage(typeDescriptor.getClass()));
|
||||
} else {
|
||||
sb.append(formatClassNameForMessage(typeDescriptor.getType()));
|
||||
}
|
||||
else {
|
||||
sb.append(formatClassNameForMessage(null));
|
||||
}
|
||||
}
|
||||
|
|
@ -53,8 +54,8 @@ public class FormatHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Produce a nice string for a given class object. For example a string array will have the formatted name
|
||||
* "java.lang.String[]".
|
||||
* Produce a nice string for a given class object.
|
||||
* For example, a string array will have the formatted name "java.lang.String[]".
|
||||
* @param clazz The class whose name is to be formatted
|
||||
* @return a formatted string suitable for message inclusion
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.expression.spel.ast;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class FormatHelperTests {
|
||||
|
||||
@Test
|
||||
public void formatMethodWithSingleArgumentForMessage() {
|
||||
String message = FormatHelper.formatMethodForMessage("foo", Arrays.asList(TypeDescriptor.forObject("a string")));
|
||||
assertEquals("foo(java.lang.String)", message);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatMethodWithMultipleArgumentsForMessage() {
|
||||
String message = FormatHelper.formatMethodForMessage("foo", Arrays.asList(TypeDescriptor.forObject("a string"), TypeDescriptor.forObject(Integer.valueOf(5))));
|
||||
assertEquals("foo(java.lang.String,java.lang.Integer)", message);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue