This is an automated email from the ASF dual-hosted git repository.

joerghoh pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git


The following commit(s) were added to refs/heads/master by this push:
     new 0840997  SLING-11601 support BVPs which provide properties with lazy 
evaluation (#17)
0840997 is described below

commit 0840997c2a9fe06f0d05a4877aa3aa72992f28ec
Author: Jörg Hoh <[email protected]>
AuthorDate: Tue Oct 4 16:49:31 2022 +0200

    SLING-11601 support BVPs which provide properties with lazy evaluation (#17)
---
 .../apache/sling/testing/mock/sling/context/MockSlingBindings.java  | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/core/src/main/java/org/apache/sling/testing/mock/sling/context/MockSlingBindings.java
 
b/core/src/main/java/org/apache/sling/testing/mock/sling/context/MockSlingBindings.java
index e177da5..b766d5a 100644
--- 
a/core/src/main/java/org/apache/sling/testing/mock/sling/context/MockSlingBindings.java
+++ 
b/core/src/main/java/org/apache/sling/testing/mock/sling/context/MockSlingBindings.java
@@ -20,10 +20,11 @@ package org.apache.sling.testing.mock.sling.context;
 
 import javax.jcr.Node;
 import javax.jcr.Session;
-import javax.script.SimpleBindings;
+import javax.script.Bindings;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.scripting.LazyBindings;
 import org.apache.sling.api.scripting.SlingBindings;
 import org.apache.sling.scripting.api.BindingsValuesProvider;
 import org.jetbrains.annotations.NotNull;
@@ -73,12 +74,13 @@ class MockSlingBindings extends SlingBindings implements 
EventHandler {
      * Removes all (non-dynamic) properties from bindings and populates them 
from all registered {@link BindingsValuesProvider} implementations.
      */
     private void populateFromBindingsValuesProvider() {
-        SimpleBindings bindings = new SimpleBindings();
+        Bindings bindings = new LazyBindings();
         for (BindingsValuesProvider provider : 
context.getServices(BindingsValuesProvider.class,
                 "(!(" + SERVICE_PROPERTY_MOCK_SLING_BINDINGS_IGNORE + 
"=true))")) {
             provider.addBindings(bindings);
         }
         this.clear();
+        // if a provider added properties which are evaluated lazily, they are 
evaluated here.
         this.putAll(bindings);
     }
 

Reply via email to