Expression javadoc alignment

This commit is contained in:
Juergen Hoeller
2017-07-14 16:46:22 +02:00
parent f5c54f90b3
commit 1ad6180019
3 changed files with 86 additions and 71 deletions

View File

@@ -335,14 +335,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
// See SpelCompiler.loadClass()
Field f = SpelExpression.class.getDeclaredField("compiledAst");
Set<Object> classloadersUsed = new HashSet<>();
for (int i=0;i<1500;i++) { // 1500 is greater than SpelCompiler.CLASSES_DEFINED_LIMIT
for (int i =0; i < 1500; i++) { // 1500 is greater than SpelCompiler.CLASSES_DEFINED_LIMIT
expression = parser.parseExpression("4 + 5");
assertEquals(9, (int)expression.getValue(Integer.class));
assertEquals(9, (int) expression.getValue(Integer.class));
assertCanCompile(expression);
f.setAccessible(true);
CompiledExpression cEx = (CompiledExpression)f.get(expression);
classloadersUsed.add(cEx.getClass().getClassLoader());
assertEquals(9, (int)expression.getValue(Integer.class));
assertEquals(9, (int) expression.getValue(Integer.class));
}
assertTrue(classloadersUsed.size() > 1);
}
@@ -474,7 +474,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
expression = parser.parseExpression("T(Integer).valueOf(42)");
expression.getValue(Integer.class);
assertCanCompile(expression);
assertEquals(new Integer(42), expression.getValue(new StandardEvaluationContext(), Integer.class));
assertEquals(new Integer(42), expression.getValue(Integer.class));
// Code gen is different for -1 .. 6 because there are bytecode instructions specifically for those
// values
@@ -853,9 +853,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
assertEquals("4.0", expression.getValue(ctx).toString());
}
// Confirms visibility of what is being called.
@Test
public void functionReferenceVisibility_SPR12359() throws Exception {
// Confirms visibility of what is being called.
StandardEvaluationContext context = new StandardEvaluationContext(new Object[] {"1"});
context.registerFunction("doCompare", SomeCompareMethod.class.getDeclaredMethod(
"compare", Object.class, Object.class));
@@ -866,7 +866,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
assertCantCompile(expression);
// type not public but method is
context = new StandardEvaluationContext(new Object[] {"1"});
context = new StandardEvaluationContext(new Object[] {"1"});
context.registerFunction("doCompare", SomeCompareMethod.class.getDeclaredMethod(
"compare2", Object.class, Object.class));
context.setVariable("arg", "2");
@@ -877,7 +877,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
@Test
public void functionReferenceNonCompilableArguments_SPR12359() throws Exception {
StandardEvaluationContext context = new StandardEvaluationContext(new Object[] {"1"});
StandardEvaluationContext context = new StandardEvaluationContext(new Object[] {"1"});
context.registerFunction("negate", SomeCompareMethod2.class.getDeclaredMethod(
"negate", Integer.TYPE));
context.setVariable("arg", "2");
@@ -3093,7 +3093,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, getClass().getClassLoader()));
Person3 person = new Person3("foo", 1);
SpelExpression expression = parser.parseRaw("#it?.age?.equals([0])");
StandardEvaluationContext context = new StandardEvaluationContext(new Object[] { 1 });
StandardEvaluationContext context = new StandardEvaluationContext(new Object[] {1});
context.setVariable("it", person);
expression.setEvaluationContext(context);
assertTrue(expression.getValue(Boolean.class));
@@ -3120,8 +3120,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
// code generation for ENGLISH should notice there is something on the stack that
// is not required and pop it off.
expression = parser.parseExpression("#userId.toString().toLowerCase(T(java.util.Locale).ENGLISH)");
StandardEvaluationContext context =
new StandardEvaluationContext();
StandardEvaluationContext context = new StandardEvaluationContext();
context.setVariable("userId", "RoDnEy");
assertEquals("rodney", expression.getValue(context));
assertCanCompile(expression);
@@ -3270,8 +3269,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
expression = parser.parseExpression("#it?.age.equals([0])");
Person person = new Person(1);
StandardEvaluationContext context =
new StandardEvaluationContext(new Object[] { person.getAge() });
StandardEvaluationContext context = new StandardEvaluationContext(new Object[] {person.getAge()});
context.setVariable("it", person);
assertTrue(expression.getValue(context, Boolean.class));
assertCanCompile(expression);
@@ -3279,29 +3277,26 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
// Variant of above more like what was in the bug report:
SpelExpressionParser parser = new SpelExpressionParser(
new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE,
getClass().getClassLoader()));
new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, getClass().getClassLoader()));
SpelExpression ex = parser.parseRaw("#it?.age.equals([0])");
context = new StandardEvaluationContext(new Object[] { person.getAge() });
context = new StandardEvaluationContext(new Object[] {person.getAge()});
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 =
new StandardEvaluationContext(new Object[] { person2.getAge() });
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 =
new StandardEvaluationContext(new Object[] { person2.getAge() });
context = new StandardEvaluationContext(new Object[] {person2.getAge()});
context.setVariable("it", person2);
assertTrue((Boolean)ex.getValue(context));
assertTrue((Boolean)ex.getValue(context));
assertTrue((Boolean) ex.getValue(context));
assertTrue((Boolean) ex.getValue(context));
}
@Test