Add support for making MapAccessor read-only
See gh-33222
This commit is contained in:
committed by
Stéphane Nicoll
parent
ec383f69f2
commit
a0e43b1f46
@@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* Tests for {@link MapAccessor}.
|
||||
*
|
||||
* @author Andy Clement
|
||||
* @author Yanming Zhou
|
||||
*/
|
||||
class MapAccessorTests {
|
||||
|
||||
@@ -80,6 +81,16 @@ class MapAccessorTests {
|
||||
assertThat(ex.getValue(sec,testMap)).isEqualTo("bar2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapAccessorNotWritable() {
|
||||
Map<String, Object> testMap = getSimpleTestMap();
|
||||
StandardEvaluationContext sec = new StandardEvaluationContext();
|
||||
sec.addPropertyAccessor(new MapAccessor(false));
|
||||
SpelExpressionParser sep = new SpelExpressionParser();
|
||||
Expression ex = sep.parseExpression("foo");
|
||||
assertThat(ex.isWritable(sec, testMap)).isFalse();
|
||||
}
|
||||
|
||||
public static class MapGetter {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user