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 <[email protected]> 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); }
