DATACMNS-533 - Discover declared properties on EvaluationContextExtension.
We new automatically register public static fields declared on classes extending EvaluationContextExtensionSupport as properties to be used within SpEL expressions. Related pull request: spring-projects/spring-data-jpa#101 Related ticket: DATAJPA-564
This commit is contained in:
committed by
Oliver Gierke
parent
9ab9467386
commit
1ff4961cbc
@@ -116,7 +116,24 @@ public class ExtensibleEvaluationContextProviderUnitTests {
|
||||
assertThat(evaluateExpression("extensionMethod()", provider), is((Object) "methodResult"));
|
||||
}
|
||||
|
||||
static class DummyExtension extends EvaluationContextExtensionSupport {
|
||||
/**
|
||||
* @see DATACMNS-533
|
||||
*/
|
||||
@Test
|
||||
public void exposesPropertiesDefinedByExtension() {
|
||||
|
||||
List<EvaluationContextExtension> extensions = new ArrayList<EvaluationContextExtension>();
|
||||
extensions.add(new DummyExtension("_first", "first"));
|
||||
|
||||
EvaluationContextProvider provider = new ExtensionAwareEvaluationContextProvider(extensions);
|
||||
|
||||
assertThat(evaluateExpression("DUMMY_KEY", provider), is((Object) "dummy"));
|
||||
assertThat(evaluateExpression("_first.DUMMY_KEY", provider), is((Object) "dummy"));
|
||||
}
|
||||
|
||||
public static class DummyExtension extends EvaluationContextExtensionSupport {
|
||||
|
||||
public static String DUMMY_KEY = "dummy";
|
||||
|
||||
private final String key;
|
||||
private final String value;
|
||||
@@ -145,7 +162,12 @@ public class ExtensibleEvaluationContextProviderUnitTests {
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getProperties() {
|
||||
return Collections.<String, Object> singletonMap("key", value);
|
||||
|
||||
Map<String, Object> properties = new HashMap<String, Object>(super.getProperties());
|
||||
|
||||
properties.put("key", value);
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user