提交 17c88107 编写于 作者: A Andy Clement

Removing functionality. Removed expression list support, cannot say (foo();bar()) any more

上级 4d437688
......@@ -24,10 +24,10 @@ package org.springframework.expression;
* turn. The only rule that affects the call order is that any naming the target class directly in
* getSpecifiedTargetClasses() will be called first, before the general resolvers.
* <p>
* If the cost of locating the property is expensive, in relation to actually retrieving its value, consider
* extending CacheablePropertyAccessor rather than directly implementing PropertyAccessor. A CacheablePropertyAccessor
* enables the discovery (resolution) of the property to be done once and then an object (an executor) returned
* and cached by the infrastructure that can be used repeatedly to retrieve the property value.
* If the cost of locating the property is expensive, in relation to actually retrieving its value, consider extending
* CacheablePropertyAccessor rather than directly implementing PropertyAccessor. A CacheablePropertyAccessor enables the
* discovery (resolution) of the property to be done once and then an object (an executor) returned and cached by the
* infrastructure that can be used repeatedly to retrieve the property value.
*
* @author Andy Clement
*/
......@@ -39,7 +39,6 @@ public interface PropertyAccessor {
*
* @return an array of classes that this resolver is suitable for (or null if a general resolver)
*/
@SuppressWarnings("unchecked")
public Class[] getSpecificTargetClasses();
/**
......
......@@ -59,10 +59,6 @@ tokens {
}
expr: expression EOF!;
exprList
: LPAREN expression (SEMI expression)+ (SEMIRPAREN | RPAREN)
-> ^(EXPRESSIONLIST expression+);
SEMIRPAREN : ';)'; // recoveryrelated: allows us to cope with a rogue superfluous semicolon before the rparen in an expression list
......@@ -102,8 +98,7 @@ primaryExpression
startNode
:
(LPAREN expression SEMI) => exprList
| parenExpr
parenExpr
| methodOrProperty
| functionOrVar
| localFunctionOrVar
......@@ -135,7 +130,6 @@ dottedNode
| selection
| firstSelection
| lastSelection
| exprList
))
;
......
GREATER_THAN_OR_EQUAL=79
SELECT_FIRST=58
COMMA=51
GREATER_THAN_OR_EQUAL=78
SELECT_FIRST=57
COMMA=50
HOLDER=14
GREATER_THAN=78
TYPE=60
GREATER_THAN=77
TYPE=59
EXPRESSIONLIST=4
MINUS=41
MINUS=40
MAP_ENTRY=25
SELECT_LAST=59
SELECT_LAST=58
NUMBER=29
LESS_THAN=76
BANG=46
LESS_THAN=75
BANG=45
ARGLIST=11
FALSE=70
FALSE=69
METHOD=26
PROPERTY_OR_FIELD=9
LBRACKET=53
MOD=44
LBRACKET=52
INDEXER=10
MOD=43
CONSTRUCTOR_ARRAY=15
FUNCTIONREF=17
NULL_LITERAL=66
NULL_LITERAL=65
NAMED_ARGUMENT=16
OR=38
PIPE=62
DOT=47
RCURLY=56
OR=37
PIPE=61
DOT=46
RCURLY=55
EXPRESSION=6
AND=39
LCURLY=63
AND=38
LCURLY=62
DATE_LITERAL=13
REAL_TYPE_SUFFIX=89
STRING_LITERAL=64
SELECT=57
STRING_LITERAL=63
SELECT=56
QUALIFIED_IDENTIFIER=7
RBRACKET=54
RBRACKET=53
SUBTRACT=28
ASSIGN=34
BETWEEN=82
RPAREN=33
ASSIGN=31
BETWEEN=81
RPAREN=36
SIGN=90
LPAREN=30
HEX_DIGIT=73
PLUS=40
LPAREN=35
HEX_DIGIT=72
PLUS=39
LIST_INITIALIZER=21
APOS=84
INTEGER_LITERAL=5
AT=52
ID=49
NOT_EQUAL=75
AT=51
ID=48
NOT_EQUAL=74
RANGE=19
POWER=45
POWER=44
TYPEREF=18
DECIMAL_DIGIT=71
DECIMAL_DIGIT=70
WS=86
IS=81
DOLLAR=50
LESS_THAN_OR_EQUAL=77
SEMIRPAREN=32
DQ_STRING_LITERAL=65
HEXADECIMAL_INTEGER_LITERAL=67
IS=80
DOLLAR=49
LESS_THAN_OR_EQUAL=76
SEMIRPAREN=30
DQ_STRING_LITERAL=64
HEXADECIMAL_INTEGER_LITERAL=66
MAP_INITIALIZER=22
LAMBDA=61
LAMBDA=60
LOCALFUNC=24
IN=80
IN=79
SEMI=83
CONSTRUCTOR=12
SEMI=31
INTEGER_TYPE_SUFFIX=72
EQUAL=74
MATCHES=83
INTEGER_TYPE_SUFFIX=71
EQUAL=73
MATCHES=82
DOT_ESCAPED=85
UPTO=87
QMARK=36
QMARK=33
REFERENCE=8
PROJECT=55
DEFAULT=35
COLON=37
DIV=43
PROJECT=54
DEFAULT=32
COLON=34
DIV=42
LOCALVAR=23
STAR=42
REAL_LITERAL=68
STAR=41
REAL_LITERAL=67
VARIABLEREF=20
EXPONENT_PART=88
TRUE=69
TRUE=68
ADD=27
POUND=48
POUND=47
'date'=92
'new'=91
......@@ -182,7 +182,6 @@ public class ReflectionUtils {
* match an expected type
* @return a MatchInfo object indicating what kind of match it was or null if it was not a match
*/
@SuppressWarnings("unchecked")
private static ArgumentsMatchInfo compareArguments(Class[] expectedArgTypes, Class[] suppliedArgTypes,
TypeConverter typeConverter, boolean conversionAllowed) {
ArgsMatchKind match = ArgsMatchKind.EXACT;
......@@ -230,7 +229,6 @@ public class ReflectionUtils {
* match an expected type
* @return a MatchInfo object indicating what kind of match it was or null if it was not a match
*/
@SuppressWarnings("unchecked")
private static ArgumentsMatchInfo compareArgumentsVarargs(Class[] expectedArgTypes, Class[] suppliedArgTypes,
TypeConverter typeConverter, boolean conversionAllowed) {
ArgsMatchKind match = ArgsMatchKind.EXACT;
......@@ -484,9 +482,9 @@ public class ReflectionUtils {
} else {
targetType = parameterTypes[i];
}
if (converter==null) {
throw new SpelException(SpelMessages.PROBLEM_DURING_TYPE_CONVERSION, "No converter available to convert '"
+ arguments[i] + " to type '" + targetType + "'");
if (converter == null) {
throw new SpelException(SpelMessages.PROBLEM_DURING_TYPE_CONVERSION,
"No converter available to convert '" + arguments[i] + " to type '" + targetType + "'");
}
try {
if (arguments[i] != null && arguments[i].getClass() != targetType) {
......@@ -495,8 +493,9 @@ public class ReflectionUtils {
} catch (EvaluationException e) {
// allows for another type converter throwing a different kind of EvaluationException
if (!(e instanceof SpelException)) {
throw new SpelException(e, SpelMessages.PROBLEM_DURING_TYPE_CONVERSION, "Converter failed to convert '"
+ arguments[i].getClass().getName() + "' to type '" + targetType + "'");
throw new SpelException(e, SpelMessages.PROBLEM_DURING_TYPE_CONVERSION,
"Converter failed to convert '" + arguments[i].getClass().getName() + "' to type '"
+ targetType + "'");
}
throw e;
}
......
......@@ -180,19 +180,11 @@ public class EvaluationTests extends ExpressionTestCase {
evaluate("#{1:'January', 2:'February', 3:'March'}.get(2)", "February", String.class);
}
public void testInlineMapCreation06() {
evaluate("(#pos=3;#{1:'January', 2:'February', 3:'March'}[#pos])", "March", String.class);
}
// set construction
public void testSetConstruction01() {
evaluate("new HashSet().addAll({'a','b','c'})", "true", Boolean.class);
}
public void testSets01() {
evaluate("(#var=new HashSet();#var.addAll({'a','b','c'});#var[1])", "c", String.class);
}
// constructors
public void testConstructorInvocation01() {
evaluate("new String('hello')", "hello", String.class);
......@@ -323,19 +315,6 @@ public class EvaluationTests extends ExpressionTestCase {
evaluate("#var1='value1'", "value1", String.class);
}
public void testAssignmentToVariables02() {
evaluate("(#var1='value1';#var1)", "value1", String.class, true);
}
// Property setting
public void testAssignmentToProperty01() {
evaluate("placeOfBirth.city='SmilJan'", "SmilJan", String.class);
evaluate(
"(#oldPOB = placeOfBirth.city;placeOfBirth.city='FairOak';'From ' + #oldPOB + ' to ' + placeOfBirth.city)",
"From SmilJan to FairOak", String.class);
evaluate("placeOfBirth.city='SmilJan'", "SmilJan", String.class);
}
// Ternary operator
public void testTernaryOperator01() {
evaluate("{1}.#isEven(#this[0]) == 'y'?'it is even':'it is odd'", "it is odd", String.class);
......@@ -389,10 +368,6 @@ public class EvaluationTests extends ExpressionTestCase {
evaluate("@(apple).color.getRGB() == T(java.awt.Color).green.getRGB()", "true", Boolean.class);
}
public void testReferences06b() {
evaluate("(#t='Color';@(apple).color.getRGB() == T(java.awt.Color).green.getRGB())", "true", Boolean.class);
}
public void testReferences07() {
evaluate("@(apple).color.getRGB().equals(T(java.awt.Color).green.getRGB())", "true", Boolean.class);
}
......@@ -424,49 +399,46 @@ public class EvaluationTests extends ExpressionTestCase {
evaluate("{|| true }", "{|| true }", Lambda.class);
}
public void testLambdaNoArgsReferenced() {
evaluate("(#fn={|| false };#fn)", "{|| false }", Lambda.class, true);
}
public void testLambda01() {
evaluate("{|x,y| $x > $y ? $x : $y }", "{|x,y| ($x > $y) ? $x : $y }",
org.springframework.expression.spel.ast.Lambda.class);
}
public void testLambda02() {
evaluate("(#max={|x,y| $x > $y ? $x : $y };true)", "true", Boolean.class);
}
public void testLambdaMax() {
evaluate("(#max = {|x,y| $x > $y ? $x : $y }; #max(5,25))", "25", Integer.class);
}
public void testLambdaFactorial01() {
evaluate("(#fact = {|n| $n <= 1 ? 1 : $n * #fact($n-1) }; #fact(5))", "120", Integer.class);
}
public void testLambdaFactorial02() {
evaluate("(#fact = {|n| $n <= 1 ? 1 : #fact($n-1) * $n }; #fact(5))", "120", Integer.class);
}
public void testLambdaAlphabet01() {
evaluate("(#alpha = {|l,s| $l>'z'?$s:#alpha($l+1,$s+$l)};#alphabet={||#alpha('a','')}; #alphabet())",
"abcdefghijklmnopqrstuvwxyz", String.class);
}
public void testLambdaAlphabet02() {
evaluate("(#alphabet = {|l,s| $l>'z'?$s:#alphabet($l+1,$s+$l)};#alphabet('a',''))",
"abcdefghijklmnopqrstuvwxyz", String.class);
}
public void testLambdaDelegation01() {
evaluate("(#sqrt={|n| T(Math).sqrt($n)};#delegate={|f,n| $f($n)};#delegate(#sqrt,4))", "2.0", Double.class);
}
public void testVariableReferences() {
evaluate("(#answer=42;#answer)", "42", Integer.class, true);
evaluate("($answer=42;$answer)", "42", Integer.class, true);
}
//
// public void testLambda02() {
// evaluate("(#max={|x,y| $x > $y ? $x : $y };true)", "true", Boolean.class);
// }
//
// public void testLambdaMax() {
// evaluate("(#max = {|x,y| $x > $y ? $x : $y }; #max(5,25))", "25", Integer.class);
// }
//
// public void testLambdaFactorial01() {
// evaluate("(#fact = {|n| $n <= 1 ? 1 : $n * #fact($n-1) }; #fact(5))", "120", Integer.class);
// }
//
// public void testLambdaFactorial02() {
// evaluate("(#fact = {|n| $n <= 1 ? 1 : #fact($n-1) * $n }; #fact(5))", "120", Integer.class);
// }
//
// public void testLambdaAlphabet01() {
// evaluate("(#alpha = {|l,s| $l>'z'?$s:#alpha($l+1,$s+$l)};#alphabet={||#alpha('a','')}; #alphabet())",
// "abcdefghijklmnopqrstuvwxyz", String.class);
// }
//
// public void testLambdaAlphabet02() {
// evaluate("(#alphabet = {|l,s| $l>'z'?$s:#alphabet($l+1,$s+$l)};#alphabet('a',''))",
// "abcdefghijklmnopqrstuvwxyz", String.class);
// }
//
// public void testLambdaDelegation01() {
// evaluate("(#sqrt={|n| T(Math).sqrt($n)};#delegate={|f,n| $f($n)};#delegate(#sqrt,4))", "2.0", Double.class);
// }
//
// public void testVariableReferences() {
// evaluate("(#answer=42;#answer)", "42", Integer.class, true);
// evaluate("($answer=42;$answer)", "42", Integer.class, true);
// }
// type references
public void testTypeReferences01() {
......
......@@ -90,27 +90,27 @@ public class LiteralTests extends ExpressionTestCase {
}
public void testLiteralReal01_CreatingDoubles() {
evaluate("1.25",1.25d,Double.class);
evaluate("2.99",2.99d,Double.class);
evaluate("-3.141",-3.141d,Double.class);
evaluate("1.25d",1.25d,Double.class);
evaluate("2.99d",2.99d,Double.class);
evaluate("-3.141d",-3.141d,Double.class);
evaluate("1.25D",1.25d,Double.class);
evaluate("2.99D",2.99d,Double.class);
evaluate("-3.141D",-3.141d,Double.class);
evaluate("1.25", 1.25d, Double.class);
evaluate("2.99", 2.99d, Double.class);
evaluate("-3.141", -3.141d, Double.class);
evaluate("1.25d", 1.25d, Double.class);
evaluate("2.99d", 2.99d, Double.class);
evaluate("-3.141d", -3.141d, Double.class);
evaluate("1.25D", 1.25d, Double.class);
evaluate("2.99D", 2.99d, Double.class);
evaluate("-3.141D", -3.141d, Double.class);
}
public void testLiteralReal02_CreatingFloats() {
// For now, everything becomes a double...
evaluate("1.25f",1.25d,Double.class);
evaluate("2.99f",2.99d,Double.class);
evaluate("-3.141f",-3.141d,Double.class);
evaluate("1.25F",1.25d,Double.class);
evaluate("2.99F",2.99d,Double.class);
evaluate("-3.141F",-3.141d,Double.class);
}
evaluate("1.25f", 1.25d, Double.class);
evaluate("2.99f", 2.99d, Double.class);
evaluate("-3.141f", -3.141d, Double.class);
evaluate("1.25F", 1.25d, Double.class);
evaluate("2.99F", 2.99d, Double.class);
evaluate("-3.141F", -3.141d, Double.class);
}
public void testLiteralReal03_UsingExponents() {
evaluate("6.0221415E+23", "6.0221415E23", Double.class);
evaluate("6.0221415e+23", "6.0221415E23", Double.class);
......@@ -121,10 +121,10 @@ public class LiteralTests extends ExpressionTestCase {
}
public void testLiteralReal04_BadExpressions() {
parseAndCheckError("6.1e23e22",SpelMessages.PARSE_PROBLEM,6,"mismatched input 'e22' expecting EOF");
parseAndCheckError("6.1f23e22",SpelMessages.PARSE_PROBLEM,4,"mismatched input '23e22' expecting EOF");
parseAndCheckError("6.1e23e22", SpelMessages.PARSE_PROBLEM, 6, "mismatched input 'e22' expecting EOF");
parseAndCheckError("6.1f23e22", SpelMessages.PARSE_PROBLEM, 4, "mismatched input '23e22' expecting EOF");
}
public void testLiteralNull01() {
evaluate("null", null, null);
}
......@@ -156,10 +156,10 @@ public class LiteralTests extends ExpressionTestCase {
// int year convertable from number to string
parseAndCheckError("date(2008,'yyyy').getTime()>0", SpelMessages.PARSE_PROBLEM);
}
public void testConversions() {
// getting the expression type to be what we want - either:
evaluate("(#foo=37;#foo.byteValue())",(byte)37,Byte.class); // calling byteValue() on Integer.class
evaluateAndAskForReturnType("(#foo=37;#foo)",(byte)37,Byte.class); // relying on registered type converters
evaluate("new Integer(37).byteValue()", (byte) 37, Byte.class); // calling byteValue() on Integer.class
evaluateAndAskForReturnType("new Integer(37)", (byte) 37, Byte.class); // relying on registered type converters
}
}
......@@ -35,12 +35,6 @@ public class ParserErrorMessagesTests extends ExpressionTestCase {
parseAndCheckError("0xB0BG", SpelMessages.PARSE_PROBLEM, 5, "mismatched input 'G' expecting EOF");
}
public void testBrokenExpression03() {
// too many closing brackets
parseAndCheckError("((3;4;)+(5;6;)))", SpelMessages.PARSE_PROBLEM, 15, "mismatched input ')' expecting EOF");
evaluate("((3;4;)+(5;6;))", 10 /* 4+6 */, Integer.class);
}
public void testBrokenExpression04() {
// missing right operand
parseAndCheckError("true or ", SpelMessages.PARSE_PROBLEM, -1, "no viable alternative at input '<EOF>'"); // POOR
......@@ -51,21 +45,10 @@ public class ParserErrorMessagesTests extends ExpressionTestCase {
parseAndCheckError("1 + ", SpelMessages.PARSE_PROBLEM, -1, "no viable alternative at input '<EOF>'"); // POOR
}
public void testBrokenExpression06() {
// expression list missing surrounding parentheses
parseAndCheckError("1;2;3", SpelMessages.PARSE_PROBLEM, 1, "mismatched input ';' expecting EOF"); // POOR
evaluate("(1;2;3)", 3, Integer.class);
}
public void testBrokenExpression07() {
// T() can only take an identifier (possibly qualified), not a literal
// message ought to say identifier rather than ID
parseAndCheckError("null is T('a')", SpelMessages.PARSE_PROBLEM, 10, "mismatched input ''a'' expecting ID"); // POOR
}
public void testExpressionLists02a() {
// either missing semi or rogue 5. RPAREN should at least be ')', and why doesn't it give the other possibles?
parseAndCheckError("( (3;4)5)", SpelMessages.PARSE_PROBLEM, 7, "mismatched input '5' expecting RPAREN"); // POOR
}
}
......@@ -22,7 +22,7 @@ import org.springframework.expression.ParseException;
/**
* Parse some expressions and check we get the AST we expect. Rather than inspecting each node in the AST, we ask it to
* write itself to a string form and check that is as expected.
*
*
* @author Andy Clement
*/
public class ParsingTests extends TestCase {
......@@ -360,14 +360,15 @@ public class ParsingTests extends TestCase {
parseCheck("{|x,y| $x > $y ? $x : $y }", "{|x,y| ($x > $y) ? $x : $y }");
}
public void testLambdaMax() {
parseCheck("(#max = {|x,y| $x > $y ? $x : $y }; #max(5,25))", "(#max={|x,y| ($x > $y) ? $x : $y };#max(5,25))");
}
public void testLambdaFactorial() {
parseCheck("(#fact = {|n| $n <= 1 ? 1 : $n * #fact($n-1) }; #fact(5))",
"(#fact={|n| ($n <= 1) ? 1 : ($n * #fact(($n - 1))) };#fact(5))");
} // 120
//
// public void testLambdaMax() {
// parseCheck("(#max = {|x,y| $x > $y ? $x : $y }; #max(5,25))", "(#max={|x,y| ($x > $y) ? $x : $y };#max(5,25))");
// }
//
// public void testLambdaFactorial() {
// parseCheck("(#fact = {|n| $n <= 1 ? 1 : $n * #fact($n-1) }; #fact(5))",
// "(#fact={|n| ($n <= 1) ? 1 : ($n * #fact(($n - 1))) };#fact(5))");
// } // 120
// Type references
public void testTypeReferences01() {
......@@ -378,39 +379,10 @@ public class ParsingTests extends TestCase {
parseCheck("T(String)");
}
// Nesting expressions and expression lists
public void testExpressionLists01() {
parseCheck("(3;4;5)");
}
public void testExpressionLists02() {
parseCheck("( (3;4);5)", "((3;4);5)");
}
public void testExpressionLists03() {
parseCheck("(3;(4;5))");
}
public void testExpressionLists04() {
parseCheck("((3;4;5))", "(3;4;5)");
}
public void testExpressionLists05() {
parseCheck("((3;4)+(5;6))", "((3;4) + (5;6))");
}
public void testExpressionLists06() {
parseCheck("((3;4;)+(5;6))", "((3;4) + (5;6))");
}
public void testExpressionLists07() {
parseCheck("((3;4;)+(5;6;))", "((3;4) + (5;6))");
}
/**
* Parse the supplied expression and then create a string representation of the resultant AST, it should be the same
* as the original expression.
*
*
* @param expression the expression to parse *and* the expected value of the string form of the resultant AST
*/
public void parseCheck(String expression) {
......@@ -420,7 +392,7 @@ public class ParsingTests extends TestCase {
/**
* Parse the supplied expression and then create a string representation of the resultant AST, it should be the
* expected value.
*
*
* @param expression the expression to parse
* @param expectedStringFormOfAST the expected string form of the AST
*/
......
......@@ -26,7 +26,6 @@ public class VariableAndFunctionTests extends ExpressionTestCase {
public void testVariableAccess() {
evaluate("#answer", "42", Integer.class, SHOULD_BE_WRITABLE);
evaluate("(#i=5;#i)", 5, Integer.class, SHOULD_BE_WRITABLE);
evaluate("#answer / 2", 21, Integer.class, SHOULD_NOT_BE_WRITABLE);
}
......@@ -40,40 +39,43 @@ public class VariableAndFunctionTests extends ExpressionTestCase {
evaluate("#reverseString('hello')", "olleh", String.class);
evaluate("#reverseString(37)", "73", String.class); // requires type conversion of 37 to '37'
}
public void testCallVarargsFunction() {
evaluate("#varargsFunctionReverseStringsAndMerge('a','b','c')","cba",String.class);
evaluate("#varargsFunctionReverseStringsAndMerge('a')","a",String.class);
evaluate("#varargsFunctionReverseStringsAndMerge()","",String.class);
evaluate("#varargsFunctionReverseStringsAndMerge('b',25)","25b",String.class);
evaluate("#varargsFunctionReverseStringsAndMerge(25)","25",String.class);
evaluate("#varargsFunctionReverseStringsAndMerge2(1,'a','b','c')","1cba",String.class);
evaluate("#varargsFunctionReverseStringsAndMerge2(2,'a')","2a",String.class);
evaluate("#varargsFunctionReverseStringsAndMerge2(3)","3",String.class);
evaluate("#varargsFunctionReverseStringsAndMerge2(4,'b',25)","425b",String.class);
evaluate("#varargsFunctionReverseStringsAndMerge2(5,25)","525",String.class);
evaluate("#varargsFunctionReverseStringsAndMerge('a','b','c')", "cba", String.class);
evaluate("#varargsFunctionReverseStringsAndMerge('a')", "a", String.class);
evaluate("#varargsFunctionReverseStringsAndMerge()", "", String.class);
evaluate("#varargsFunctionReverseStringsAndMerge('b',25)", "25b", String.class);
evaluate("#varargsFunctionReverseStringsAndMerge(25)", "25", String.class);
evaluate("#varargsFunctionReverseStringsAndMerge2(1,'a','b','c')", "1cba", String.class);
evaluate("#varargsFunctionReverseStringsAndMerge2(2,'a')", "2a", String.class);
evaluate("#varargsFunctionReverseStringsAndMerge2(3)", "3", String.class);
evaluate("#varargsFunctionReverseStringsAndMerge2(4,'b',25)", "425b", String.class);
evaluate("#varargsFunctionReverseStringsAndMerge2(5,25)", "525", String.class);
}
public void testCallingFunctionsIncorrectly() {
evaluateAndCheckError("#varargsFunctionReverseStringsAndMerge(new StringBuilder())",SpelMessages.TYPE_CONVERSION_ERROR);
evaluateAndCheckError("#varargsFunctionReverseStringsAndMerge(new StringBuilder())",
SpelMessages.TYPE_CONVERSION_ERROR);
}
public void testCallingIllegalFunctions() throws Exception {
SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = new StandardEvaluationContext();
ctx.setVariable("notStatic",this.getClass().getMethod("nonStatic"));
ctx.setVariable("notStatic", this.getClass().getMethod("nonStatic"));
try {
@SuppressWarnings("unused")
Object v = parser.parseExpression("#notStatic()").getValue(ctx);
fail("Should have failed with exception - cannot call non static method that way");
} catch (SpelException se) {
if (se.getMessageUnformatted()!=SpelMessages.FUNCTION_MUST_BE_STATIC) {
if (se.getMessageUnformatted() != SpelMessages.FUNCTION_MUST_BE_STATIC) {
se.printStackTrace();
fail("Should have failed a message about the function needing to be static, not: "+se.getMessageUnformatted());
fail("Should have failed a message about the function needing to be static, not: "
+ se.getMessageUnformatted());
}
}
}
public void nonStatic() {}
public void nonStatic() {
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册