|
28 | 28 | import java.util.Map;
|
29 | 29 |
|
30 | 30 | import org.junit.Test;
|
| 31 | +import org.springframework.beans.ConfigurablePropertyAccessor; |
31 | 32 | import org.springframework.beans.MutablePropertyValues;
|
| 33 | +import org.springframework.beans.NotWritablePropertyException; |
32 | 34 | import org.springframework.beans.PropertyValues;
|
| 35 | +import org.springframework.expression.spel.SpelEvaluationException; |
33 | 36 | import org.springframework.format.annotation.DateTimeFormat;
|
34 | 37 | import org.springframework.format.annotation.DateTimeFormat.ISO;
|
35 | 38 | import org.springframework.format.support.DefaultFormattingConversionService;
|
@@ -91,7 +94,29 @@ public void skipsPropertyNotExposedByTheTypeHierarchy() {
|
91 | 94 | MutablePropertyValues values = new MutablePropertyValues();
|
92 | 95 | values.add("somethingWeird", "Value");
|
93 | 96 |
|
94 |
| - assertThat(bind(values)).isEqualTo(Collections.<String, Object> emptyMap()); |
| 97 | + assertThat(bind(values)).isEqualTo(Collections.emptyMap()); |
| 98 | + } |
| 99 | + |
| 100 | + @Test // DATACMNS-1264 |
| 101 | + public void dropsMapExpressionsForCollectionReferences() { |
| 102 | + |
| 103 | + ConfigurablePropertyAccessor accessor = new MapDataBinder(Bar.class, new DefaultFormattingConversionService()) |
| 104 | + .getPropertyAccessor(); |
| 105 | + |
| 106 | + assertThatExceptionOfType(NotWritablePropertyException.class) // |
| 107 | + .isThrownBy(() -> accessor.setPropertyValue("fooBar['foo']", null)) // |
| 108 | + .withCauseInstanceOf(SpelEvaluationException.class); |
| 109 | + } |
| 110 | + |
| 111 | + @Test // DATACMNS-1264 |
| 112 | + public void rejectsExpressionContainingTypeExpression() { |
| 113 | + |
| 114 | + ConfigurablePropertyAccessor accessor = new MapDataBinder(Bar.class, new DefaultFormattingConversionService()) |
| 115 | + .getPropertyAccessor(); |
| 116 | + |
| 117 | + assertThatExceptionOfType(NotWritablePropertyException.class) // |
| 118 | + .isThrownBy(() -> accessor.setPropertyValue("fooBar[T(java.lang.String)]", null)) // |
| 119 | + .withCauseInstanceOf(SpelEvaluationException.class); |
95 | 120 | }
|
96 | 121 |
|
97 | 122 | private static Map<String, Object> bind(PropertyValues values) {
|
|
0 commit comments