You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by jo...@apache.org on 2022/09/29 11:55:21 UTC

[sling-org-apache-sling-testing-sling-mock] branch SLING-11601-use-LazyBindings created (now 8a8f9b7)

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

joerghoh pushed a change to branch SLING-11601-use-LazyBindings
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git


      at 8a8f9b7  SLING-11601 support BVPs which provide properties with lazy evaluation

This branch includes the following new commits:

     new 8a8f9b7  SLING-11601 support BVPs which provide properties with lazy evaluation

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[sling-org-apache-sling-testing-sling-mock] 01/01: SLING-11601 support BVPs which provide properties with lazy evaluation

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8a8f9b733086d11104716eeafb46b95bf4bfa1cc
Author: Joerg Hoh <jo...@apache.org>
AuthorDate: Thu Sep 29 13:55:07 2022 +0200

    SLING-11601 support BVPs which provide properties with lazy evaluation
---
 .../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);
     }