diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java index d29770227a..e3355453cc 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java @@ -72,7 +72,7 @@ public class LookupAnnotationTests { assertEquals(TestBean.class, expected.getClass()); assertEquals("haha", expected.getName()); } - + @Test public void testWithTwoConstructorArg() { AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean"); @@ -82,7 +82,7 @@ public class LookupAnnotationTests { assertEquals("haha", expected.getName()); assertEquals(72, expected.getAge()); } - + @Test public void testWithThreeArgsShouldFail() { AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean"); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java index e9ce2b8200..21e6c72a7c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java @@ -67,7 +67,7 @@ public class LookupMethodTests { assertEquals(TestBean.class, expected.getClass()); assertEquals("haha", expected.getName()); } - + @Test public void testWithTwoConstructorArg() { AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean"); @@ -77,7 +77,7 @@ public class LookupMethodTests { assertEquals("haha", expected.getName()); assertEquals(72, expected.getAge()); } - + @Test public void testWithThreeArgsShouldFail() { AbstractBean bean = (AbstractBean) beanFactory.getBean("abstractBean"); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AutoProxyLazyInitTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AutoProxyLazyInitTests.java index a6042b693a..5c87b92043 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AutoProxyLazyInitTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AutoProxyLazyInitTests.java @@ -41,7 +41,7 @@ public class AutoProxyLazyInitTests { ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithStatic.class); MyBean bean = ctx.getBean("myBean", MyBean.class); - + assertFalse(MyBeanImpl.initialized); bean.doIt(); assertTrue(MyBeanImpl.initialized); diff --git a/spring-core/src/main/java/org/springframework/util/UpdateMessageDigestInputStream.java b/spring-core/src/main/java/org/springframework/util/UpdateMessageDigestInputStream.java index 3dc081e74e..37890be94f 100644 --- a/spring-core/src/main/java/org/springframework/util/UpdateMessageDigestInputStream.java +++ b/spring-core/src/main/java/org/springframework/util/UpdateMessageDigestInputStream.java @@ -28,7 +28,7 @@ import java.security.MessageDigest; * @since 4.2 */ abstract class UpdateMessageDigestInputStream extends InputStream { - + /** * Update the message digest with the rest of the bytes in this stream. *

Using this method is more optimized since it avoids creating new @@ -42,7 +42,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream { messageDigest.update((byte) data); } } - + /** * Update the message digest with the next len bytes in this stream. *

Using this method is more optimized since it avoids creating new diff --git a/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java b/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java index 52ef43eda6..1909011186 100644 --- a/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java +++ b/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java @@ -316,16 +316,16 @@ public class SettableListenableFutureTests { settableListenableFuture.setException(new RuntimeException()); verifyNoMoreInteractions(callback); } - + private static class InterruptableSettableListenableFuture extends SettableListenableFuture { private boolean interrupted = false; - + @Override protected void interruptTask() { interrupted = true; } - + boolean calledInterruptTask() { return interrupted; } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java index e698781aa5..db59a23915 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java @@ -56,7 +56,7 @@ public class CodeFlow implements Opcodes { * will be called after the main evaluation function has finished being generated. */ private List fieldAdders = null; - + /** * As SpEL ast nodes are called to generate code for the main evaluation method * they can register to add code to a static initializer in the class. Any @@ -64,19 +64,19 @@ public class CodeFlow implements Opcodes { * has finished being generated. */ private List clinitAdders = null; - + /** * Name of the class being generated. Typically used when generating code * that accesses freshly generated fields on the generated type. */ private String clazzName; - + /** * When code generation requires holding a value in a class level field, this * is used to track the next available field id (used as a name suffix). */ private int nextFieldId = 1; - + /** * When code generation requires an intermediate variable within a method, * this method records the next available variable (variable 0 is 'this'). @@ -222,7 +222,7 @@ public class CodeFlow implements Opcodes { mv.visitTypeInsn(CHECKCAST, "java/lang/Number"); } mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Number", "doubleValue", "()D", false); - break; + break; case 'F': if (stackDescriptor.equals("Ljava/lang/Object")) { mv.visitTypeInsn(CHECKCAST, "java/lang/Number"); @@ -246,7 +246,7 @@ public class CodeFlow implements Opcodes { throw new IllegalArgumentException("Unboxing should not be attempted for descriptor '" + targetDescriptor + "'"); } } - + /** * Insert any necessary numeric conversion bytecodes based upon what is on the stack and the desired target type. * @param mv the method visitor into which instructions should be placed @@ -327,7 +327,7 @@ public class CodeFlow implements Opcodes { } } - + /** * Create the JVM signature descriptor for a method. This consists of the descriptors * for the method parameters surrounded with parentheses, followed by the @@ -777,7 +777,7 @@ public class CodeFlow implements Opcodes { } return descriptors; } - + /** * Called after the main expression evaluation method has been generated, this * method will callback any registered FieldAdders or ClinitAdders to add any @@ -815,7 +815,7 @@ public class CodeFlow implements Opcodes { } /** - * Register a ClinitAdder which will add code to the static + * Register a ClinitAdder which will add code to the static * initializer in the generated class to support the code * produced by an ast nodes primary generateCode() method. */ @@ -837,11 +837,11 @@ public class CodeFlow implements Opcodes { public String getClassname() { return clazzName; } - + public interface FieldAdder { public void generateField(ClassWriter cw, CodeFlow codeflow); } - + public interface ClinitAdder { public void generateCode(MethodVisitor mv, CodeFlow codeflow); } @@ -863,11 +863,11 @@ public class CodeFlow implements Opcodes { } else { mv.visitLdcInsn(value); - } + } } /** - * Produce appropriate bytecode to store a stack item in an array. The + * Produce appropriate bytecode to store a stack item in an array. The * instruction to use varies depending on whether the type * is a primitive or reference type. * @param mv where to insert the bytecode @@ -901,7 +901,7 @@ public class CodeFlow implements Opcodes { public static int arrayCodeFor(String arraytype) { switch (arraytype.charAt(0)) { case 'I': return T_INT; - case 'J': return T_LONG; + case 'J': return T_LONG; case 'F': return T_FLOAT; case 'D': return T_DOUBLE; case 'B': return T_BYTE; @@ -925,9 +925,9 @@ public class CodeFlow implements Opcodes { } return false; } - + /** - * Produce the correct bytecode to build an array. The opcode to use and the + * Produce the correct bytecode to build an array. The opcode to use and the * signature to pass along with the opcode can vary depending on the signature * of the array type. * @param mv the methodvisitor into which code should be inserted @@ -972,5 +972,5 @@ public class CodeFlow implements Opcodes { } } - + } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/CompilablePropertyAccessor.java b/spring-expression/src/main/java/org/springframework/expression/spel/CompilablePropertyAccessor.java index 7ad99309dc..dcadffdf90 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/CompilablePropertyAccessor.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/CompilablePropertyAccessor.java @@ -21,7 +21,7 @@ import org.springframework.asm.Opcodes; import org.springframework.expression.PropertyAccessor; /** - * A compilable property accessor is able to generate bytecode that represents + * A compilable property accessor is able to generate bytecode that represents * the access operation, facilitating compilation to bytecode of expressions * that use the accessor. * diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/CompiledExpression.java b/spring-expression/src/main/java/org/springframework/expression/spel/CompiledExpression.java index a6e37b49a0..dc80e9cb52 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/CompiledExpression.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/CompiledExpression.java @@ -23,12 +23,12 @@ import org.springframework.expression.EvaluationException; * Base superclass for compiled expressions. Each generated compiled expression class * will extend this class and implement the {@link #getValue} method. It is not intended * to be subclassed by user code. - * + * * @author Andy Clement * @since 4.1 */ public abstract class CompiledExpression { - + /** * Subclasses of CompiledExpression generated by SpelCompiler will provide an * implementation of this method. diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/SpelMessage.java b/spring-expression/src/main/java/org/springframework/expression/spel/SpelMessage.java index b1e4c12c47..1431554a49 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/SpelMessage.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/SpelMessage.java @@ -250,7 +250,7 @@ public enum SpelMessage { MISSING_SELECTION_EXPRESSION(Kind.ERROR, 1071, "A required selection expression has not been specified"), - + EXCEPTION_RUNNING_COMPILED_EXPRESSION(Kind.ERROR,1072, "An exception occurred whilst evaluating a compiled expression"); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java index bda0744320..b7ef07ed77 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java @@ -622,7 +622,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { // '}' - end of list // ',' - more expressions in this list // ':' - this is a map! - + if (peekToken(TokenKind.RCURLY)) { // list with one item in it List listElements = new ArrayList(); listElements.add(firstExpression); @@ -638,7 +638,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { while (peekToken(TokenKind.COMMA,true)); closingCurly = eatToken(TokenKind.RCURLY); expr = new InlineList(toPos(t.startPos,closingCurly.endPos),listElements.toArray(new SpelNodeImpl[listElements.size()])); - + } else if (peekToken(TokenKind.COLON, true)) { // map! List mapElements = new ArrayList(); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java index 2e9ed08172..9ec6c8b83d 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java @@ -176,9 +176,9 @@ public class SpelCompiler implements Opcodes { mv.visitMaxs(0, 0); // not supplied due to COMPUTE_MAXS mv.visitEnd(); cw.visitEnd(); - + cf.finish(); - + byte[] data = cw.toByteArray(); // TODO need to make this conditionally occur based on a debug flag // dump(expressionToCompile.toStringAST(), clazzName, data); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java index 237e79d595..af4fbd36d6 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java @@ -66,7 +66,7 @@ public class SpelExpression implements Expression { // Count of many times as the expression been interpreted - can trigger compilation // when certain limit reached private volatile int interpretedCount = 0; - + // The number of times compilation was attempted and failed - enables us to eventually // give up trying to compile it when it just doesn't seem to be possible. private volatile int failedAttempts = 0; @@ -448,8 +448,8 @@ public class SpelExpression implements Expression { /** - * Perform expression compilation. This will only succeed once exit descriptors for all nodes have - * been determined. If the compilation fails and has failed more than 100 times the expression is + * Perform expression compilation. This will only succeed once exit descriptors for all nodes have + * been determined. If the compilation fails and has failed more than 100 times the expression is * no longer considered suitable for compilation. */ public boolean compileExpression() { diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java index 8cae22fada..17c0e5064a 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java @@ -239,7 +239,7 @@ public class ReflectionHelper { Integer varargsPosition = method.isVarArgs() ? method.getParameterTypes().length-1:null; return convertArguments(converter, arguments, method, varargsPosition); } - + /** * Takes an input set of argument values and converts them to the types specified as the * required parameter types. The arguments are converted 'in-place' in the input array. diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodExecutor.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodExecutor.java index 637385fdb6..ce23b3e881 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodExecutor.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodExecutor.java @@ -35,11 +35,11 @@ import org.springframework.util.ReflectionUtils; public class ReflectiveMethodExecutor implements MethodExecutor { private final Method method; - + private final Integer varargsPosition; private boolean computedPublicDeclaringClass = false; - + private Class publicDeclaringClass; private boolean argumentConversionOccurred = false; @@ -58,10 +58,10 @@ public class ReflectiveMethodExecutor implements MethodExecutor { public Method getMethod() { return this.method; } - + /** * Find the first public class in the methods declaring class hierarchy that declares this method. - * Sometimes the reflective method discovery logic finds a suitable method that can easily be + * Sometimes the reflective method discovery logic finds a suitable method that can easily be * called via reflection but cannot be called from generated code when compiling the expression * because of visibility restrictions. For example if a non public class overrides toString(), this * helper method will walk up the type hierarchy to find the first public type that declares the @@ -81,7 +81,7 @@ public class ReflectiveMethodExecutor implements MethodExecutor { clazz.getDeclaredMethod(method.getName(), method.getParameterTypes()); return clazz; } catch (NoSuchMethodException nsme) { - + } } Class[] intfaces = clazz.getInterfaces(); @@ -93,7 +93,7 @@ public class ReflectiveMethodExecutor implements MethodExecutor { } return null; } - + public boolean didArgumentConversionOccur() { return this.argumentConversionOccurred; } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java index ea805a331d..21e8dd4ba5 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java @@ -120,7 +120,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor { } return false; } - + public Member getLastReadInvokerPair() { return lastReadInvokerPair.member; } @@ -656,7 +656,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor { public void write(EvaluationContext context, Object target, String name, Object newValue) { throw new UnsupportedOperationException("Should not be called on an OptimalPropertyAccessor"); } - + @Override public boolean isCompilable() { return (Modifier.isPublic(this.member.getModifiers()) && diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java index 209224a016..de17ed7c5b 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java @@ -465,7 +465,7 @@ public class EvaluationTests extends AbstractExpressionTests { assertEquals("T(java.lang.String)", expr.toStringAST()); assertEquals(String.class, expr.getValue(Class.class)); } - + @Test public void operatorVariants() throws Exception { SpelExpression expr = (SpelExpression)parser.parseExpression("#a < #b"); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/MapTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/MapTests.java index 05cc6cd10c..c0e023c950 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/MapTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/MapTests.java @@ -78,7 +78,7 @@ public class MapTests extends AbstractExpressionTests { public void testInlineMapWithFunkyKeys() { evaluate("{#root.name:true}","{Nikola Tesla=true}",LinkedHashMap.class); } - + @Test public void testInlineMapError() { parseAndCheckError("{key:'abc'", SpelMessage.OOD); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java index 5d26439e87..34954ae5ed 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java @@ -75,12 +75,12 @@ public class SetValueTests extends AbstractExpressionTests { setValue("arrayContainer.bytes[1]", (byte) 3); setValue("arrayContainer.chars[1]", (char) 3); } - + @Test public void testIsWritableForInvalidExpressions_SPR10610() { Expression e = null; StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext(); - + // PROPERTYORFIELDREFERENCE // Non existent field (or property): e = parser.parseExpression("arrayContainer.wibble"); @@ -95,7 +95,7 @@ public class SetValueTests extends AbstractExpressionTests { // at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:225) // success! } - + // VARIABLE // the variable does not exist (but that is OK, we should be writable) e = parser.parseExpression("#madeup1"); @@ -103,7 +103,7 @@ public class SetValueTests extends AbstractExpressionTests { e = parser.parseExpression("#madeup2.bar"); // compound expression assertFalse("Should not be writable!",e.isWritable(lContext)); - + // INDEXER // non existent indexer (wibble made up) e = parser.parseExpression("arrayContainer.wibble[99]"); @@ -113,7 +113,7 @@ public class SetValueTests extends AbstractExpressionTests { } catch (SpelEvaluationException see) { // success! } - + // non existent indexer (index via a string) e = parser.parseExpression("arrayContainer.ints['abc']"); try { diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java index a2c429d13c..cf7662c0e5 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java @@ -49,13 +49,13 @@ import static org.junit.Assert.*; * @since 4.1 */ public class SpelCompilationCoverageTests extends AbstractExpressionTests { - + private Expression expression; private SpelNodeImpl ast; - + /* * Further TODOs for compilation: - * + * * - OpMinus with a single literal operand could be treated as a negative literal. Will save a * pointless loading of 0 and then a subtract instruction in code gen. * - allow other accessors/resolvers to participate in compilation and create their own code @@ -65,10 +65,10 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { * - The opEq implementation is quite basic. It will compare numbers of the same type (allowing * them to be their boxed or unboxed variants) or compare object references. It does not * compile expressions where numbers are of different types or when objects implement - * Comparable. + * Comparable. * * Compiled nodes: - * + * * TypeReference * OperatorInstanceOf * StringLiteral @@ -102,7 +102,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { * FunctionReference * InlineList * OpModulus - * + * * Not yet compiled (some may never need to be): * Assign * BeanReference @@ -116,14 +116,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { * QualifiedId * Selection */ - + @Test public void typeReference() throws Exception { expression = parse("T(String)"); assertEquals(String.class,expression.getValue()); assertCanCompile(expression); assertEquals(String.class,expression.getValue()); - + expression = parse("T(java.io.IOException)"); assertEquals(IOException.class,expression.getValue()); assertCanCompile(expression); @@ -178,7 +178,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(Boolean.TYPE,expression.getValue()); assertCanCompile(expression); assertEquals(Boolean.TYPE,expression.getValue()); - + expression = parse("T(Missing)"); assertGetValueFail(expression); assertCantCompile(expression); @@ -208,7 +208,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(true,expression.getValue(arrayOfLists)); assertCanCompile(expression); assertEquals(true,expression.getValue(arrayOfLists)); - + int[] intArray = new int[]{1,2,3}; expression = parse("#root instanceof T(int[])"); assertEquals(true,expression.getValue(intArray)); @@ -236,7 +236,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { @Test public void stringLiteral() throws Exception { - expression = parser.parseExpression("'abcde'"); + expression = parser.parseExpression("'abcde'"); assertEquals("abcde",expression.getValue(new TestClass1(),String.class)); assertCanCompile(expression); String resultC = expression.getValue(new TestClass1(),String.class); @@ -248,7 +248,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals("abcde",expression.getValue(String.class)); } - + @Test public void nullLiteral() throws Exception { expression = parser.parseExpression("null"); @@ -259,7 +259,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(null,resultC); assertEquals(null,resultC); } - + @Test public void realLiteral() throws Exception { expression = parser.parseExpression("3.4d"); @@ -271,7 +271,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(3.4d,expression.getValue()); } - + @SuppressWarnings("rawtypes") @Test public void inlineList() throws Exception { @@ -281,21 +281,21 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); o = expression.getValue(); assertEquals("bcde", o); - + expression = parser.parseExpression("{'abc','def'}"); List l = (List) expression.getValue(); assertEquals("[abc, def]", l.toString()); assertCanCompile(expression); l = (List) expression.getValue(); assertEquals("[abc, def]", l.toString()); - + expression = parser.parseExpression("{'abc','def'}[0]"); o = expression.getValue(); assertEquals("abc",o); assertCanCompile(expression); o = expression.getValue(); assertEquals("abc", o); - + expression = parser.parseExpression("{'abcde','ijklm'}[0].substring({1,3,4}[0])"); o = expression.getValue(); assertEquals("bcde",o); @@ -315,7 +315,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { @Test public void nestedInlineLists() throws Exception { Object o = null; - + expression = parser.parseExpression("{{1,2,3},{4,5,6},{7,8,9}}"); o = expression.getValue(); assertEquals("[[1, 2, 3], [4, 5, 6], [7, 8, 9]]",o.toString()); @@ -336,7 +336,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); o = expression.getValue(); assertEquals(4,o); - + expression = parser.parseExpression("{{1,2,3},'abc',{7,8,9}}[1]"); o = expression.getValue(); assertEquals("abc",o); @@ -357,7 +357,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); o = expression.getValue(); assertEquals("bcde", o); - + expression = parser.parseExpression("{'abc',{'def','ghi'}}"); List l = (List) expression.getValue(); assertEquals("[abc, [def, ghi]]", l.toString()); @@ -371,7 +371,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); o = expression.getValue(); assertEquals("bcde", o); - + expression = parser.parseExpression("{'abcde',{'ijklm','nopqr'}}[1][0].substring({1,3,4}[0])"); o = expression.getValue(); assertEquals("jklm",o); @@ -400,10 +400,10 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(Integer.class); assertCanCompile(expression); assertEquals(new Integer(42),expression.getValue(null,Integer.class)); - + // Code gen is different for -1 .. 6 because there are bytecode instructions specifically for those // values - + // Not an int literal but an opminus with one operand: // expression = parser.parseExpression("-1"); // assertCanCompile(expression); @@ -418,7 +418,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals(7,expression.getValue()); } - + @Test public void longLiteral() throws Exception { expression = parser.parseExpression("99L"); @@ -426,9 +426,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); long resultC = expression.getValue(new TestClass1(),Long.TYPE); assertEquals(99L,resultI); - assertEquals(99L,resultC); + assertEquals(99L,resultC); } - + @Test public void booleanLiteral() throws Exception { expression = parser.parseExpression("true"); @@ -437,7 +437,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue(SpelCompiler.compile(expression)); boolean resultC = expression.getValue(1,Boolean.TYPE); assertEquals(true,resultC); - + expression = parser.parseExpression("false"); resultI = expression.getValue(1,Boolean.TYPE); assertEquals(false,resultI); @@ -445,7 +445,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { resultC = expression.getValue(1,Boolean.TYPE); assertEquals(false,resultC); } - + @Test public void floatLiteral() throws Exception { expression = parser.parseExpression("3.4f"); @@ -457,7 +457,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(3.4f,expression.getValue()); } - + @Test public void opOr() throws Exception { Expression expression = parser.parseExpression("false or false"); @@ -466,21 +466,21 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { boolean resultC = expression.getValue(1,Boolean.TYPE); assertEquals(false,resultI); assertEquals(false,resultC); - + expression = parser.parseExpression("false or true"); resultI = expression.getValue(1,Boolean.TYPE); assertCanCompile(expression); resultC = expression.getValue(1,Boolean.TYPE); assertEquals(true,resultI); assertEquals(true,resultC); - + expression = parser.parseExpression("true or false"); resultI = expression.getValue(1,Boolean.TYPE); assertCanCompile(expression); resultC = expression.getValue(1,Boolean.TYPE); assertEquals(true,resultI); assertEquals(true,resultC); - + expression = parser.parseExpression("true or true"); resultI = expression.getValue(1,Boolean.TYPE); assertCanCompile(expression); @@ -500,7 +500,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parser.parseExpression("gettrue() or getfalse()"); resultI = expression.getValue(tc,Boolean.TYPE); assertCantCompile(expression); - + expression = parser.parseExpression("getA() or getB()"); tc.a = true; tc.b = true; @@ -511,7 +511,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { resultI = expression.getValue(tc,Boolean.TYPE); assertCanCompile(expression); // Now been down both assertTrue(resultI); - + boolean b = false; expression = parse("#root or #root"); Object resultI2 = expression.getValue(b); @@ -519,7 +519,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertFalse((Boolean)resultI2); assertFalse((Boolean)expression.getValue(b)); } - + @Test public void opAnd() throws Exception { Expression expression = parser.parseExpression("false and false"); @@ -535,7 +535,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { resultC = expression.getValue(1,Boolean.TYPE); assertEquals(false,resultI); assertEquals(false,resultC); - + expression = parser.parseExpression("true and false"); resultI = expression.getValue(1,Boolean.TYPE); SpelCompiler.compile(expression); @@ -549,14 +549,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { resultC = expression.getValue(1,Boolean.TYPE); assertEquals(true,resultI); assertEquals(true,resultC); - + TestClass4 tc = new TestClass4(); // Can't compile this as we aren't going down the gettrue() branch in our evaluation expression = parser.parseExpression("getfalse() and gettrue()"); resultI = expression.getValue(tc,Boolean.TYPE); assertCantCompile(expression); - + expression = parser.parseExpression("getA() and getB()"); tc.a = false; tc.b = false; @@ -571,7 +571,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { tc.b = true; resultI = expression.getValue(tc,Boolean.TYPE); assertTrue(resultI); - + boolean b = true; expression = parse("#root and #root"); Object resultI2 = expression.getValue(b); @@ -579,7 +579,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue((Boolean)resultI2); assertTrue((Boolean)expression.getValue(b)); } - + @Test public void operatorNot() throws Exception { expression = parse("!true"); @@ -613,7 +613,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { String resultC = expression.getValue(String.class); assertEquals("a",resultI); assertEquals("a",resultC); - + expression = parser.parseExpression("false?'a':'b'"); resultI = expression.getValue(String.class); assertCanCompile(expression); @@ -635,9 +635,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals(3L,expression.getValue(root)); root = true; - assertEquals(1,expression.getValue(root)); + assertEquals(1,expression.getValue(root)); } - + @Test public void ternaryWithBooleanReturn() { // SPR-12271 expression = parser.parseExpression("T(Boolean).TRUE?'abc':'def'"); @@ -650,7 +650,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals("def",expression.getValue()); } - + @Test public void elvis() throws Exception { Expression expression = parser.parseExpression("'a'?:'b'"); @@ -659,14 +659,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { String resultC = expression.getValue(String.class); assertEquals("a",resultI); assertEquals("a",resultC); - + expression = parser.parseExpression("null?:'a'"); resultI = expression.getValue(String.class); assertCanCompile(expression); resultC = expression.getValue(String.class); assertEquals("a",resultI); assertEquals("a",resultC); - + String s = "abc"; expression = parser.parseExpression("#root?:'b'"); assertCantCompile(expression); @@ -674,7 +674,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("abc",resultI); assertCanCompile(expression); } - + @Test public void variableReference_root() throws Exception { String s = "hello"; @@ -683,7 +683,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); String resultC = expression.getValue(s,String.class); assertEquals(s,resultI); - assertEquals(s,resultC); + assertEquals(s,resultC); expression = parser.parseExpression("#root"); int i = (Integer)expression.getValue(42); @@ -692,11 +692,11 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { i = (Integer)expression.getValue(42); assertEquals(42,i); } - + public static String concat(String a, String b) { return a+b; } - + public static String join(String...strings) { StringBuilder buf = new StringBuilder(); for (String string: strings) { @@ -704,7 +704,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } return buf.toString(); } - + @Test public void compiledExpressionShouldWorkWhenUsingCustomFunctionWithVarargs() throws Exception { StandardEvaluationContext context = null; @@ -747,23 +747,23 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals("hey there", expression.getValue(String.class)); } - + @Test public void functionReference() throws Exception { EvaluationContext ctx = new StandardEvaluationContext(); Method m = this.getClass().getDeclaredMethod("concat",String.class,String.class); ctx.setVariable("concat",m); - + expression = parser.parseExpression("#concat('a','b')"); assertEquals("ab",expression.getValue(ctx)); assertCanCompile(expression); assertEquals("ab",expression.getValue(ctx)); - + expression = parser.parseExpression("#concat(#concat('a','b'),'c').charAt(1)"); assertEquals('b',expression.getValue(ctx)); assertCanCompile(expression); assertEquals('b',expression.getValue(ctx)); - + expression = parser.parseExpression("#concat(#a,#b)"); ctx.setVariable("a", "foo"); ctx.setVariable("b", "bar"); @@ -772,7 +772,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("foobar",expression.getValue(ctx)); ctx.setVariable("b", "boo"); assertEquals("fooboo",expression.getValue(ctx)); - + m = Math.class.getDeclaredMethod("pow",Double.TYPE,Double.TYPE); ctx.setVariable("kapow",m); expression = parser.parseExpression("#kapow(2.0d,2.0d)"); @@ -792,7 +792,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parser.parseExpression("#doCompare([0],#arg)"); assertEquals("-1",expression.getValue(context, Integer.class).toString()); assertCantCompile(expression); - + // type not public but method is context = new StandardEvaluationContext(new Object[] { "1" }); context.registerFunction("doCompare", SomeCompareMethod.class.getDeclaredMethod( @@ -802,7 +802,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("-1",expression.getValue(context, Integer.class).toString()); assertCantCompile(expression); } - + @Test public void functionReferenceNonCompilableArguments_SPR12359() throws Exception { StandardEvaluationContext context = new StandardEvaluationContext(new Object[] { "1" }); @@ -817,8 +817,8 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { // Selection isn't compilable. assertFalse(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); } - - @Test + + @Test public void functionReferenceVarargs_SPR12359() throws Exception { StandardEvaluationContext context = new StandardEvaluationContext(); context.registerFunction("append", @@ -859,20 +859,20 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); assertCanCompile(expression); assertEquals("",expression.getValue(context).toString()); - + expression = parser.parseExpression("#append(#stringArray)"); assertEquals("xyz",expression.getValue(context).toString()); assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); assertCanCompile(expression); assertEquals("xyz",expression.getValue(context).toString()); - + // This is a methodreference invocation, to compare with functionreference expression = parser.parseExpression("append(#stringArray)"); assertEquals("xyz",expression.getValue(context,new SomeCompareMethod2()).toString()); assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); assertCanCompile(expression); assertEquals("xyz",expression.getValue(context,new SomeCompareMethod2()).toString()); - + expression = parser.parseExpression("#append2('a','b','c')"); assertEquals("abc",expression.getValue(context).toString()); assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); @@ -896,7 +896,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); assertCanCompile(expression); assertEquals("",expression.getValue(context).toString()); - + expression = parser.parseExpression("#append3(#stringArray)"); assertEquals("xyz",expression.getValue(context, new SomeCompareMethod2()).toString()); assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); @@ -909,7 +909,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { // assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); // assertCanCompile(expression); // assertEquals("xyz",expression.getValue(context).toString()); - + expression = parser.parseExpression("#sum(1,2,3)"); assertEquals(6,expression.getValue(context)); assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); @@ -927,13 +927,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); assertCanCompile(expression); assertEquals(0,expression.getValue(context)); - + expression = parser.parseExpression("#sum(#intArray)"); assertEquals(20,expression.getValue(context)); assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); assertCanCompile(expression); assertEquals(20,expression.getValue(context)); - + expression = parser.parseExpression("#sumDouble(1.0d,2.0d,3.0d)"); assertEquals(6,expression.getValue(context)); assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); @@ -951,7 +951,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); assertCanCompile(expression); assertEquals(0,expression.getValue(context)); - + expression = parser.parseExpression("#sumDouble(#doubleArray)"); assertEquals(20,expression.getValue(context)); assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); @@ -975,21 +975,21 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); assertCanCompile(expression); assertEquals(0,expression.getValue(context)); - + expression = parser.parseExpression("#sumFloat(#floatArray)"); assertEquals(20,expression.getValue(context)); assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); assertCanCompile(expression); assertEquals(20,expression.getValue(context)); - - + + expression = parser.parseExpression("#appendChar('abc'.charAt(0),'abc'.charAt(1))"); assertEquals("ab",expression.getValue(context)); assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); assertCanCompile(expression); assertEquals("ab",expression.getValue(context)); - - + + expression = parser.parseExpression("#append4('a','b','c')"); assertEquals("a::bc",expression.getValue(context).toString()); assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); @@ -1007,14 +1007,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); assertCanCompile(expression); assertEquals("a::",expression.getValue(context).toString()); - + expression = parser.parseExpression("#append4('a',#stringArray)"); assertEquals("a::xyz",expression.getValue(context).toString()); assertTrue(((SpelNodeImpl)((SpelExpression)expression).getAST()).isCompilable()); assertCanCompile(expression); assertEquals("a::xyz",expression.getValue(context).toString()); } - + @Test public void functionReferenceVarargs() throws Exception { EvaluationContext ctx = new StandardEvaluationContext(); @@ -1025,7 +1025,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals("abc",expression.getValue(ctx)); } - + @Test public void variableReference_userDefined() throws Exception { EvaluationContext ctx = new StandardEvaluationContext(); @@ -1033,9 +1033,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parser.parseExpression("#target"); assertEquals("abc",expression.getValue(ctx)); assertCanCompile(expression); - assertEquals("abc",expression.getValue(ctx)); + assertEquals("abc",expression.getValue(ctx)); ctx.setVariable("target", "123"); - assertEquals("123",expression.getValue(ctx)); + assertEquals("123",expression.getValue(ctx)); ctx.setVariable("target", 42); try { assertEquals(42,expression.getValue(ctx)); @@ -1043,14 +1043,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } catch (SpelEvaluationException see) { assertTrue(see.getCause() instanceof ClassCastException); } - + ctx.setVariable("target", "abc"); expression = parser.parseExpression("#target.charAt(0)"); assertEquals('a',expression.getValue(ctx)); assertCanCompile(expression); - assertEquals('a',expression.getValue(ctx)); + assertEquals('a',expression.getValue(ctx)); ctx.setVariable("target", "1"); - assertEquals('1',expression.getValue(ctx)); + assertEquals('1',expression.getValue(ctx)); ctx.setVariable("target", 42); try { assertEquals('4',expression.getValue(ctx)); @@ -1059,7 +1059,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue(see.getCause() instanceof ClassCastException); } } - + @Test public void opLt() throws Exception { expression = parse("3.0d < 4.0d"); @@ -1075,25 +1075,25 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parse("2 < 4"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + expression = parse("3.0f < 1.0f"); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); expression = parse("1.0f < 5.0f"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + expression = parse("30L < 30L"); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); expression = parse("15L < 20L"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + // Differing types of number, not yet supported expression = parse("1 < 3.0d"); assertCantCompile(expression); - + expression = parse("T(Integer).valueOf(3) < 4"); assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); @@ -1109,7 +1109,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); } - + @Test public void opLe() throws Exception { expression = parse("3.0d <= 4.0d"); @@ -1131,7 +1131,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parse("3 <= 3"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + expression = parse("3.0f <= 1.0f"); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); @@ -1141,14 +1141,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parse("2.0f <= 2.0f"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + expression = parse("30L <= 30L"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); expression = parse("15L <= 20L"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + // Differing types of number, not yet supported expression = parse("1 <= 3.0d"); assertCantCompile(expression); @@ -1168,8 +1168,8 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); } - - + + @Test public void opGt() throws Exception { expression = parse("3.0d > 4.0d"); @@ -1185,21 +1185,21 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parse("2 > 4"); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("3.0f > 1.0f"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); expression = parse("1.0f > 5.0f"); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("30L > 30L"); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); expression = parse("15L > 20L"); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + // Differing types of number, not yet supported expression = parse("1 > 3.0d"); assertCantCompile(expression); @@ -1208,7 +1208,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("T(Integer).valueOf(3) > T(Integer).valueOf(3)"); assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); @@ -1219,7 +1219,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); } - + @Test public void opGe() throws Exception { expression = parse("3.0d >= 4.0d"); @@ -1241,7 +1241,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parse("3 >= 3"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + expression = parse("3.0f >= 1.0f"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); @@ -1251,7 +1251,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parse("3.0f >= 3.0f"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + expression = parse("40L >= 30L"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); @@ -1261,7 +1261,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parse("30L >= 30L"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + // Differing types of number, not yet supported expression = parse("1 >= 3.0d"); assertCantCompile(expression); @@ -1270,7 +1270,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("T(Integer).valueOf(3) >= T(Integer).valueOf(3)"); assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); @@ -1281,7 +1281,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); } - + @Test public void opEq() throws Exception { String tvar = "35"; @@ -1315,8 +1315,8 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue((Boolean)expression.getValue(tc7)); assertCanCompile(expression); assertTrue((Boolean)expression.getValue(tc7)); - - + + expression = parse("3.0d == 4.0d"); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); @@ -1330,31 +1330,31 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parse("3 == 3"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + expression = parse("3.0f == 1.0f"); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); expression = parse("2.0f == 2.0f"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + expression = parse("30L == 30L"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); expression = parse("15L == 20L"); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + // number types are not the same expression = parse("1 == 3.0d"); assertCantCompile(expression); - + Double d = 3.0d; expression = parse("#root==3.0d"); assertTrue((Boolean)expression.getValue(d)); assertCanCompile(expression); assertTrue((Boolean)expression.getValue(d)); - + Integer i = 3; expression = parse("#root==3"); assertTrue((Boolean)expression.getValue(i)); @@ -1366,13 +1366,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue((Boolean)expression.getValue(f)); assertCanCompile(expression); assertTrue((Boolean)expression.getValue(f)); - + long l = 300l; expression = parse("#root==300l"); assertTrue((Boolean)expression.getValue(l)); assertCanCompile(expression); assertTrue((Boolean)expression.getValue(l)); - + boolean b = true; expression = parse("#root==true"); assertTrue((Boolean)expression.getValue(b)); @@ -1383,7 +1383,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("T(Integer).valueOf(3) == T(Integer).valueOf(3)"); assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); @@ -1398,7 +1398,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("T(Float).valueOf(3.0f) == T(Float).valueOf(3.0f)"); assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); @@ -1408,12 +1408,12 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("T(Long).valueOf(3L) == 4L"); assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("T(Long).valueOf(3L) == T(Long).valueOf(3L)"); assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); @@ -1422,13 +1422,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parse("5L == T(Long).valueOf(3L)"); assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); - assertFalse((Boolean)expression.getValue()); - + assertFalse((Boolean)expression.getValue()); + expression = parse("T(Double).valueOf(3.0d) == 4.0d"); assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("T(Double).valueOf(3.0d) == T(Double).valueOf(3.0d)"); assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); @@ -1443,7 +1443,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("T(Boolean).valueOf('true') == T(Boolean).valueOf('true')"); assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); @@ -1475,30 +1475,30 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parse("3 != 3"); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("3.0f != 1.0f"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); expression = parse("2.0f != 2.0f"); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("30L != 30L"); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); expression = parse("15L != 20L"); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + // not compatible number types - expression = parse("1 != 3.0d"); + expression = parse("1 != 3.0d"); assertCantCompile(expression); expression = parse("T(Integer).valueOf(3) != 4"); assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + expression = parse("T(Integer).valueOf(3) != T(Integer).valueOf(3)"); assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); @@ -1513,7 +1513,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + expression = parse("T(Float).valueOf(3.0f) != T(Float).valueOf(3.0f)"); assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); @@ -1523,12 +1523,12 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + expression = parse("T(Long).valueOf(3L) != 4L"); assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); - + expression = parse("T(Long).valueOf(3L) != T(Long).valueOf(3L)"); assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); @@ -1537,13 +1537,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parse("5L != T(Long).valueOf(3L)"); assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); - assertTrue((Boolean)expression.getValue()); - + assertTrue((Boolean)expression.getValue()); + expression = parse("T(Double).valueOf(3.0d) == 4.0d"); assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("T(Double).valueOf(3.0d) == T(Double).valueOf(3.0d)"); assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); @@ -1558,7 +1558,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertFalse((Boolean)expression.getValue()); assertCanCompile(expression); assertFalse((Boolean)expression.getValue()); - + expression = parse("T(Boolean).valueOf('true') == T(Boolean).valueOf('true')"); assertTrue((Boolean)expression.getValue()); assertCanCompile(expression); @@ -1574,14 +1574,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertTrue((Boolean)expression.getValue()); } - + @Test public void opPlus() throws Exception { expression = parse("2+2"); expression.getValue(); assertCanCompile(expression); assertEquals(4,expression.getValue()); - + expression = parse("2L+2L"); expression.getValue(); assertCanCompile(expression); @@ -1596,37 +1596,37 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(); assertCanCompile(expression); assertEquals(7.0d,expression.getValue()); - + expression = parse("+1"); expression.getValue(); assertCanCompile(expression); - assertEquals(1,expression.getValue()); + assertEquals(1,expression.getValue()); expression = parse("+1L"); expression.getValue(); assertCanCompile(expression); - assertEquals(1L,expression.getValue()); + assertEquals(1L,expression.getValue()); expression = parse("+1.5f"); expression.getValue(); assertCanCompile(expression); - assertEquals(1.5f,expression.getValue()); + assertEquals(1.5f,expression.getValue()); expression = parse("+2.5d"); expression.getValue(); assertCanCompile(expression); - assertEquals(2.5d,expression.getValue()); + assertEquals(2.5d,expression.getValue()); expression = parse("+T(Double).valueOf(2.5d)"); expression.getValue(); assertCanCompile(expression); - assertEquals(2.5d,expression.getValue()); - + assertEquals(2.5d,expression.getValue()); + expression = parse("T(Integer).valueOf(2)+6"); assertEquals(8,expression.getValue()); assertCanCompile(expression); assertEquals(8,expression.getValue()); - + expression = parse("T(Integer).valueOf(1)+T(Integer).valueOf(3)"); assertEquals(4,expression.getValue()); assertCanCompile(expression); @@ -1641,7 +1641,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(8.0f,expression.getValue()); assertCanCompile(expression); assertEquals(8.0f,expression.getValue()); - + expression = parse("T(Float).valueOf(2.0f)+T(Float).valueOf(3.0f)"); assertEquals(5.0f,expression.getValue()); assertCanCompile(expression); @@ -1656,7 +1656,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(8L,expression.getValue()); assertCanCompile(expression); assertEquals(8L,expression.getValue()); - + expression = parse("T(Long).valueOf(2L)+T(Long).valueOf(3L)"); assertEquals(5L,expression.getValue()); assertCanCompile(expression); @@ -1665,9 +1665,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parse("1L+T(Long).valueOf(2L)"); assertEquals(3L,expression.getValue()); assertCanCompile(expression); - assertEquals(3L,expression.getValue()); + assertEquals(3L,expression.getValue()); } - + public class PayloadX { public int valueI = 120; public Integer valueIB = 120; @@ -1689,8 +1689,8 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { public byte valueB18 = (byte)18; public byte valueB20 = (byte)20; public Byte valueBB = (byte)120; - public Byte valueBB18 = (byte)18; - public Byte valueBB20 = (byte)20; + public Byte valueBB18 = (byte)18; + public Byte valueBB20 = (byte)20; public char valueC = (char)120; public Character valueCB = (char)120; public short valueS = (short)120; @@ -1704,14 +1704,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { payload = this; } } - + @Test public void opDivide_mixedNumberTypes() throws Exception { PayloadX p = new PayloadX(); - + // This is what you had to do before the changes in order for it to compile: // expression = parse("(T(java.lang.Double).parseDouble(payload.valueI.toString()))/60D"); - + // right is a double checkCalc(p,"payload.valueSB/60D",2d); checkCalc(p,"payload.valueBB/60D",2d); @@ -1740,7 +1740,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD/payload.valueDB60",2d); checkCalc(p,"payload.valueJ/payload.valueDB60",2d); checkCalc(p,"payload.valueI/payload.valueDB60",2d); - + // right is a float checkCalc(p,"payload.valueSB/60F",2F); checkCalc(p,"payload.valueBB/60F",2F); @@ -1755,7 +1755,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD/60F",2d); checkCalc(p,"payload.valueJ/60F",2F); checkCalc(p,"payload.valueI/60F",2F); - + checkCalc(p,"payload.valueSB/payload.valueFB60",2F); checkCalc(p,"payload.valueBB/payload.valueFB60",2F); checkCalc(p,"payload.valueFB/payload.valueFB60",2f); @@ -1813,7 +1813,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD/60",2d); checkCalc(p,"payload.valueJ/60",2L); checkCalc(p,"payload.valueI/60",2); - + checkCalc(p,"payload.valueSB/payload.valueIB60",2); checkCalc(p,"payload.valueBB/payload.valueIB60",2); checkCalc(p,"payload.valueFB/payload.valueIB60",2f); @@ -1827,7 +1827,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD/payload.valueIB60",2d); checkCalc(p,"payload.valueJ/payload.valueIB60",2L); checkCalc(p,"payload.valueI/payload.valueIB60",2); - + // right is a short checkCalc(p,"payload.valueSB/payload.valueS",1); checkCalc(p,"payload.valueBB/payload.valueS",1); @@ -1886,14 +1886,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueJ/payload.valueBB",1L); checkCalc(p,"payload.valueI/payload.valueBB",1); } - + @Test public void opPlus_mixedNumberTypes() throws Exception { PayloadX p = new PayloadX(); - + // This is what you had to do before the changes in order for it to compile: // expression = parse("(T(java.lang.Double).parseDouble(payload.valueI.toString()))/60D"); - + // right is a double checkCalc(p,"payload.valueSB+60D",180d); checkCalc(p,"payload.valueBB+60D",180d); @@ -1922,7 +1922,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD+payload.valueDB60",180d); checkCalc(p,"payload.valueJ+payload.valueDB60",180d); checkCalc(p,"payload.valueI+payload.valueDB60",180d); - + // right is a float checkCalc(p,"payload.valueSB+60F",180F); checkCalc(p,"payload.valueBB+60F",180F); @@ -1937,7 +1937,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD+60F",180d); checkCalc(p,"payload.valueJ+60F",180F); checkCalc(p,"payload.valueI+60F",180F); - + checkCalc(p,"payload.valueSB+payload.valueFB60",180F); checkCalc(p,"payload.valueBB+payload.valueFB60",180F); checkCalc(p,"payload.valueFB+payload.valueFB60",180f); @@ -1995,7 +1995,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD+60",180d); checkCalc(p,"payload.valueJ+60",180L); checkCalc(p,"payload.valueI+60",180); - + checkCalc(p,"payload.valueSB+payload.valueIB60",180); checkCalc(p,"payload.valueBB+payload.valueIB60",180); checkCalc(p,"payload.valueFB+payload.valueIB60",180f); @@ -2009,7 +2009,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD+payload.valueIB60",180d); checkCalc(p,"payload.valueJ+payload.valueIB60",180L); checkCalc(p,"payload.valueI+payload.valueIB60",180); - + // right is a short checkCalc(p,"payload.valueSB+payload.valueS",240); checkCalc(p,"payload.valueBB+payload.valueS",240); @@ -2068,35 +2068,35 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueJ+payload.valueBB",240L); checkCalc(p,"payload.valueI+payload.valueBB",240); } - + private void checkCalc(PayloadX p, String expression, int expectedResult) { Expression expr = parse(expression); assertEquals(expectedResult,expr.getValue(p)); assertCanCompile(expr); - assertEquals(expectedResult,expr.getValue(p)); + assertEquals(expectedResult,expr.getValue(p)); } private void checkCalc(PayloadX p, String expression, float expectedResult) { Expression expr = parse(expression); assertEquals(expectedResult,expr.getValue(p)); assertCanCompile(expr); - assertEquals(expectedResult,expr.getValue(p)); + assertEquals(expectedResult,expr.getValue(p)); } - + private void checkCalc(PayloadX p, String expression, long expectedResult) { Expression expr = parse(expression); assertEquals(expectedResult,expr.getValue(p)); assertCanCompile(expr); - assertEquals(expectedResult,expr.getValue(p)); + assertEquals(expectedResult,expr.getValue(p)); } private void checkCalc(PayloadX p, String expression, double expectedResult) { Expression expr = parse(expression); assertEquals(expectedResult,expr.getValue(p)); assertCanCompile(expr); - assertEquals(expectedResult,expr.getValue(p)); + assertEquals(expectedResult,expr.getValue(p)); } - + @Test public void opPlusString() throws Exception { expression = parse("'hello' + 'world'"); @@ -2109,7 +2109,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("helloworld",expression.getValue(new Greeter())); assertCanCompile(expression); assertEquals("helloworld",expression.getValue(new Greeter())); - + // Method with string return expression = parse("getWorld() + 'hello'"); assertEquals("worldhello",expression.getValue(new Greeter())); @@ -2121,17 +2121,17 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("helloworld spring",expression.getValue(new Greeter())); assertCanCompile(expression); assertEquals("helloworld spring",expression.getValue(new Greeter())); - + // Three strings, optimal bytecode would only use one StringBuilder expression = parse("'hello' + 3 + ' spring'"); assertEquals("hello3 spring",expression.getValue(new Greeter())); assertCantCompile(expression); - + expression = parse("object + 'a'"); assertEquals("objecta",expression.getValue(new Greeter())); assertCanCompile(expression); assertEquals("objecta",expression.getValue(new Greeter())); - + expression = parse("'a'+object"); assertEquals("aobject",expression.getValue(new Greeter())); assertCanCompile(expression); @@ -2152,12 +2152,12 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals("objectobject",expression.getValue(new Greeter())); } - + public static class Greeter { public String getWorld() { - return "world"; + return "world"; } - + public Object getObject() { return "object"; } @@ -2169,7 +2169,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(); assertCanCompile(expression); assertEquals(0,expression.getValue()); - + expression = parse("4L-2L"); expression.getValue(); assertCanCompile(expression); @@ -2184,32 +2184,32 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(); assertCanCompile(expression); assertEquals(-1.0d,expression.getValue()); - + expression = parse("-1"); expression.getValue(); assertCanCompile(expression); - assertEquals(-1,expression.getValue()); + assertEquals(-1,expression.getValue()); expression = parse("-1L"); expression.getValue(); assertCanCompile(expression); - assertEquals(-1L,expression.getValue()); + assertEquals(-1L,expression.getValue()); expression = parse("-1.5f"); expression.getValue(); assertCanCompile(expression); - assertEquals(-1.5f,expression.getValue()); + assertEquals(-1.5f,expression.getValue()); expression = parse("-2.5d"); expression.getValue(); assertCanCompile(expression); - assertEquals(-2.5d,expression.getValue()); - + assertEquals(-2.5d,expression.getValue()); + expression = parse("T(Integer).valueOf(2)-6"); assertEquals(-4,expression.getValue()); assertCanCompile(expression); assertEquals(-4,expression.getValue()); - + expression = parse("T(Integer).valueOf(1)-T(Integer).valueOf(3)"); assertEquals(-2,expression.getValue()); assertCanCompile(expression); @@ -2224,7 +2224,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(-4.0f,expression.getValue()); assertCanCompile(expression); assertEquals(-4.0f,expression.getValue()); - + expression = parse("T(Float).valueOf(8.0f)-T(Float).valueOf(3.0f)"); assertEquals(5.0f,expression.getValue()); assertCanCompile(expression); @@ -2239,7 +2239,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(3L,expression.getValue()); assertCanCompile(expression); assertEquals(3L,expression.getValue()); - + expression = parse("T(Long).valueOf(4L)-T(Long).valueOf(3L)"); assertEquals(1L,expression.getValue()); assertCanCompile(expression); @@ -2250,14 +2250,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals(6L,expression.getValue()); } - + @Test public void opMinus_mixedNumberTypes() throws Exception { PayloadX p = new PayloadX(); - + // This is what you had to do before the changes in order for it to compile: // expression = parse("(T(java.lang.Double).parseDouble(payload.valueI.toString()))/60D"); - + // right is a double checkCalc(p,"payload.valueSB-60D",60d); checkCalc(p,"payload.valueBB-60D",60d); @@ -2286,7 +2286,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD-payload.valueDB60",60d); checkCalc(p,"payload.valueJ-payload.valueDB60",60d); checkCalc(p,"payload.valueI-payload.valueDB60",60d); - + // right is a float checkCalc(p,"payload.valueSB-60F",60F); checkCalc(p,"payload.valueBB-60F",60F); @@ -2301,7 +2301,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD-60F",60d); checkCalc(p,"payload.valueJ-60F",60F); checkCalc(p,"payload.valueI-60F",60F); - + checkCalc(p,"payload.valueSB-payload.valueFB60",60F); checkCalc(p,"payload.valueBB-payload.valueFB60",60F); checkCalc(p,"payload.valueFB-payload.valueFB60",60f); @@ -2359,7 +2359,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD-60",60d); checkCalc(p,"payload.valueJ-60",60L); checkCalc(p,"payload.valueI-60",60); - + checkCalc(p,"payload.valueSB-payload.valueIB60",60); checkCalc(p,"payload.valueBB-payload.valueIB60",60); checkCalc(p,"payload.valueFB-payload.valueIB60",60f); @@ -2373,7 +2373,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD-payload.valueIB60",60d); checkCalc(p,"payload.valueJ-payload.valueIB60",60L); checkCalc(p,"payload.valueI-payload.valueIB60",60); - + // right is a short checkCalc(p,"payload.valueSB-payload.valueS20",100); checkCalc(p,"payload.valueBB-payload.valueS20",100); @@ -2436,10 +2436,10 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { @Test public void opMultiply_mixedNumberTypes() throws Exception { PayloadX p = new PayloadX(); - + // This is what you had to do before the changes in order for it to compile: // expression = parse("(T(java.lang.Double).parseDouble(payload.valueI.toString()))/60D"); - + // right is a double checkCalc(p,"payload.valueSB*60D",7200d); checkCalc(p,"payload.valueBB*60D",7200d); @@ -2468,7 +2468,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD*payload.valueDB60",7200d); checkCalc(p,"payload.valueJ*payload.valueDB60",7200d); checkCalc(p,"payload.valueI*payload.valueDB60",7200d); - + // right is a float checkCalc(p,"payload.valueSB*60F",7200F); checkCalc(p,"payload.valueBB*60F",7200F); @@ -2483,7 +2483,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD*60F",7200d); checkCalc(p,"payload.valueJ*60F",7200F); checkCalc(p,"payload.valueI*60F",7200F); - + checkCalc(p,"payload.valueSB*payload.valueFB60",7200F); checkCalc(p,"payload.valueBB*payload.valueFB60",7200F); checkCalc(p,"payload.valueFB*payload.valueFB60",7200f); @@ -2541,7 +2541,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD*60",7200d); checkCalc(p,"payload.valueJ*60",7200L); checkCalc(p,"payload.valueI*60",7200); - + checkCalc(p,"payload.valueSB*payload.valueIB60",7200); checkCalc(p,"payload.valueBB*payload.valueIB60",7200); checkCalc(p,"payload.valueFB*payload.valueIB60",7200f); @@ -2555,7 +2555,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD*payload.valueIB60",7200d); checkCalc(p,"payload.valueJ*payload.valueIB60",7200L); checkCalc(p,"payload.valueI*payload.valueIB60",7200); - + // right is a short checkCalc(p,"payload.valueSB*payload.valueS20",2400); checkCalc(p,"payload.valueBB*payload.valueS20",2400); @@ -2614,15 +2614,15 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueJ*payload.valueBB20",2400L); checkCalc(p,"payload.valueI*payload.valueBB20",2400); } - + @Test public void opModulus_mixedNumberTypes() throws Exception { PayloadX p = new PayloadX(); - + // This is what you had to do before the changes in order for it to compile: // expression = parse("(T(java.lang.Double).parseDouble(payload.valueI.toString()))/60D"); - + // right is a double checkCalc(p,"payload.valueSB%58D",4d); checkCalc(p,"payload.valueBB%58D",4d); @@ -2651,7 +2651,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD%payload.valueDB58",4d); checkCalc(p,"payload.valueJ%payload.valueDB58",4d); checkCalc(p,"payload.valueI%payload.valueDB58",4d); - + // right is a float checkCalc(p,"payload.valueSB%58F",4F); checkCalc(p,"payload.valueBB%58F",4F); @@ -2666,7 +2666,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD%58F",4d); checkCalc(p,"payload.valueJ%58F",4F); checkCalc(p,"payload.valueI%58F",4F); - + checkCalc(p,"payload.valueSB%payload.valueFB58",4F); checkCalc(p,"payload.valueBB%payload.valueFB58",4F); checkCalc(p,"payload.valueFB%payload.valueFB58",4f); @@ -2724,7 +2724,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD%58",4d); checkCalc(p,"payload.valueJ%58",4L); checkCalc(p,"payload.valueI%58",4); - + checkCalc(p,"payload.valueSB%payload.valueIB58",4); checkCalc(p,"payload.valueBB%payload.valueIB58",4); checkCalc(p,"payload.valueFB%payload.valueIB58",4f); @@ -2738,7 +2738,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueD%payload.valueIB58",4d); checkCalc(p,"payload.valueJ%payload.valueIB58",4L); checkCalc(p,"payload.valueI%payload.valueIB58",4); - + // right is a short checkCalc(p,"payload.valueSB%payload.valueS18",12); checkCalc(p,"payload.valueBB%payload.valueS18",12); @@ -2797,14 +2797,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { checkCalc(p,"payload.valueJ%payload.valueBB18",12L); checkCalc(p,"payload.valueI%payload.valueBB18",12); } - + @Test public void opMultiply() throws Exception { expression = parse("2*2"); expression.getValue(); assertCanCompile(expression); assertEquals(4,expression.getValue()); - + expression = parse("2L*2L"); expression.getValue(); assertCanCompile(expression); @@ -2824,7 +2824,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(12.0f,expression.getValue()); assertCanCompile(expression); assertEquals(12.0f,expression.getValue()); - + expression = parse("T(Float).valueOf(8.0f)*T(Float).valueOf(3.0f)"); assertEquals(24.0f,expression.getValue()); assertCanCompile(expression); @@ -2839,7 +2839,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(54L,expression.getValue()); assertCanCompile(expression); assertEquals(54L,expression.getValue()); - + expression = parse("T(Long).valueOf(4L)*T(Long).valueOf(3L)"); assertEquals(12L,expression.getValue()); assertCanCompile(expression); @@ -2855,14 +2855,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals(-24.0f,expression.getValue()); } - + @Test public void opDivide() throws Exception { expression = parse("2/2"); expression.getValue(); assertCanCompile(expression); assertEquals(1,expression.getValue()); - + expression = parse("2L/2L"); expression.getValue(); assertCanCompile(expression); @@ -2882,7 +2882,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(3.0f,expression.getValue()); assertCanCompile(expression); assertEquals(3.0f,expression.getValue()); - + expression = parse("T(Float).valueOf(8.0f)/T(Float).valueOf(2.0f)"); assertEquals(4.0f,expression.getValue()); assertCanCompile(expression); @@ -2897,7 +2897,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(4L,expression.getValue()); assertCanCompile(expression); assertEquals(4L,expression.getValue()); - + expression = parse("T(Long).valueOf(4L)/T(Long).valueOf(2L)"); assertEquals(2L,expression.getValue()); assertCanCompile(expression); @@ -2913,7 +2913,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals(-2.0f,expression.getValue()); } - + @Test public void opModulus_12041() throws Exception { expression = parse("2%2"); @@ -2932,7 +2932,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(2,expression.getValue()); assertCanCompile(expression); assertEquals(2,expression.getValue()); - + expression = parse("17L%5L"); assertEquals(2L,expression.getValue()); assertCanCompile(expression); @@ -2952,7 +2952,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(0.0f,expression.getValue()); assertCanCompile(expression); assertEquals(0.0f,expression.getValue()); - + expression = parse("T(Float).valueOf(6.0f)%4"); assertEquals(2.0f,expression.getValue()); assertCanCompile(expression); @@ -2972,7 +2972,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(8L,expression.getValue()); assertCanCompile(expression); assertEquals(8L,expression.getValue()); - + expression = parse("T(Long).valueOf(9L)%T(Long).valueOf(2L)"); assertEquals(1L,expression.getValue()); assertCanCompile(expression); @@ -2999,11 +2999,11 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { context.setVariable("it", person); expression.setEvaluationContext(context); assertTrue(expression.getValue(Boolean.class)); - assertTrue(expression.getValue(Boolean.class)); + assertTrue(expression.getValue(Boolean.class)); assertCanCompile(expression); assertTrue(expression.getValue(Boolean.class)); } - + @Test public void constructorReference_SPR12326() { String type = this.getClass().getName(); @@ -3013,7 +3013,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("test", ((Obj) expression.getValue(new Object[] { "test" })).param1); assertCanCompile(expression); assertEquals("test", ((Obj) expression.getValue(new Object[] { "test" })).param1); - + expression = parser.parseExpression(prefix+"2('foo','bar').output"); assertEquals("foobar", expression.getValue(String.class)); assertCanCompile(expression); @@ -3028,7 +3028,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("", expression.getValue(String.class)); assertCanCompile(expression); assertEquals("", expression.getValue(String.class)); - + expression = parser.parseExpression(prefix+"3(1,2,3).output"); assertEquals("123", expression.getValue(String.class)); assertCanCompile(expression); @@ -3043,7 +3043,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("", expression.getValue(String.class)); assertCanCompile(expression); assertEquals("", expression.getValue(String.class)); - + expression = parser.parseExpression(prefix+"3('abc',5.0f,1,2,3).output"); assertEquals("abc:5.0:123", expression.getValue(String.class)); assertCanCompile(expression); @@ -3058,13 +3058,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("abc:5.0:", expression.getValue(String.class)); assertCanCompile(expression); assertEquals("abc:5.0:", expression.getValue(String.class)); - + expression = parser.parseExpression(prefix+"4(#root).output"); assertEquals("123", expression.getValue(new int[]{1,2,3},String.class)); assertCanCompile(expression); assertEquals("123", expression.getValue(new int[]{1,2,3},String.class)); } - + @Test public void methodReferenceMissingCastAndRootObjectAccessing_SPR12326() { // Need boxing code on the 1 so that toString() can be called @@ -3075,7 +3075,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parser.parseExpression("#it?.age.equals([0])"); Person person = new Person(1); - StandardEvaluationContext context = + StandardEvaluationContext context = new StandardEvaluationContext(new Object[] { person.getAge() }); context.setVariable("it", person); assertTrue(expression.getValue(context, Boolean.class)); @@ -3092,52 +3092,52 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { context.setVariable("it", person); assertTrue(ex.getValue(context, Boolean.class)); assertTrue(ex.getValue(context, Boolean.class)); - + PersonInOtherPackage person2 = new PersonInOtherPackage(1); ex = parser.parseRaw("#it?.age.equals([0])"); - context = + context = new StandardEvaluationContext(new Object[] { person2.getAge() }); context.setVariable("it", person2); assertTrue(ex.getValue(context, Boolean.class)); assertTrue(ex.getValue(context, Boolean.class)); - + ex = parser.parseRaw("#it?.age.equals([0])"); - context = + context = new StandardEvaluationContext(new Object[] { person2.getAge() }); context.setVariable("it", person2); assertTrue((Boolean)ex.getValue(context)); assertTrue((Boolean)ex.getValue(context)); } - + public class Person { - + private int age; - + public Person(int age) { this.age = age; } - + public int getAge() { return age; } - + public void setAge(int age) { this.age = age; } } - + public class Person3 { - + private int age; - + public Person3(String name, int age) { this.age = age; } - + public int getAge() { return age; } - + public void setAge(int age) { this.age = age; } @@ -3151,7 +3151,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals("123",expression.getValue()); - String testclass8 = "org.springframework.expression.spel.SpelCompilationCoverageTests$TestClass8"; + String testclass8 = "org.springframework.expression.spel.SpelCompilationCoverageTests$TestClass8"; // multi arg ctor that includes primitives expression = parser.parseExpression("new "+testclass8+"(42,'123',4.0d,true)"); assertEquals(testclass8,expression.getValue().getClass().getName()); @@ -3163,14 +3163,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("123",tc8.s); assertEquals(4.0d,tc8.d,0.5d); assertEquals(true,tc8.z); - + // no-arg ctor expression = parser.parseExpression("new "+testclass8+"()"); assertEquals(testclass8,expression.getValue().getClass().getName()); assertCanCompile(expression); o = expression.getValue(); assertEquals(testclass8,o.getClass().getName()); - + // pass primitive to reference type ctor expression = parser.parseExpression("new "+testclass8+"(42)"); assertEquals(testclass8,expression.getValue().getClass().getName()); @@ -3181,16 +3181,16 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(42,tc8.i); // private class, can't compile it - String testclass9 = "org.springframework.expression.spel.SpelCompilationCoverageTests$TestClass9"; + String testclass9 = "org.springframework.expression.spel.SpelCompilationCoverageTests$TestClass9"; expression = parser.parseExpression("new "+testclass9+"(42)"); assertEquals(testclass9,expression.getValue().getClass().getName()); assertCantCompile(expression); } - + @Test public void methodReferenceReflectiveMethodSelectionWithVarargs() throws Exception { TestClass10 tc = new TestClass10(); - + // Should call the non varargs version of concat // (which causes the '::' prefix in test output) expression = parser.parseExpression("concat('test')"); @@ -3201,7 +3201,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { tc.reset(); expression.getValue(tc); assertEquals("::test",tc.s); - tc.reset(); + tc.reset(); // This will call the varargs concat with an empty array expression = parser.parseExpression("concat()"); @@ -3212,8 +3212,8 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { tc.reset(); expression.getValue(tc); assertEquals("",tc.s); - tc.reset(); - + tc.reset(); + // Should call the non varargs version of concat // (which causes the '::' prefix in test output) expression = parser.parseExpression("concat2('test')"); @@ -3224,7 +3224,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { tc.reset(); expression.getValue(tc); assertEquals("::test",tc.s); - tc.reset(); + tc.reset(); // This will call the varargs concat with an empty array expression = parser.parseExpression("concat2()"); @@ -3235,13 +3235,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { tc.reset(); expression.getValue(tc); assertEquals("",tc.s); - tc.reset(); + tc.reset(); } @Test public void methodReferenceVarargs() throws Exception { TestClass5 tc = new TestClass5(); - + // varargs string expression = parser.parseExpression("eleven()"); assertCantCompile(expression); @@ -3252,7 +3252,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("",tc.s); tc.reset(); - + // varargs string expression = parser.parseExpression("eleven('aaa')"); assertCantCompile(expression); @@ -3263,7 +3263,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("aaa",tc.s); tc.reset(); - + // varargs string expression = parser.parseExpression("eleven(stringArray)"); assertCantCompile(expression); @@ -3285,7 +3285,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("aaabbbccc",tc.s); tc.reset(); - + expression = parser.parseExpression("sixteen('aaa','bbb','ccc')"); assertCantCompile(expression); expression.getValue(tc); @@ -3295,7 +3295,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("aaabbbccc",tc.s); tc.reset(); - + // TODO Fails related to conversion service converting a String[] to satisfy Object... // expression = parser.parseExpression("sixteen(stringArray)"); // assertCantCompile(expression); @@ -3317,7 +3317,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals(6,tc.i); tc.reset(); - + expression = parser.parseExpression("twelve(1)"); assertCantCompile(expression); expression.getValue(tc); @@ -3338,7 +3338,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("aaa::bbbccc",tc.s); tc.reset(); - + // nothing passed to varargs parameter expression = parser.parseExpression("thirteen('aaa')"); assertCantCompile(expression); @@ -3349,7 +3349,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("aaa::",tc.s); tc.reset(); - + // nested arrays expression = parser.parseExpression("fourteen('aaa',stringArray,stringArray)"); assertCantCompile(expression); @@ -3360,7 +3360,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("aaa::{aaabbbccc}{aaabbbccc}",tc.s); tc.reset(); - + // nested primitive array expression = parser.parseExpression("fifteen('aaa',intArray,intArray)"); assertCantCompile(expression); @@ -3371,7 +3371,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("aaa::{112233}{112233}",tc.s); tc.reset(); - + // varargs boolean expression = parser.parseExpression("arrayz(true,true,false)"); assertCantCompile(expression); @@ -3382,7 +3382,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("truetruefalse",tc.s); tc.reset(); - + expression = parser.parseExpression("arrayz(true)"); assertCantCompile(expression); expression.getValue(tc); @@ -3392,7 +3392,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("true",tc.s); tc.reset(); - + // varargs short expression = parser.parseExpression("arrays(s1,s2,s3)"); assertCantCompile(expression); @@ -3403,7 +3403,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("123",tc.s); tc.reset(); - + expression = parser.parseExpression("arrays(s1)"); assertCantCompile(expression); expression.getValue(tc); @@ -3413,7 +3413,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("1",tc.s); tc.reset(); - + // varargs double expression = parser.parseExpression("arrayd(1.0d,2.0d,3.0d)"); assertCantCompile(expression); @@ -3434,7 +3434,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("1.0",tc.s); tc.reset(); - + // varargs long expression = parser.parseExpression("arrayj(l1,l2,l3)"); assertCantCompile(expression); @@ -3487,7 +3487,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("656667",tc.s); tc.reset(); - + expression = parser.parseExpression("arrayb(b1)"); assertCantCompile(expression); expression.getValue(tc); @@ -3508,7 +3508,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("1.02.03.0",tc.s); tc.reset(); - + expression = parser.parseExpression("arrayf(f1)"); assertCantCompile(expression); expression.getValue(tc); @@ -3519,11 +3519,11 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("1.0",tc.s); tc.reset(); } - + @Test public void methodReference() throws Exception { TestClass5 tc = new TestClass5(); - + // non-static method, no args, void return expression = parser.parseExpression("one()"); assertCantCompile(expression); @@ -3533,7 +3533,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals(1,tc.i); tc.reset(); - + // static method, no args, void return expression = parser.parseExpression("two()"); assertCantCompile(expression); @@ -3543,7 +3543,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals(1,TestClass5._i); tc.reset(); - + // non-static method, reference type return expression = parser.parseExpression("three()"); assertCantCompile(expression); @@ -3561,7 +3561,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { tc.reset(); assertEquals(3277700L,expression.getValue(tc)); tc.reset(); - + // static method, reference type return expression = parser.parseExpression("five()"); assertCantCompile(expression); @@ -3579,7 +3579,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { tc.reset(); assertEquals(3277700L,expression.getValue(tc)); tc.reset(); - + // non-static method, one parameter of reference type expression = parser.parseExpression("seven(\"foo\")"); assertCantCompile(expression); @@ -3589,7 +3589,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals("foo",tc.s); tc.reset(); - + // static method, one parameter of reference type expression = parser.parseExpression("eight(\"bar\")"); assertCantCompile(expression); @@ -3619,23 +3619,23 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression.getValue(tc); assertEquals(111,TestClass5._i); tc.reset(); - + // method that gets type converted parameters - + // Converting from an int to a string expression = parser.parseExpression("seven(123)"); assertCantCompile(expression); expression.getValue(tc); assertEquals("123",tc.s); assertCantCompile(expression); // Uncompilable as argument conversion is occurring - + Expression expression = parser.parseExpression("'abcd'.substring(index1,index2)"); String resultI = expression.getValue(new TestClass1(),String.class); assertCanCompile(expression); String resultC = expression.getValue(new TestClass1(),String.class); assertEquals("bc",resultI); assertEquals("bc",resultC); - + // Converting from an int to a Number expression = parser.parseExpression("takeNumber(123)"); assertCantCompile(expression); @@ -3664,14 +3664,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { tc.reset(); assertCantCompile(expression); // method takes a string and we are passing an Integer } - - - @Test + + + @Test public void errorHandling() throws Exception { TestClass5 tc = new TestClass5(); - + // changing target - + // from primitive array to reference type array int[] is = new int[]{1,2,3}; String[] strings = new String[]{"a","b","c"}; @@ -3679,7 +3679,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(2,expression.getValue(is)); assertCanCompile(expression); assertEquals(2,expression.getValue(is)); - + try { assertEquals(2,expression.getValue(strings)); fail(); @@ -3690,8 +3690,8 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("b",expression.getValue(strings)); assertCanCompile(expression); assertEquals("b",expression.getValue(strings)); - - + + tc.field = "foo"; expression = parser.parseExpression("seven(field)"); assertCantCompile(expression); @@ -3701,7 +3701,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { tc.reset(); tc.field="bar"; expression.getValue(tc); - + // method with changing parameter types (change reference type) tc.obj = "foo"; expression = parser.parseExpression("seven(obj)"); @@ -3717,8 +3717,8 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } catch (SpelEvaluationException see) { assertTrue(see.getCause() instanceof ClassCastException); } - - + + // method with changing target expression = parser.parseExpression("#root.charAt(0)"); assertEquals('a',expression.getValue("abc")); @@ -3729,9 +3729,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } catch (SpelEvaluationException see) { // java.lang.Integer cannot be cast to java.lang.String assertTrue(see.getCause() instanceof ClassCastException); - } + } } - + @Test public void methodReference_staticMethod() throws Exception { Expression expression = parser.parseExpression("T(Integer).valueOf(42)"); @@ -3739,9 +3739,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); int resultC = expression.getValue(new TestClass1(),Integer.TYPE); assertEquals(42,resultI); - assertEquals(42,resultC); + assertEquals(42,resultC); } - + @Test public void methodReference_literalArguments_int() throws Exception { Expression expression = parser.parseExpression("'abcd'.substring(1,3)"); @@ -3771,7 +3771,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { int resultC = expression.getValue(new Integer(42),Integer.TYPE); assertEquals(42,resultC); } - + @Test public void methodReference_simpleInstanceMethodOneArgReturnPrimitive1() throws Exception { Expression expression = parser.parseExpression("indexOf('b')"); @@ -3828,8 +3828,8 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(0.04d,expression.getValue(payload)); assertEquals("D",getAst().getExitDescriptor()); } - - + + @Test public void mixingItUp_indexerOpEqTernary() throws Exception { Map m = new HashMap(); @@ -3842,25 +3842,25 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { m.remove("andy"); assertEquals(1,expression.getValue(m)); } - + @Test public void propertyReference() throws Exception { TestClass6 tc = new TestClass6(); - + // non static field expression = parser.parseExpression("orange"); assertCantCompile(expression); assertEquals("value1",expression.getValue(tc)); assertCanCompile(expression); assertEquals("value1",expression.getValue(tc)); - + // static field expression = parser.parseExpression("apple"); assertCantCompile(expression); assertEquals("value2",expression.getValue(tc)); assertCanCompile(expression); - assertEquals("value2",expression.getValue(tc)); - + assertEquals("value2",expression.getValue(tc)); + // non static getter expression = parser.parseExpression("banana"); assertCantCompile(expression); @@ -3886,7 +3886,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals("wibble",expression.getValue(ctx)); } - + @SuppressWarnings("unchecked") @Test public void indexer() throws Exception { @@ -3899,7 +3899,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { float[] fs = new float[]{6.0f,7.0f,8.0f}; byte[] bs = new byte[]{(byte)2,(byte)3,(byte)4}; char[] cs = new char[]{'a','b','c'}; - + // Access String (reference type) array expression = parser.parseExpression("[0]"); assertEquals("a",expression.getValue(sss)); @@ -3912,7 +3912,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals(8,expression.getValue(ns)); assertEquals("Ljava/lang/Number",getAst().getExitDescriptor()); - + // Access int array expression = parser.parseExpression("[2]"); assertEquals(10,expression.getValue(is)); @@ -3961,7 +3961,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals('b',expression.getValue(cs)); assertEquals("C",getAst().getExitDescriptor()); - + // Collections List strings = new ArrayList(); strings.add("aaa"); @@ -3972,7 +3972,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals("bbb",expression.getValue(strings)); assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); - + List ints = new ArrayList(); ints.add(123); ints.add(456); @@ -3982,7 +3982,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals(789,expression.getValue(ints)); assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); - + // Maps Map map1 = new HashMap(); map1.put("aaa", 111); @@ -3993,7 +3993,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals(111,expression.getValue(map1)); assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); - + // Object TestClass6 tc = new TestClass6(); expression = parser.parseExpression("['orange']"); @@ -4001,7 +4001,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals("value1",expression.getValue(tc)); assertEquals("Ljava/lang/String",getAst().getExitDescriptor()); - + expression = parser.parseExpression("['peach']"); assertEquals(34L,expression.getValue(tc)); assertCanCompile(expression); @@ -4014,9 +4014,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals("value3",expression.getValue(tc)); assertEquals("Ljava/lang/String",getAst().getExitDescriptor()); - + // list of arrays - + List listOfStringArrays = new ArrayList(); listOfStringArrays.add(new String[]{"a","b","c"}); listOfStringArrays.add(new String[]{"d","e","f"}); @@ -4025,7 +4025,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals("d e f",stringify(expression.getValue(listOfStringArrays))); assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); - + expression = parser.parseExpression("[1][0]"); assertEquals("d",stringify(expression.getValue(listOfStringArrays))); assertCanCompile(expression); @@ -4046,7 +4046,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals(2,expression.getValue(listOfIntegerArrays)); assertEquals("Ljava/lang/Integer",getAst().getExitDescriptor()); - + // array of lists List[] stringArrayOfLists = new ArrayList[2]; stringArrayOfLists[0] = new ArrayList(); @@ -4062,13 +4062,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals("d e f",stringify(expression.getValue(stringArrayOfLists))); assertEquals("Ljava/util/ArrayList",getAst().getExitDescriptor()); - + expression = parser.parseExpression("[1][2]"); assertEquals("f",stringify(expression.getValue(stringArrayOfLists))); assertCanCompile(expression); assertEquals("f",stringify(expression.getValue(stringArrayOfLists))); assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); - + // array of arrays String[][] referenceTypeArrayOfArrays = new String[][]{new String[]{"a","b","c"},new String[]{"d","e","f"}}; expression = parser.parseExpression("[1]"); @@ -4077,26 +4077,26 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("[Ljava/lang/String",getAst().getExitDescriptor()); assertEquals("d e f",stringify(expression.getValue(referenceTypeArrayOfArrays))); assertEquals("[Ljava/lang/String",getAst().getExitDescriptor()); - + expression = parser.parseExpression("[1][2]"); assertEquals("f",stringify(expression.getValue(referenceTypeArrayOfArrays))); assertCanCompile(expression); assertEquals("f",stringify(expression.getValue(referenceTypeArrayOfArrays))); assertEquals("Ljava/lang/String",getAst().getExitDescriptor()); - + int[][] primitiveTypeArrayOfArrays = new int[][]{new int[]{1,2,3},new int[]{4,5,6}}; expression = parser.parseExpression("[1]"); assertEquals("4 5 6",stringify(expression.getValue(primitiveTypeArrayOfArrays))); assertCanCompile(expression); assertEquals("4 5 6",stringify(expression.getValue(primitiveTypeArrayOfArrays))); assertEquals("[I",getAst().getExitDescriptor()); - + expression = parser.parseExpression("[1][2]"); assertEquals("6",stringify(expression.getValue(primitiveTypeArrayOfArrays))); assertCanCompile(expression); assertEquals("6",stringify(expression.getValue(primitiveTypeArrayOfArrays))); assertEquals("I",getAst().getExitDescriptor()); - + // list of lists of reference types List> listOfListOfStrings = new ArrayList>(); List list = new ArrayList(); @@ -4109,20 +4109,20 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { list.add("e"); list.add("f"); listOfListOfStrings.add(list); - + expression = parser.parseExpression("[1]"); assertEquals("d e f",stringify(expression.getValue(listOfListOfStrings))); assertCanCompile(expression); assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); assertEquals("d e f",stringify(expression.getValue(listOfListOfStrings))); assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); - + expression = parser.parseExpression("[1][2]"); assertEquals("f",stringify(expression.getValue(listOfListOfStrings))); assertCanCompile(expression); assertEquals("f",stringify(expression.getValue(listOfListOfStrings))); assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); - + // Map of lists Map> mapToLists = new HashMap>(); list = new ArrayList(); @@ -4136,13 +4136,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); assertEquals("a b c",stringify(expression.getValue(mapToLists))); assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); - + expression = parser.parseExpression("['foo'][2]"); assertEquals("c",stringify(expression.getValue(mapToLists))); assertCanCompile(expression); assertEquals("c",stringify(expression.getValue(mapToLists))); assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); - + // Map to array Map mapToIntArray = new HashMap(); StandardEvaluationContext ctx = new StandardEvaluationContext(); @@ -4154,12 +4154,12 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); assertEquals("1 2 3",stringify(expression.getValue(mapToIntArray))); assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); - + expression = parser.parseExpression("['foo'][1]"); assertEquals(2,expression.getValue(mapToIntArray)); assertCanCompile(expression); assertEquals(2,expression.getValue(mapToIntArray)); - + expression = parser.parseExpression("foo"); assertEquals("1 2 3",stringify(expression.getValue(ctx,mapToIntArray))); assertCanCompile(expression); @@ -4176,7 +4176,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals("3",stringify(expression.getValue(ctx,mapToIntArray))); assertEquals("I",getAst().getExitDescriptor()); - + // Map array Map[] mapArray = new Map[1]; mapArray[0] = new HashMap(); @@ -4187,25 +4187,25 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("Ljava/util/Map",getAst().getExitDescriptor()); assertEquals("{key=value1}",stringify(expression.getValue(mapArray))); assertEquals("Ljava/util/Map",getAst().getExitDescriptor()); - + expression = parser.parseExpression("[0]['key']"); assertEquals("value1",stringify(expression.getValue(mapArray))); assertCanCompile(expression); assertEquals("value1",stringify(expression.getValue(mapArray))); assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); } - + @Test public void mixingItUp_propertyAccessIndexerOpLtTernaryRootNull() throws Exception { Payload payload = new Payload(); - + expression = parser.parseExpression("DR[0].three"); Object v = expression.getValue(payload); assertEquals("Lorg/springframework/expression/spel/SpelCompilationCoverageTests$Three",getAst().getExitDescriptor()); - + Expression expression = parser.parseExpression("DR[0].three.four lt 0.1d?#root:null"); v = expression.getValue(payload); - + SpelExpression sExpr = (SpelExpression)expression; Ternary ternary = (Ternary)sExpr.getAST(); OpLT oplt = (OpLT)ternary.getChild(0); @@ -4213,7 +4213,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { String cExprExitDescriptor = cExpr.getExitDescriptor(); assertEquals("D",cExprExitDescriptor); assertEquals("Z",oplt.getExitDescriptor()); - + assertCanCompile(expression); Object vc = expression.getValue(payload); assertEquals(payload,v); @@ -4231,7 +4231,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression = parser.parseExpression("payload2.var1"); Object v = expression.getValue(ctx,holder); assertEquals("abc",v); - + // // time it interpreted // long stime = System.currentTimeMillis(); // for (int i=0;i<100000;i++) { @@ -4242,7 +4242,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); v = expression.getValue(ctx,holder); assertEquals("abc",v); -// +// // // time it compiled // stime = System.currentTimeMillis(); // for (int i=0;i<100000;i++) { @@ -4250,14 +4250,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { // } // System.out.println((System.currentTimeMillis()-stime)); } - + @Test public void compilerWithGenerics_12040() { expression = parser.parseExpression("payload!=2"); assertTrue(expression.getValue(new GenericMessageTestHelper(4),Boolean.class)); assertCanCompile(expression); assertFalse(expression.getValue(new GenericMessageTestHelper(2),Boolean.class)); - + expression = parser.parseExpression("2!=payload"); assertTrue(expression.getValue(new GenericMessageTestHelper(4),Boolean.class)); assertCanCompile(expression); @@ -4267,12 +4267,12 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertTrue(expression.getValue(new GenericMessageTestHelper(4L),Boolean.class)); assertCanCompile(expression); assertFalse(expression.getValue(new GenericMessageTestHelper(6L),Boolean.class)); - + expression = parser.parseExpression("payload==2"); assertFalse(expression.getValue(new GenericMessageTestHelper(4),Boolean.class)); assertCanCompile(expression); assertTrue(expression.getValue(new GenericMessageTestHelper(2),Boolean.class)); - + expression = parser.parseExpression("2==payload"); assertFalse(expression.getValue(new GenericMessageTestHelper(4),Boolean.class)); assertCanCompile(expression); @@ -4292,27 +4292,27 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(2,expression.getValue(new GenericMessageTestHelper(4))); assertCanCompile(expression); assertEquals(3,expression.getValue(new GenericMessageTestHelper(6))); - + expression = parser.parseExpression("100/payload"); assertEquals(25,expression.getValue(new GenericMessageTestHelper(4))); assertCanCompile(expression); assertEquals(10,expression.getValue(new GenericMessageTestHelper(10))); - + expression = parser.parseExpression("payload+2"); assertEquals(6,expression.getValue(new GenericMessageTestHelper(4))); assertCanCompile(expression); assertEquals(8,expression.getValue(new GenericMessageTestHelper(6))); - + expression = parser.parseExpression("100+payload"); assertEquals(104,expression.getValue(new GenericMessageTestHelper(4))); assertCanCompile(expression); assertEquals(110,expression.getValue(new GenericMessageTestHelper(10))); - + expression = parser.parseExpression("payload-2"); assertEquals(2,expression.getValue(new GenericMessageTestHelper(4))); assertCanCompile(expression); assertEquals(4,expression.getValue(new GenericMessageTestHelper(6))); - + expression = parser.parseExpression("100-payload"); assertEquals(96,expression.getValue(new GenericMessageTestHelper(4))); assertCanCompile(expression); @@ -4322,7 +4322,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(8,expression.getValue(new GenericMessageTestHelper(4))); assertCanCompile(expression); assertEquals(12,expression.getValue(new GenericMessageTestHelper(6))); - + expression = parser.parseExpression("100*payload"); assertEquals(400,expression.getValue(new GenericMessageTestHelper(4))); assertCanCompile(expression); @@ -4332,7 +4332,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(2L,expression.getValue(new GenericMessageTestHelper(4L))); assertCanCompile(expression); assertEquals(3L,expression.getValue(new GenericMessageTestHelper(6L))); - + expression = parser.parseExpression("100L/payload"); assertEquals(25L,expression.getValue(new GenericMessageTestHelper(4L))); assertCanCompile(expression); @@ -4342,7 +4342,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(2f,expression.getValue(new GenericMessageTestHelper(4f))); assertCanCompile(expression); assertEquals(3f,expression.getValue(new GenericMessageTestHelper(6f))); - + expression = parser.parseExpression("100f/payload"); assertEquals(25f,expression.getValue(new GenericMessageTestHelper(4f))); assertCanCompile(expression); @@ -4352,13 +4352,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(2d,expression.getValue(new GenericMessageTestHelper(4d))); assertCanCompile(expression); assertEquals(3d,expression.getValue(new GenericMessageTestHelper(6d))); - + expression = parser.parseExpression("100d/payload"); assertEquals(25d,expression.getValue(new GenericMessageTestHelper(4d))); assertCanCompile(expression); assertEquals(10d,expression.getValue(new GenericMessageTestHelper(10d))); } - + // The new helper class here uses an upper bound on the generic @Test public void compilerWithGenerics_12040_2() { @@ -4376,17 +4376,17 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(6,expression.getValue(new GenericMessageTestHelper2(4))); assertCanCompile(expression); assertEquals(8,expression.getValue(new GenericMessageTestHelper2(6))); - + expression = parser.parseExpression("100+payload"); assertEquals(104,expression.getValue(new GenericMessageTestHelper2(4))); assertCanCompile(expression); assertEquals(110,expression.getValue(new GenericMessageTestHelper2(10))); - + expression = parser.parseExpression("payload-2"); assertEquals(2,expression.getValue(new GenericMessageTestHelper2(4))); assertCanCompile(expression); assertEquals(4,expression.getValue(new GenericMessageTestHelper2(6))); - + expression = parser.parseExpression("100-payload"); assertEquals(96,expression.getValue(new GenericMessageTestHelper2(4))); assertCanCompile(expression); @@ -4396,13 +4396,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(8,expression.getValue(new GenericMessageTestHelper2(4))); assertCanCompile(expression); assertEquals(12,expression.getValue(new GenericMessageTestHelper2(6))); - + expression = parser.parseExpression("100*payload"); assertEquals(400,expression.getValue(new GenericMessageTestHelper2(4))); assertCanCompile(expression); assertEquals(1000,expression.getValue(new GenericMessageTestHelper2(10))); } - + // The other numeric operators @Test public void compilerWithGenerics_12040_3() { @@ -4464,11 +4464,11 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { expression=sep.parseExpression("headers[getKey()]"); assertEquals("wobble",expression.getValue(root)); assertEquals("wobble",expression.getValue(root)); - + expression=sep.parseExpression("list[getKey2()]"); assertEquals("wobble",expression.getValue(root)); assertEquals("wobble",expression.getValue(root)); - + expression = sep.parseExpression("ia[getKey2()]"); assertEquals(3,expression.getValue(root)); assertEquals(3,expression.getValue(root)); @@ -4482,7 +4482,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { List getList(); int[] getIa(); } - + public static class MyMessage implements Message { public MessageHeaders getHeaders() { MessageHeaders mh = new MessageHeaders(); @@ -4498,11 +4498,11 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { l.add("wobble"); return l; } - + public String getKey() { return "command2"; } - + public int getKey2() { return 1; } @@ -4513,29 +4513,29 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { public static class GenericMessageTestHelper { private T payload; - + GenericMessageTestHelper(T value) { this.payload = value; } - + public T getPayload() { return payload; } } - + // This test helper has a bound on the type variable public static class GenericMessageTestHelper2 { private T payload; - + GenericMessageTestHelper2(T value) { this.payload = value; } - + public T getPayload() { return payload; } } - + static class MyAccessor implements CompilablePropertyAccessor { private Method method; @@ -4688,7 +4688,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } } - + // helpers private SpelNodeImpl getAst() { @@ -4725,19 +4725,19 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } return s.toString().trim(); } - + private void assertCanCompile(Expression expression) { assertTrue(SpelCompiler.compile(expression)); } - + private void assertCantCompile(Expression expression) { assertFalse(SpelCompiler.compile(expression)); } - + private Expression parse(String expression) { return parser.parseExpression(expression); } - + private void assertGetValueFail(Expression expression) { try { Object o = expression.getValue(); @@ -4746,18 +4746,18 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { // success! } } - + // test classes - + public static class Payload { Two[] DR = new Two[]{new Two()}; public Two holder = new Two(); - + public Two[] getDR() { return DR; } } - + public static class Payload2 { String var1 = "abc"; String var2 = "def"; @@ -4774,7 +4774,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { public static class Payload2Holder { public Payload2 payload2 = new Payload2(); } - + public static class Two { Three three = new Three(); public Three getThree() { @@ -4784,7 +4784,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { return "instanceof Two"; } } - + public static class Three { double four = 0.04d; public double getFour() { @@ -4795,9 +4795,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { public static class TestClass1 { public int index1 = 1; public int index2 = 3; - public String word = "abcd"; + public String word = "abcd"; } - + public static class TestClass4 { public boolean a,b; public boolean gettrue() { return true; } @@ -4805,19 +4805,19 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { public boolean getA() { return a; } public boolean getB() { return b; } } - + public static class TestClass10 { public String s = null; - + public void reset() { s = null; } - + public void concat(String arg) { s = "::"+arg; } - public void concat(String... vargs) { + public void concat(String... vargs) { if (vargs==null) { s = ""; } @@ -4828,12 +4828,12 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } } } - + public void concat2(Object arg) { s = "::"+arg; } - public void concat2(Object... vargs) { + public void concat2(Object... vargs) { if (vargs==null) { s = ""; } @@ -4845,13 +4845,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } } } - + public static class TestClass5 { public int i = 0; public String s = null; public static int _i = 0; public static String _s = null; - + public static short s1 = (short)1; public static short s2 = (short)2; public static short s3 = (short)3; @@ -4867,18 +4867,18 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { public static char c1 = 'a'; public static char c2 = 'b'; public static char c3 = 'c'; - + public static byte b1 = (byte)65; public static byte b2 = (byte)66; public static byte b3 = (byte)67; public static String[] stringArray = new String[]{"aaa","bbb","ccc"}; public static int[] intArray = new int[]{11,22,33}; - + public Object obj = null; - + public String field = null; - + public void reset() { i = 0; _i=0; @@ -4886,28 +4886,28 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { _s = null; field = null; } - + public void one() { i = 1; } - + public static void two() { _i = 1; } - + public String three() { return "hello"; } public long four() { return 3277700L; } public static String five() { return "hello"; } public static long six() { return 3277700L; } - + public void seven(String toset) { s = toset; } // public void seven(Number n) { s = n.toString(); } - + public void takeNumber(Number n) { s = n.toString(); } public void takeString(String s) { this.s = s; } public static void eight(String toset) { _s = toset; } - + public void nine(int toset) { i = toset; } public static void ten(int toset) { _i = toset; } - - public void eleven(String... vargs) { + + public void eleven(String... vargs) { if (vargs==null) { s = ""; } @@ -4918,8 +4918,8 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } } } - - public void twelve(int... vargs) { + + public void twelve(int... vargs) { if (vargs==null) { i = 0; } @@ -4930,8 +4930,8 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } } } - - public void thirteen(String a, String... vargs) { + + public void thirteen(String a, String... vargs) { if (vargs==null) { s = a+"::"; } @@ -4942,7 +4942,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } } } - + public void arrayz(boolean... bs) { s = ""; if (bs != null) { @@ -4952,7 +4952,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } } } - + public void arrays(short... ss) { s = ""; if (ss != null) { @@ -4962,7 +4962,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } } } - + public void arrayd(double... vargs) { s = ""; if (vargs != null) { @@ -5002,7 +5002,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } } } - + public void arrayc(char... vargs) { s = ""; if (vargs != null) { @@ -5013,7 +5013,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } } - public void fourteen(String a, String[]... vargs) { + public void fourteen(String a, String[]... vargs) { if (vargs==null) { s = a+"::"; } @@ -5022,14 +5022,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { for (String[] varg: vargs) { s+="{"; for (String v: varg) { - s+=v; + s+=v; } s+="}"; } } } - - public void fifteen(String a, int[]... vargs) { + + public void fifteen(String a, int[]... vargs) { if (vargs==null) { s = a+"::"; } @@ -5038,14 +5038,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { for (int[] varg: vargs) { s+="{"; for (int v: varg) { - s+=Integer.toString(v); + s+=Integer.toString(v); } s+="}"; } } } - - public void sixteen(Object... vargs) { + + public void sixteen(Object... vargs) { if (vargs==null) { s = ""; } @@ -5056,15 +5056,15 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } } } - + } - + public static class TestClass6 { public String orange = "value1"; public static String apple = "value2"; - + public long peach = 34L; - + public String getBanana() { return "value3"; } @@ -5073,7 +5073,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { return "value4"; } } - + public static class TestClass7 { public static String property; static { @@ -5081,13 +5081,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { StringTokenizer st = new StringTokenizer(s); property = st.nextToken(); } - + public static void reset() { String s = "UK 123"; StringTokenizer st = new StringTokenizer(s); property = st.nextToken(); } - + } public static class TestClass8 { @@ -5095,22 +5095,22 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { public String s; public double d; public boolean z; - + public TestClass8(int i, String s, double d, boolean z) { this.i = i; this.s = s; this.d = d; this.z = z; } - + public TestClass8() { - + } - + public TestClass8(Integer i) { this.i = i; } - + @SuppressWarnings("unused") private TestClass8(String a, String b) { this.s = a+b; @@ -5118,18 +5118,18 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } public static class Obj { - + private final String param1; - + public Obj(String param1){ this.param1 = param1; } } public static class Obj2 { - + public final String output; - + public Obj2(String... params){ StringBuilder b = new StringBuilder(); for (String param: params) { @@ -5140,9 +5140,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } public static class Obj3 { - + public final String output; - + public Obj3(int... params) { StringBuilder b = new StringBuilder(); for (int param: params) { @@ -5150,7 +5150,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } output = b.toString(); } - + public Obj3(String s, Float f, int... ints) { StringBuilder b = new StringBuilder(); b.append(s); @@ -5163,11 +5163,11 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { output = b.toString(); } } - + public static class Obj4 { - + public final String output; - + public Obj4(int[] params) { StringBuilder b = new StringBuilder(); for (int param: params) { @@ -5176,17 +5176,17 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { output = b.toString(); } } - + @SuppressWarnings("unused") private static class TestClass9 { public TestClass9(int i) {} } - + // These test classes simulate a pattern of public/private classes seen in Spring Security - - // final class HttpServlet3RequestFactory implements HttpServletRequestFactory + + // final class HttpServlet3RequestFactory implements HttpServletRequestFactory static class HttpServlet3RequestFactory { - + static Servlet3SecurityContextHolderAwareRequestWrapper getOne() { HttpServlet3RequestFactory outer = new HttpServlet3RequestFactory(); return outer.new Servlet3SecurityContextHolderAwareRequestWrapper(); @@ -5195,17 +5195,17 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { private class Servlet3SecurityContextHolderAwareRequestWrapper extends SecurityContextHolderAwareRequestWrapper { } } - - // public class SecurityContextHolderAwareRequestWrapper extends HttpServletRequestWrapper + + // public class SecurityContextHolderAwareRequestWrapper extends HttpServletRequestWrapper static class SecurityContextHolderAwareRequestWrapper extends HttpServletRequestWrapper { } - + public static class HttpServletRequestWrapper { public String getServletPath() { return "wibble"; } } - + // Here the declaring class is not public static class SomeCompareMethod { @@ -5219,7 +5219,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { return -1; } } - + public static class SomeCompareMethod2 { public static int negate(int i1) { return -i1; @@ -5232,7 +5232,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } return b.toString(); } - + public static String append2(Object... objects) { StringBuilder b = new StringBuilder(); for (Object object: objects) { @@ -5240,7 +5240,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } return b.toString(); } - + public static String append3(String[] strings) { StringBuilder b = new StringBuilder(); for (String string: strings) { @@ -5248,7 +5248,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } return b.toString(); } - + public static String append4(String s, String... strings) { StringBuilder b = new StringBuilder(); b.append(s).append("::"); @@ -5265,7 +5265,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } return b.toString(); } - + public static int sum(int... ints) { int total = 0; for (int i: ints) { @@ -5291,11 +5291,11 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { } } - + public static class DelegatingStringFormat { public static String format(String s, Object... args) { return String.format(s, args); } } - + } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationPerformanceTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationPerformanceTests.java index cdcc18c568..58403d6b2a 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationPerformanceTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationPerformanceTests.java @@ -62,7 +62,7 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests { return duration; } } - + public static class NumberHolder { public int payload = 36; } @@ -97,7 +97,7 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests { System.out.println("Now compiled:"); o = expression.getValue(nh); assertEquals(2d, o); - + stime = System.currentTimeMillis(); for (int i=0;i<1000000;i++) { o = expression.getValue(nh); @@ -113,7 +113,7 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests { o = expression.getValue(nh); } System.out.println("One million iterations: "+(System.currentTimeMillis()-stime)+"ms"); - + expression = parser.parseExpression("payload/18D"); o = expression.getValue(nh); assertEquals(2d,o); @@ -137,7 +137,7 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests { System.out.println("Now compiled:"); o = expression.getValue(nh); assertEquals(2d, o); - + stime = System.currentTimeMillis(); for (int i=0;i<1000000;i++) { o = expression.getValue(nh); @@ -154,7 +154,7 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests { } System.out.println("One million iterations: "+(System.currentTimeMillis()-stime)+"ms"); } - + @Test public void inlineLists() throws Exception { expression = parser.parseExpression("{'abcde','ijklm'}[0].substring({1,3,4}[0],{1,3,4}[1])"); @@ -180,7 +180,7 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests { System.out.println("Now compiled:"); o = expression.getValue(); assertEquals("bc", o); - + stime = System.currentTimeMillis(); for (int i=0;i<1000000;i++) { o = expression.getValue(); @@ -197,7 +197,7 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests { } System.out.println("One million iterations: "+(System.currentTimeMillis()-stime)+"ms"); } - + @Test public void inlineNestedLists() throws Exception { expression = parser.parseExpression("{'abcde',{'ijklm','nopqr'}}[1][0].substring({1,3,4}[0],{1,3,4}[1])"); @@ -223,7 +223,7 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests { System.out.println("Now compiled:"); o = expression.getValue(); assertEquals("jk", o); - + stime = System.currentTimeMillis(); for (int i=0;i<1000000;i++) { o = expression.getValue(); @@ -269,7 +269,7 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests { System.out.println("Now compiled:"); o = expression.getValue(g); assertEquals("helloworld spring", o); - + stime = System.currentTimeMillis(); for (int i=0;i<1000000;i++) { o = expression.getValue(g); @@ -286,7 +286,7 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests { } System.out.println("One million iterations: "+(System.currentTimeMillis()-stime)+"ms"); } - + public static class Greeter { public String getWorld() { return "world"; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/testdata/PersonInOtherPackage.java b/spring-expression/src/test/java/org/springframework/expression/spel/testdata/PersonInOtherPackage.java index add606359f..13e13fec27 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/testdata/PersonInOtherPackage.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/testdata/PersonInOtherPackage.java @@ -16,7 +16,7 @@ package org.springframework.expression.spel.testdata; /** - * + * * @author Andy Clement * @since 4.1.2 */ diff --git a/spring-web/src/test/java/org/springframework/protobuf/Msg.java b/spring-web/src/test/java/org/springframework/protobuf/Msg.java index b8d966600f..cdd69dd66c 100644 --- a/spring-web/src/test/java/org/springframework/protobuf/Msg.java +++ b/spring-web/src/test/java/org/springframework/protobuf/Msg.java @@ -129,7 +129,7 @@ public final class Msg extends if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { - com.google.protobuf.ByteString bs = + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { @@ -145,7 +145,7 @@ public final class Msg extends getFooBytes() { java.lang.Object ref = foo_; if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); foo_ = b; @@ -461,7 +461,7 @@ public final class Msg extends getFooBytes() { java.lang.Object ref = foo_; if (ref instanceof String) { - com.google.protobuf.ByteString b = + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); foo_ = b; @@ -610,7 +610,7 @@ public final class Msg extends * optional .SecondMsg blah = 2; */ private com.google.protobuf.SingleFieldBuilder< - org.springframework.protobuf.SecondMsg, org.springframework.protobuf.SecondMsg.Builder, org.springframework.protobuf.SecondMsgOrBuilder> + org.springframework.protobuf.SecondMsg, org.springframework.protobuf.SecondMsg.Builder, org.springframework.protobuf.SecondMsgOrBuilder> getBlahFieldBuilder() { if (blahBuilder_ == null) { blahBuilder_ = new com.google.protobuf.SingleFieldBuilder< diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java index 0967961bd5..e263839be5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java @@ -709,7 +709,7 @@ public class MvcNamespaceTests { (DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors"); assertEquals(1, deferredResultInterceptors.length); } - + @Test public void testViewResolution() throws Exception { loadBeanDefinitions("mvc-config-view-resolution.xml", 6);