From 639d2c6fe74dd698236d4f447b417da7d03ecb45 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 21 Mar 2018 12:39:15 +0100 Subject: [PATCH] Polishing --- .../spel/AbstractExpressionTests.java | 14 +- .../spel/BooleanExpressionTests.java | 2 +- .../expression/spel/EvaluationTests.java | 2 +- .../spel/MethodInvocationTests.java | 10 +- .../expression/spel/SpelReproTests.java | 204 +++++++++--------- 5 files changed, 116 insertions(+), 116 deletions(-) diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java index a7c1a23c78..b93ad2f848 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java @@ -44,7 +44,7 @@ public abstract class AbstractExpressionTests { protected final ExpressionParser parser = new SpelExpressionParser(); - protected final StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext(); + protected final StandardEvaluationContext context = TestScenarioCreator.getTestEvaluationContext(); /** @@ -63,7 +63,7 @@ public abstract class AbstractExpressionTests { SpelUtilities.printAbstractSyntaxTree(System.out, expr); } - Object value = expr.getValue(eContext); + Object value = expr.getValue(context); // Check the return value if (value == null) { @@ -95,7 +95,7 @@ public abstract class AbstractExpressionTests { SpelUtilities.printAbstractSyntaxTree(System.out, expr); } - Object value = expr.getValue(eContext, expectedResultType); + Object value = expr.getValue(context, expectedResultType); if (value == null) { if (expectedValue == null) { return; // no point doing other checks @@ -127,7 +127,7 @@ public abstract class AbstractExpressionTests { if (DEBUG) { SpelUtilities.printAbstractSyntaxTree(System.out, expr); } - Object value = expr.getValue(eContext); + Object value = expr.getValue(context); if (value == null) { if (expectedValue == null) { return; // no point doing other checks @@ -145,7 +145,7 @@ public abstract class AbstractExpressionTests { assertTrue("Type of the result was not as expected. Expected '" + expectedClassOfResult + "' but result was of type '" + resultType + "'", expectedClassOfResult.equals(resultType)); - boolean isWritable = expr.isWritable(eContext); + boolean isWritable = expr.isWritable(context); if (isWritable != shouldBeWritable) { if (shouldBeWritable) fail("Expected the expression to be writable but it is not"); @@ -184,10 +184,10 @@ public abstract class AbstractExpressionTests { fail("Parser returned null for expression"); } if (expectedReturnType != null) { - expr.getValue(eContext, expectedReturnType); + expr.getValue(context, expectedReturnType); } else { - expr.getValue(eContext); + expr.getValue(context); } fail("Should have failed with message " + expectedMessage); } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java index 73b0bd740f..5feccfb836 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java @@ -104,7 +104,7 @@ public class BooleanExpressionTests extends AbstractExpressionTests { return targetType.getType() == Boolean.class ? false : null; } }; - eContext.setTypeConverter(new StandardTypeConverter(conversionService)); + context.setTypeConverter(new StandardTypeConverter(conversionService)); evaluate("null or true", Boolean.TRUE, Boolean.class, false); evaluate("null and true", Boolean.FALSE, Boolean.class, false); 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 a6e753fea7..f28b6a6816 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 @@ -359,7 +359,7 @@ public class EvaluationTests extends AbstractExpressionTests { @Test public void testTernaryOperator04() { Expression e = parser.parseExpression("1>2?3:4"); - assertFalse(e.isWritable(eContext)); + assertFalse(e.isWritable(context)); } @Test diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java index 61b5a43718..27f712c5be 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -163,9 +163,9 @@ public class MethodInvocationTests extends AbstractExpressionTests { SpelExpressionParser parser = new SpelExpressionParser(); Expression expr = parser.parseExpression("throwException(#bar)"); - eContext.setVariable("bar", 2); + context.setVariable("bar", 2); try { - expr.getValue(eContext); + expr.getValue(context); fail(); } catch (Exception ex) { @@ -187,9 +187,9 @@ public class MethodInvocationTests extends AbstractExpressionTests { SpelExpressionParser parser = new SpelExpressionParser(); Expression expr = parser.parseExpression("throwException(#bar)"); - eContext.setVariable("bar", 4); + context.setVariable("bar", 4); try { - expr.getValue(eContext); + expr.getValue(context); fail(); } catch (ExpressionInvocationTargetException ex) { diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java index 0150a6023c..534f8025ed 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -102,11 +102,11 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void SPR5899() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new Spr5899Class()); + StandardEvaluationContext context = new StandardEvaluationContext(new Spr5899Class()); Expression expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull(12)"); - assertEquals(12, expr.getValue(eContext)); + assertEquals(12, expr.getValue(context)); expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull(null)"); - assertEquals(null, expr.getValue(eContext)); + assertEquals(null, expr.getValue(context)); try { expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull2(null)"); expr.getValue(); @@ -115,73 +115,73 @@ public class SpelReproTests extends AbstractExpressionTests { catch (EvaluationException see) { // success } - eContext.setTypeLocator(new MyTypeLocator()); + context.setTypeLocator(new MyTypeLocator()); // varargs expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull3(null,'a','b')"); - assertEquals("ab", expr.getValue(eContext)); + assertEquals("ab", expr.getValue(context)); // varargs 2 - null is packed into the varargs expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull3(12,'a',null,'c')"); - assertEquals("anullc", expr.getValue(eContext)); + assertEquals("anullc", expr.getValue(context)); // check we can find the ctor ok expr = new SpelExpressionParser().parseRaw("new Spr5899Class().toString()"); - assertEquals("instance", expr.getValue(eContext)); + assertEquals("instance", expr.getValue(context)); expr = new SpelExpressionParser().parseRaw("new Spr5899Class(null).toString()"); - assertEquals("instance", expr.getValue(eContext)); + assertEquals("instance", expr.getValue(context)); // ctor varargs expr = new SpelExpressionParser().parseRaw("new Spr5899Class(null,'a','b').toString()"); - assertEquals("instance", expr.getValue(eContext)); + assertEquals("instance", expr.getValue(context)); // ctor varargs 2 expr = new SpelExpressionParser().parseRaw("new Spr5899Class(null,'a', null, 'b').toString()"); - assertEquals("instance", expr.getValue(eContext)); + assertEquals("instance", expr.getValue(context)); } @Test public void SPR5905_InnerTypeReferences() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new Spr5899Class()); + StandardEvaluationContext context = new StandardEvaluationContext(new Spr5899Class()); Expression expr = new SpelExpressionParser().parseRaw("T(java.util.Map$Entry)"); - assertEquals(Map.Entry.class, expr.getValue(eContext)); + assertEquals(Map.Entry.class, expr.getValue(context)); expr = new SpelExpressionParser().parseRaw("T(org.springframework.expression.spel.SpelReproTests$Outer$Inner).run()"); - assertEquals(12, expr.getValue(eContext)); + assertEquals(12, expr.getValue(context)); expr = new SpelExpressionParser().parseRaw("new org.springframework.expression.spel.SpelReproTests$Outer$Inner().run2()"); - assertEquals(13, expr.getValue(eContext)); + assertEquals(13, expr.getValue(context)); } @Test public void SPR5804() { Map m = new HashMap<>(); m.put("foo", "bar"); - StandardEvaluationContext eContext = new StandardEvaluationContext(m); // root is a map instance - eContext.addPropertyAccessor(new MapAccessor()); + StandardEvaluationContext context = new StandardEvaluationContext(m); // root is a map instance + context.addPropertyAccessor(new MapAccessor()); Expression expr = new SpelExpressionParser().parseRaw("['foo']"); - assertEquals("bar", expr.getValue(eContext)); + assertEquals("bar", expr.getValue(context)); } @Test public void SPR5847() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new TestProperties()); + StandardEvaluationContext context = new StandardEvaluationContext(new TestProperties()); String name = null; Expression expr = null; expr = new SpelExpressionParser().parseRaw("jdbcProperties['username']"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("Dave", name); expr = new SpelExpressionParser().parseRaw("jdbcProperties[username]"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("Dave", name); // MapAccessor required for this to work expr = new SpelExpressionParser().parseRaw("jdbcProperties.username"); - eContext.addPropertyAccessor(new MapAccessor()); - name = expr.getValue(eContext, String.class); + context.addPropertyAccessor(new MapAccessor()); + name = expr.getValue(context, String.class); assertEquals("Dave", name); // --- dotted property names @@ -189,14 +189,14 @@ public class SpelReproTests extends AbstractExpressionTests { // lookup foo on the root, then bar on that, then use that as the key into // jdbcProperties expr = new SpelExpressionParser().parseRaw("jdbcProperties[foo.bar]"); - eContext.addPropertyAccessor(new MapAccessor()); - name = expr.getValue(eContext, String.class); + context.addPropertyAccessor(new MapAccessor()); + name = expr.getValue(context, String.class); assertEquals("Dave2", name); // key is foo.bar expr = new SpelExpressionParser().parseRaw("jdbcProperties['foo.bar']"); - eContext.addPropertyAccessor(new MapAccessor()); - name = expr.getValue(eContext, String.class); + context.addPropertyAccessor(new MapAccessor()); + name = expr.getValue(context, String.class); assertEquals("Elephant", name); } @@ -237,13 +237,13 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void accessingNullPropertyViaReflection_SPR5663() throws AccessException { - PropertyAccessor propertyAccessor = new ReflectivePropertyAccessor(); + PropertyAccessor accessor = new ReflectivePropertyAccessor(); EvaluationContext context = TestScenarioCreator.getTestEvaluationContext(); - assertFalse(propertyAccessor.canRead(context, null, "abc")); - assertFalse(propertyAccessor.canWrite(context, null, "abc")); + assertFalse(accessor.canRead(context, null, "abc")); + assertFalse(accessor.canWrite(context, null, "abc")); try { - propertyAccessor.read(context, null, "abc"); + accessor.read(context, null, "abc"); fail("Should have failed with an IllegalStateException"); } catch (IllegalStateException ex) { @@ -251,7 +251,7 @@ public class SpelReproTests extends AbstractExpressionTests { } try { - propertyAccessor.write(context, null, "abc", "foo"); + accessor.write(context, null, "abc", "foo"); fail("Should have failed with an IllegalStateException"); } catch (IllegalStateException ex) { @@ -261,36 +261,36 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void nestedProperties_SPR6923() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new Foo()); + StandardEvaluationContext context = new StandardEvaluationContext(new Foo()); Expression expr = new SpelExpressionParser().parseRaw("resource.resource.server"); - String name = expr.getValue(eContext, String.class); + String name = expr.getValue(context, String.class); assertEquals("abc", name); } /** Should be accessing Goo.getKey because 'bar' field evaluates to "key" */ @Test public void indexingAsAPropertyAccess_SPR6968_1() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new Goo()); + StandardEvaluationContext context = new StandardEvaluationContext(new Goo()); String name = null; Expression expr = null; expr = new SpelExpressionParser().parseRaw("instance[bar]"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("hello", name); - name = expr.getValue(eContext, String.class); // will be using the cached accessor this time + name = expr.getValue(context, String.class); // will be using the cached accessor this time assertEquals("hello", name); } /** Should be accessing Goo.getKey because 'bar' variable evaluates to "key" */ @Test public void indexingAsAPropertyAccess_SPR6968_2() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new Goo()); - eContext.setVariable("bar", "key"); + StandardEvaluationContext context = new StandardEvaluationContext(new Goo()); + context.setVariable("bar", "key"); String name = null; Expression expr = null; expr = new SpelExpressionParser().parseRaw("instance[#bar]"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("hello", name); - name = expr.getValue(eContext, String.class); // will be using the cached accessor this time + name = expr.getValue(context, String.class); // will be using the cached accessor this time assertEquals("hello", name); } @@ -298,8 +298,8 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void dollarPrefixedIdentifier_SPR7100() { Holder h = new Holder(); - StandardEvaluationContext eContext = new StandardEvaluationContext(h); - eContext.addPropertyAccessor(new MapAccessor()); + StandardEvaluationContext context = new StandardEvaluationContext(h); + context.addPropertyAccessor(new MapAccessor()); h.map.put("$foo", "wibble"); h.map.put("foo$bar", "wobble"); h.map.put("foobar$$", "wabble"); @@ -310,42 +310,42 @@ public class SpelReproTests extends AbstractExpressionTests { Expression expr = null; expr = new SpelExpressionParser().parseRaw("map.$foo"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("wibble", name); expr = new SpelExpressionParser().parseRaw("map.foo$bar"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("wobble", name); expr = new SpelExpressionParser().parseRaw("map.foobar$$"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("wabble", name); expr = new SpelExpressionParser().parseRaw("map.$"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("wubble", name); expr = new SpelExpressionParser().parseRaw("map.$$"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("webble", name); expr = new SpelExpressionParser().parseRaw("map.$_$"); - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("tribble", name); } /** Should be accessing Goo.wibble field because 'bar' variable evaluates to "wibble" */ @Test public void indexingAsAPropertyAccess_SPR6968_3() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new Goo()); - eContext.setVariable("bar", "wibble"); + StandardEvaluationContext context = new StandardEvaluationContext(new Goo()); + context.setVariable("bar", "wibble"); String name = null; Expression expr = null; expr = new SpelExpressionParser().parseRaw("instance[#bar]"); // will access the field 'wibble' and not use a getter - name = expr.getValue(eContext, String.class); + name = expr.getValue(context, String.class); assertEquals("wobble", name); - name = expr.getValue(eContext, String.class); // will be using the cached accessor this time + name = expr.getValue(context, String.class); // will be using the cached accessor this time assertEquals("wobble", name); } @@ -356,14 +356,14 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void indexingAsAPropertyAccess_SPR6968_4() { Goo g = Goo.instance; - StandardEvaluationContext eContext = new StandardEvaluationContext(g); - eContext.setVariable("bar", "wibble"); + StandardEvaluationContext context = new StandardEvaluationContext(g); + context.setVariable("bar", "wibble"); Expression expr = null; expr = new SpelExpressionParser().parseRaw("instance[#bar]='world'"); // will access the field 'wibble' and not use a getter - expr.getValue(eContext, String.class); + expr.getValue(context, String.class); assertEquals("world", g.wibble); - expr.getValue(eContext, String.class); // will be using the cached accessor this time + expr.getValue(context, String.class); // will be using the cached accessor this time assertEquals("world", g.wibble); } @@ -371,31 +371,31 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void indexingAsAPropertyAccess_SPR6968_5() { Goo g = Goo.instance; - StandardEvaluationContext eContext = new StandardEvaluationContext(g); + StandardEvaluationContext context = new StandardEvaluationContext(g); Expression expr = null; expr = new SpelExpressionParser().parseRaw("instance[bar]='world'"); - expr.getValue(eContext, String.class); + expr.getValue(context, String.class); assertEquals("world", g.value); - expr.getValue(eContext, String.class); // will be using the cached accessor this time + expr.getValue(context, String.class); // will be using the cached accessor this time assertEquals("world", g.value); } @Test public void dollars() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new XX()); + StandardEvaluationContext context = new StandardEvaluationContext(new XX()); Expression expr = null; expr = new SpelExpressionParser().parseRaw("m['$foo']"); - eContext.setVariable("file_name", "$foo"); - assertEquals("wibble", expr.getValue(eContext, String.class)); + context.setVariable("file_name", "$foo"); + assertEquals("wibble", expr.getValue(context, String.class)); } @Test public void dollars2() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new XX()); + StandardEvaluationContext context = new StandardEvaluationContext(new XX()); Expression expr = null; expr = new SpelExpressionParser().parseRaw("m[$foo]"); - eContext.setVariable("file_name", "$foo"); - assertEquals("wibble", expr.getValue(eContext, String.class)); + context.setVariable("file_name", "$foo"); + assertEquals("wibble", expr.getValue(context, String.class)); } private void checkTemplateParsing(String expression, String expectedValue) { @@ -448,33 +448,33 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void beanResolution() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new XX()); + StandardEvaluationContext context = new StandardEvaluationContext(new XX()); Expression expr = null; // no resolver registered == exception try { expr = new SpelExpressionParser().parseRaw("@foo"); - assertEquals("custard", expr.getValue(eContext, String.class)); + assertEquals("custard", expr.getValue(context, String.class)); } catch (SpelEvaluationException see) { assertEquals(SpelMessage.NO_BEAN_RESOLVER_REGISTERED, see.getMessageCode()); assertEquals("foo", see.getInserts()[0]); } - eContext.setBeanResolver(new MyBeanResolver()); + context.setBeanResolver(new MyBeanResolver()); // bean exists expr = new SpelExpressionParser().parseRaw("@foo"); - assertEquals("custard", expr.getValue(eContext, String.class)); + assertEquals("custard", expr.getValue(context, String.class)); // bean does not exist expr = new SpelExpressionParser().parseRaw("@bar"); - assertEquals(null, expr.getValue(eContext, String.class)); + assertEquals(null, expr.getValue(context, String.class)); // bean name will cause AccessException expr = new SpelExpressionParser().parseRaw("@goo"); try { - assertEquals(null, expr.getValue(eContext, String.class)); + assertEquals(null, expr.getValue(context, String.class)); } catch (SpelEvaluationException see) { assertEquals(SpelMessage.EXCEPTION_DURING_BEAN_RESOLUTION, see.getMessageCode()); @@ -485,12 +485,12 @@ public class SpelReproTests extends AbstractExpressionTests { // bean exists expr = new SpelExpressionParser().parseRaw("@'foo.bar'"); - assertEquals("trouble", expr.getValue(eContext, String.class)); + assertEquals("trouble", expr.getValue(context, String.class)); // bean exists try { expr = new SpelExpressionParser().parseRaw("@378"); - assertEquals("trouble", expr.getValue(eContext, String.class)); + assertEquals("trouble", expr.getValue(context, String.class)); } catch (SpelParseException spe) { assertEquals(SpelMessage.INVALID_BEAN_REFERENCE, spe.getMessageCode()); @@ -499,7 +499,7 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void elvis_SPR7209_1() { - StandardEvaluationContext eContext = new StandardEvaluationContext(new XX()); + StandardEvaluationContext context = new StandardEvaluationContext(new XX()); Expression expr = null; // Different parts of elvis expression are null @@ -513,7 +513,7 @@ public class SpelReproTests extends AbstractExpressionTests { // Different parts of ternary expression are null try { expr = new SpelExpressionParser().parseRaw("(?'abc':'default')"); - expr.getValue(eContext); + expr.getValue(context); fail(); } catch (SpelEvaluationException see) { @@ -525,7 +525,7 @@ public class SpelReproTests extends AbstractExpressionTests { // Assignment try { expr = new SpelExpressionParser().parseRaw("(='default')"); - expr.getValue(eContext); + expr.getValue(context); fail(); } catch (SpelEvaluationException see) { @@ -553,55 +553,55 @@ public class SpelReproTests extends AbstractExpressionTests { nameMap.put("givenName", "Arthur"); map.put("value", nameMap); - StandardEvaluationContext ctx = new StandardEvaluationContext(map); + StandardEvaluationContext context = new StandardEvaluationContext(map); ExpressionParser parser = new SpelExpressionParser(); String el1 = "#root['value'].get('givenName')"; Expression exp = parser.parseExpression(el1); - Object evaluated = exp.getValue(ctx); + Object evaluated = exp.getValue(context); assertEquals("Arthur", evaluated); String el2 = "#root['value']['givenName']"; exp = parser.parseExpression(el2); - evaluated = exp.getValue(ctx); + evaluated = exp.getValue(context); assertEquals("Arthur", evaluated); } @Test public void projectionTypeDescriptors_1() { - StandardEvaluationContext ctx = new StandardEvaluationContext(new C()); + StandardEvaluationContext context = new StandardEvaluationContext(new C()); SpelExpressionParser parser = new SpelExpressionParser(); String el1 = "ls.![#this.equals('abc')]"; SpelExpression exp = parser.parseRaw(el1); - List value = (List) exp.getValue(ctx); + List value = (List) exp.getValue(context); // value is list containing [true,false] assertEquals(Boolean.class, value.get(0).getClass()); - TypeDescriptor evaluated = exp.getValueTypeDescriptor(ctx); + TypeDescriptor evaluated = exp.getValueTypeDescriptor(context); assertEquals(null, evaluated.getElementTypeDescriptor()); } @Test public void projectionTypeDescriptors_2() { - StandardEvaluationContext ctx = new StandardEvaluationContext(new C()); + StandardEvaluationContext context = new StandardEvaluationContext(new C()); SpelExpressionParser parser = new SpelExpressionParser(); String el1 = "as.![#this.equals('abc')]"; SpelExpression exp = parser.parseRaw(el1); - Object[] value = (Object[]) exp.getValue(ctx); + Object[] value = (Object[]) exp.getValue(context); // value is array containing [true,false] assertEquals(Boolean.class, value[0].getClass()); - TypeDescriptor evaluated = exp.getValueTypeDescriptor(ctx); + TypeDescriptor evaluated = exp.getValueTypeDescriptor(context); assertEquals(Boolean.class, evaluated.getElementTypeDescriptor().getType()); } @Test public void projectionTypeDescriptors_3() { - StandardEvaluationContext ctx = new StandardEvaluationContext(new C()); + StandardEvaluationContext context = new StandardEvaluationContext(new C()); SpelExpressionParser parser = new SpelExpressionParser(); String el1 = "ms.![key.equals('abc')]"; SpelExpression exp = parser.parseRaw(el1); - List value = (List) exp.getValue(ctx); + List value = (List) exp.getValue(context); // value is list containing [true,false] assertEquals(Boolean.class, value.get(0).getClass()); - TypeDescriptor evaluated = exp.getValueTypeDescriptor(ctx); + TypeDescriptor evaluated = exp.getValueTypeDescriptor(context); assertEquals(null, evaluated.getElementTypeDescriptor()); } @@ -615,23 +615,23 @@ public class SpelReproTests extends AbstractExpressionTests { list.add(new D(null)); list.add(new D("zzz")); - StandardEvaluationContext ctx = new StandardEvaluationContext(list); + StandardEvaluationContext context = new StandardEvaluationContext(list); SpelExpressionParser parser = new SpelExpressionParser(); String el1 = "#root.?[a < 'hhh']"; SpelExpression exp = parser.parseRaw(el1); - Object value = exp.getValue(ctx); + Object value = exp.getValue(context); assertEquals("[D(aaa), D(bbb), D(null), D(ccc), D(null)]", value.toString()); String el2 = "#root.?[a > 'hhh']"; SpelExpression exp2 = parser.parseRaw(el2); - Object value2 = exp2.getValue(ctx); + Object value2 = exp2.getValue(context); assertEquals("[D(zzz)]", value2.toString()); // trim out the nulls first String el3 = "#root.?[a!=null].?[a < 'hhh']"; SpelExpression exp3 = parser.parseRaw(el3); - Object value3 = exp3.getValue(ctx); + Object value3 = exp3.getValue(context); assertEquals("[D(aaa), D(bbb), D(ccc)]", value3.toString()); } @@ -820,41 +820,41 @@ public class SpelReproTests extends AbstractExpressionTests { } } - StandardEvaluationContext ctx = new StandardEvaluationContext(new Reserver()); + StandardEvaluationContext context = new StandardEvaluationContext(new Reserver()); SpelExpressionParser parser = new SpelExpressionParser(); String ex = "getReserver().NE"; SpelExpression exp = parser.parseRaw(ex); - String value = (String) exp.getValue(ctx); + String value = (String) exp.getValue(context); assertEquals("abc", value); ex = "getReserver().ne"; exp = parser.parseRaw(ex); - value = (String) exp.getValue(ctx); + value = (String) exp.getValue(context); assertEquals("def", value); ex = "getReserver().m[NE]"; exp = parser.parseRaw(ex); - value = (String) exp.getValue(ctx); + value = (String) exp.getValue(context); assertEquals("xyz", value); ex = "getReserver().DIV"; exp = parser.parseRaw(ex); - assertEquals(1, exp.getValue(ctx)); + assertEquals(1, exp.getValue(context)); ex = "getReserver().div"; exp = parser.parseRaw(ex); - assertEquals(3, exp.getValue(ctx)); + assertEquals(3, exp.getValue(context)); exp = parser.parseRaw("NE"); - assertEquals("abc", exp.getValue(ctx)); + assertEquals("abc", exp.getValue(context)); } @Test public void reservedWordProperties_SPR9862() { - StandardEvaluationContext ctx = new StandardEvaluationContext(); + StandardEvaluationContext context = new StandardEvaluationContext(); SpelExpressionParser parser = new SpelExpressionParser(); SpelExpression expression = parser.parseRaw("T(org.springframework.expression.spel.testresources.le.div.mod.reserved.Reserver).CONST"); - Object value = expression.getValue(ctx); + Object value = expression.getValue(context); assertEquals(value, Reserver.CONST); }