diff --git a/bundle/pom.xml b/bundle/pom.xml
index 0afa8e9946..f1d738db0e 100644
--- a/bundle/pom.xml
+++ b/bundle/pom.xml
@@ -41,37 +41,6 @@
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
-
- download-sling-api-2-22-0-jar
- process-test-resources
-
- copy
-
-
-
- -
- org.apache.sling
- org.apache.sling.api
- 2.22.0
- jar
-
-
-
-
- ${project.build.testOutputDirectory}
-
-
-
-
biz.aQute.bnd
bnd-baseline-maven-plugin
@@ -356,6 +325,8 @@
org.osgi
org.osgi.dto
+
+ 1.1.0
provided
@@ -383,11 +354,6 @@
slf4j-api
provided
-
- javax.mail
- mail
- provided
-
ch.qos.logback
@@ -423,6 +389,8 @@
com.github.jknack
handlebars
+
+ 4.0.5
provided
@@ -745,7 +713,7 @@
com.adobe.aem
uber-jar
- apis
+ apis-with-deprecations
provided
diff --git a/bundle/src/main/java/com/adobe/acs/commons/wcm/properties/shared/impl/SharedComponentPropertiesBindingsValuesProvider.java b/bundle/src/main/java/com/adobe/acs/commons/wcm/properties/shared/impl/SharedComponentPropertiesBindingsValuesProvider.java
index 32781804d4..9db2473c51 100644
--- a/bundle/src/main/java/com/adobe/acs/commons/wcm/properties/shared/impl/SharedComponentPropertiesBindingsValuesProvider.java
+++ b/bundle/src/main/java/com/adobe/acs/commons/wcm/properties/shared/impl/SharedComponentPropertiesBindingsValuesProvider.java
@@ -20,7 +20,6 @@
package com.adobe.acs.commons.wcm.properties.shared.impl;
import com.adobe.acs.commons.wcm.properties.shared.SharedComponentProperties;
-import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
@@ -29,18 +28,15 @@
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.api.scripting.LazyBindings;
import org.apache.sling.api.scripting.SlingBindings;
import org.apache.sling.scripting.api.BindingsValuesProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.script.Bindings;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
import java.util.Optional;
import java.util.function.Supplier;
-import java.util.stream.Stream;
/**
* Bindings Values Provider that adds bindings for globalProperties,
@@ -62,170 +58,32 @@
public class SharedComponentPropertiesBindingsValuesProvider implements BindingsValuesProvider {
private static final Logger log = LoggerFactory.getLogger(SharedComponentPropertiesBindingsValuesProvider.class);
- /**
- * The LazyBindings class, and its Supplier child interface, are introduced in org.apache.sling.api version 2.22.0,
- * which is first included in AEM 6.5 SP7.
- */
- protected static final String FQDN_LAZY_BINDINGS = "org.apache.sling.api.scripting.LazyBindings";
- protected static final String SUPPLIER_PROXY_LABEL = "ACS AEM Commons SCP BVP reflective Proxy for LazyBindings.Supplier";
-
/**
* Bind if available, check for null when reading.
*/
@Reference(policyOption = ReferencePolicyOption.GREEDY, cardinality = ReferenceCardinality.OPTIONAL_UNARY)
SharedComponentProperties sharedComponentProperties;
- /**
- * Added for pre-6.5.7 support for LazyBindings. This holds the LazyBindings interface
- * if it is discovered on activation, and is used to check if the {@link #addBindings(Bindings)} param
- * is an instance of LazyBindings. This hack is necessary until this bundle can drop support for
- * AEM versions prior to 6.5.7, at which point this variable can be removed, and the {@link #isLazy(Bindings)}
- * method can be simplified to return {@code bindings instanceof LazyBindings}.
- */
- private Class extends Bindings> lazyBindingsType;
-
- /**
- * Added for pre-6.5.7 support for LazyBindings. This holds the LazyBindings.Supplier interface
- * if it is discovered on activation, and is used to create reflection Proxy instances as a hack
- * until this bundle can drop support for AEM versions prior to 6.5.7, at which point this variable
- * can be removed, and the {@link #wrapSupplier(Supplier)} method can be simplified to accept a
- * LazyBindings.Supplier instead of a java.util.function.Supplier and return it (for matching a
- * lambda expression passed at the call site), or to simply return a lambda that calls the get()
- * method on the java.util.function.Supplier argument.
- */
- private Class extends Supplier> supplierType;
-
- /**
- * This variable only exists to facilitate testing for pre-6.5.7 LazyBindings support, so that a non-classpath
- * class loader can be injected, to provide the LazyBindings class.
- */
- private ClassLoader lazyBindingsClassLoader = SlingBindings.class.getClassLoader();
-
- /**
- * Called by the unit test to inject a URL class loader that provides a LazyBindings instance
- * at {@link #FQDN_LAZY_BINDINGS}.
- *
- * @param classLoader a new class loader
- * @return the old class loader
- */
- protected ClassLoader swapLazyBindingsClassLoaderForTesting(ClassLoader classLoader) {
- if (classLoader != null) {
- ClassLoader oldClassLoader = this.lazyBindingsClassLoader;
- this.lazyBindingsClassLoader = classLoader;
- return oldClassLoader;
- }
- return null;
- }
-
- /**
- * Return the resolved lazyBindingsType for testing.
- *
- * @return the lazyBindingsType
- */
- protected Class extends Bindings> getLazyBindingsType() {
- return this.lazyBindingsType;
- }
-
- /**
- * Return the resolved supplierType for testing.
- *
- * @return the supplierType
- */
- protected Class extends Supplier> getSupplierType() {
- return this.supplierType;
- }
-
/**
* This method ensures that the provided supplier is appropriately typed for insertion into a SlingBindings
* object. It primarily facilitates lambda type inference (i.e., {@code wrapSupplier(() -> something)} forces
- * inference to the functional interface type of the method parameter). And so long as pre-6.5.7 AEMs are supported,
- * this method is also responsible for constructing the {@link Proxy} instance when LazyBindings is present at
- * runtime, and for immediately returning {@code Supplier.get()} when it is not present.
- * After support for pre-6.5.7 AEMs is dropped, the method return type can be changed from {@code Object} to
- * {@code LazyBindings.Supplier} to fully support lazy injection.
+ * inference to the functional interface type of the method parameter).
*
* @param supplier the provided supplier
- * @return the Supplier as a LazyBindings.Supplier if supported, or the value of the provided supplier if not
- */
- protected Object wrapSupplier(final Supplier> supplier) {
- if (this.supplierType != null) {
- return Proxy.newProxyInstance(lazyBindingsClassLoader, new Class[]{this.supplierType},
- new SupplierWrapper(supplier));
- }
- return supplier.get();
- }
-
- /**
- * The only purpose of this class is to drive the pre-6.5.7 reflection-based Proxy instance returned
- * by {@link #wrapSupplier(Supplier)}.
- */
- protected static class SupplierWrapper implements InvocationHandler {
- private final Supplier> wrapped;
-
- public SupplierWrapper(final Supplier> supplier) {
- this.wrapped = supplier;
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- // we are implementing a @FunctionalInterface, so don't get carried away with implementing
- // Object methods.
- if ("get".equals(method.getName())) {
- return wrapped.get();
- } else if ("toString".equals(method.getName())) {
- // return this marker string for visibility in debugging tools. Otherwise,
- // the default toString is "\"null\"", which is confusing
- return SUPPLIER_PROXY_LABEL;
- }
- return method.getDefaultValue();
- }
- }
-
- /**
- * The purpose of this activate method is to determine if we are running in a 6.5.7+ AEM environment
- * without having to explicitly require {@code org.apache.sling.api.scripting} package version 2.5.0.
- */
- @Activate
- protected void activate() {
- // use SlingBindings class loader to check for LazyBindings class,
- // to minimize risk involved with using reflection.
- try {
- this.checkAndSetLazyBindingsType(lazyBindingsClassLoader.loadClass(FQDN_LAZY_BINDINGS));
- } catch (ReflectiveOperationException cnfe) {
- log.info("LazyBindings not found, will resort to injecting immediate Bindings values", cnfe);
- }
- }
-
- /**
- * Check that the provided {@code lazyBindingsType} implements {@link Bindings} and defines an enclosed marker
- * interface named {@code Supplier} that extends {@link Supplier}, and if so, set {@code this.lazyBindingsType} and
- * {@code this.supplierType}. Otherwise, set both to {@code null}.
+ * @return the Supplier as a LazyBindings.Supplier
*/
- @SuppressWarnings({"squid:S1872", "unchecked"})
- protected void checkAndSetLazyBindingsType(final Class> lazyBindingsType) {
- if (lazyBindingsType != null && Bindings.class.isAssignableFrom(lazyBindingsType)) {
- this.supplierType = (Class extends Supplier>) Stream.of(lazyBindingsType.getDeclaredClasses())
- .filter(clazz -> Supplier.class.getSimpleName().equals(clazz.getSimpleName())
- && Supplier.class.isAssignableFrom(clazz)).findFirst().orElse(null);
- this.lazyBindingsType = (Class extends Bindings>) lazyBindingsType;
- } else {
- log.info("Supplier interface not declared by lazyBindingsType: {}, will resort to immediate Bindings values",
- lazyBindingsType);
- this.supplierType = null;
- this.lazyBindingsType = null;
- }
+ protected LazyBindings.Supplier wrapSupplier(final Supplier> supplier) {
+ return () -> supplier != null ? supplier.get() : null;
}
/**
- * Check if provided {@code bindings} implements LazyBindings.
+ * Check if provided {@code bindings} is an instance of {@link LazyBindings}.
*
* @param bindings the parameter from {@link #addBindings(Bindings)}
* @return true if bindings implements LazyBindings
*/
private boolean isLazy(Bindings bindings) {
- return Optional.ofNullable(this.lazyBindingsType)
- .map(clazz -> clazz.isInstance(bindings))
- .orElse(false);
+ return bindings instanceof LazyBindings;
}
/**
diff --git a/bundle/src/test/java/com/adobe/acs/commons/images/transformers/impl/AdjustImageTransformerImplTest.java b/bundle/src/test/java/com/adobe/acs/commons/images/transformers/impl/AdjustImageTransformerImplTest.java
index b20aa041a5..64a5f53107 100644
--- a/bundle/src/test/java/com/adobe/acs/commons/images/transformers/impl/AdjustImageTransformerImplTest.java
+++ b/bundle/src/test/java/com/adobe/acs/commons/images/transformers/impl/AdjustImageTransformerImplTest.java
@@ -20,7 +20,6 @@
package com.adobe.acs.commons.images.transformers.impl;
-import com.adobe.acs.commons.images.transformers.impl.AdjustImageTransformerImpl;
import com.day.image.Layer;
import org.apache.sling.api.resource.ValueMap;
@@ -49,25 +48,22 @@ public class AdjustImageTransformerImplTest {
@Mock
Layer layer;
- Map map = null;
@Before
public void setUp() throws Exception {
- map = new HashMap();
transformer = new AdjustImageTransformerImpl();
}
@After
public void tearDown() throws Exception {
reset(layer);
- map = null;
}
@Test
public void testTransform() throws Exception {
final Integer brightness = 100;
final Float contrast = 0.05F;
-
+ Map map = new HashMap<>();
map.put("brightness", brightness.toString());
map.put("contrast", contrast.toString());
ValueMap properties = new ValueMapDecorator(map);
@@ -80,6 +76,7 @@ public void testTransform() throws Exception {
@Test
public void testTransform_noParams() throws Exception {
+ Map map = new HashMap<>();
ValueMap properties = new ValueMapDecorator(map);
transformer.transform(layer, properties);
@@ -90,7 +87,7 @@ public void testTransform_noParams() throws Exception {
@Test
public void testTransform_onlyBrightness() throws Exception {
final Integer brightness = 100;
-
+ Map map = new HashMap<>();
map.put("brightness", brightness.toString());
ValueMap properties = new ValueMapDecorator(map);
@@ -103,7 +100,7 @@ public void testTransform_onlyBrightness() throws Exception {
@Test
public void testTransform_onlyContrast() throws Exception {
final Float contrast = 0.05F;
-
+ Map map = new HashMap<>();
map.put("contrast", contrast.toString());
ValueMap properties = new ValueMapDecorator(map);
diff --git a/bundle/src/test/java/com/adobe/acs/commons/wcm/properties/shared/impl/SharedComponentPropertiesBindingsValuesProviderTest.java b/bundle/src/test/java/com/adobe/acs/commons/wcm/properties/shared/impl/SharedComponentPropertiesBindingsValuesProviderTest.java
index ae949eafd1..96d73b0d8a 100644
--- a/bundle/src/test/java/com/adobe/acs/commons/wcm/properties/shared/impl/SharedComponentPropertiesBindingsValuesProviderTest.java
+++ b/bundle/src/test/java/com/adobe/acs/commons/wcm/properties/shared/impl/SharedComponentPropertiesBindingsValuesProviderTest.java
@@ -19,31 +19,13 @@
*/
package com.adobe.acs.commons.wcm.properties.shared.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.function.BiFunction;
-import java.util.function.Supplier;
-
-import javax.script.Bindings;
-import javax.script.SimpleBindings;
-
+import com.adobe.acs.commons.wcm.PageRootProvider;
+import com.adobe.acs.commons.wcm.properties.shared.SharedComponentProperties;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.api.scripting.LazyBindings;
import org.apache.sling.api.scripting.SlingBindings;
import org.apache.sling.api.wrappers.ValueMapDecorator;
import org.junit.Before;
@@ -51,9 +33,22 @@
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
-import com.adobe.acs.commons.wcm.PageRootProvider;
-import com.adobe.acs.commons.wcm.properties.shared.SharedComponentProperties;
-import org.osgi.annotation.versioning.ConsumerType;
+import javax.script.Bindings;
+import javax.script.SimpleBindings;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.BiFunction;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class SharedComponentPropertiesBindingsValuesProviderTest {
@@ -61,11 +56,6 @@ public class SharedComponentPropertiesBindingsValuesProviderTest {
public static final String SITE_ROOT = "/content/acs-commons";
public static final String RESOURCE_TYPE = "acs-commons/components/content/generic-text";
- /**
- * Pre-6.5.7 LazyBindings support.
- */
- private static final String REL_PATH_SLING_API_2_22_0 = "org.apache.sling.api-2.22.0.jar";
-
private PageRootProvider pageRootProvider;
private Resource resource;
private Resource sharedPropsResource;
@@ -79,20 +69,6 @@ public class SharedComponentPropertiesBindingsValuesProviderTest {
private ValueMap localProps;
- /**
- * Pre-6.5.7 LazyBindings support. This class simulates the LazyBindings and LazyBindings.Supplier class hierarchy
- * until this project upgrades to a dependency list that includes org.apache.sling.api version 2.22.0+.
- *
- * @see LazyBindings
- */
- @ConsumerType
- private static class LazyLikeBindings extends SimpleBindings {
- @ConsumerType
- @FunctionalInterface
- interface Supplier extends java.util.function.Supplier {
- }
- }
-
@Before
public void setUp() throws Exception {
resource = mock(Resource.class);
@@ -177,7 +153,6 @@ public void addBindings() {
= new SharedComponentPropertiesBindingsValuesProvider();
sharedComponentPropertiesBindingsValuesProvider.sharedComponentProperties = sharedComponentProperties;
- sharedComponentPropertiesBindingsValuesProvider.activate();
sharedComponentPropertiesBindingsValuesProvider.addBindings(bindings);
assertEquals(sharedPropsResource, bindings.get(SharedComponentProperties.SHARED_PROPERTIES_RESOURCE));
@@ -199,179 +174,49 @@ public void addToLazyBindings() {
final SharedComponentPropertiesBindingsValuesProvider sharedComponentPropertiesBindingsValuesProvider
= new SharedComponentPropertiesBindingsValuesProvider();
-
sharedComponentPropertiesBindingsValuesProvider.sharedComponentProperties = sharedComponentProperties;
- sharedComponentPropertiesBindingsValuesProvider.activate();
- sharedComponentPropertiesBindingsValuesProvider.checkAndSetLazyBindingsType(LazyLikeBindings.class);
- LazyLikeBindings lazyBindings = new LazyLikeBindings();
+ // inject our own suppliers map for a side-channel to the suppliers
+ final Map suppliers = new HashMap<>();
+ LazyBindings lazyBindings = new LazyBindings(suppliers);
lazyBindings.putAll(bindings);
sharedComponentPropertiesBindingsValuesProvider.addBindings(lazyBindings);
// confirm that the bindings is storing a marked Supplier, rather than a resource
- Object sharedPropsObject = lazyBindings.get(SharedComponentProperties.SHARED_PROPERTIES_RESOURCE);
- assertTrue(sharedPropsObject instanceof LazyLikeBindings.Supplier);
- assertEquals(SharedComponentPropertiesBindingsValuesProvider.SUPPLIER_PROXY_LABEL, sharedPropsObject.toString());
+ LazyBindings.Supplier sharedPropsObject = suppliers.get(SharedComponentProperties.SHARED_PROPERTIES_RESOURCE);
+ assertNotNull(sharedPropsObject);
// compare that the value returned by the supplier with the expected resource
- assertEquals(sharedPropsResource, ((LazyLikeBindings.Supplier) sharedPropsObject).get());
+ assertEquals(sharedPropsResource, sharedPropsObject.get());
// confirm that the bindings is storing a marked Supplier, rather than a resource
- Object globalPropsObject = lazyBindings.get(SharedComponentProperties.GLOBAL_PROPERTIES_RESOURCE);
- assertTrue(globalPropsObject instanceof LazyLikeBindings.Supplier);
+ LazyBindings.Supplier globalPropsObject = suppliers.get(SharedComponentProperties.GLOBAL_PROPERTIES_RESOURCE);
+ assertNotNull(globalPropsObject);
// compare that the value returned by the supplier with the expected resource
- assertEquals(globalPropsResource, ((LazyLikeBindings.Supplier) globalPropsObject).get());
+ assertEquals(globalPropsResource, globalPropsObject.get());
// confirm that the bindings is storing a marked Supplier, rather than a ValueMap
- Object sharedPropsVmObject = lazyBindings.get(SharedComponentProperties.SHARED_PROPERTIES);
- assertTrue(sharedPropsVmObject instanceof LazyLikeBindings.Supplier);
+ LazyBindings.Supplier sharedPropsVmObject = suppliers.get(SharedComponentProperties.SHARED_PROPERTIES);
+ assertNotNull(sharedPropsVmObject);
// compare that the value returned by the supplier with the expected ValueMap
- assertEquals(sharedProps, ((LazyLikeBindings.Supplier) sharedPropsVmObject).get());
+ assertEquals(sharedProps, sharedPropsVmObject.get());
// confirm that the bindings is storing a marked Supplier, rather than a ValueMap
- Object globalPropsVmObject = lazyBindings.get(SharedComponentProperties.GLOBAL_PROPERTIES);
- assertTrue(globalPropsVmObject instanceof LazyLikeBindings.Supplier);
+ LazyBindings.Supplier globalPropsVmObject = suppliers.get(SharedComponentProperties.GLOBAL_PROPERTIES);
+ assertNotNull(globalPropsVmObject);
// compare that the value returned by the supplier with the expected ValueMap
- assertEquals(globalProps, ((LazyLikeBindings.Supplier) globalPropsVmObject).get());
+ assertEquals(globalProps, globalPropsVmObject.get());
// confirm that the bindings is storing a marked Supplier, rather than a resource. Acquire this Supplier BEFORE
// resetting the Global and Shared properties bindings to demonstrate that the same bindings instance
// is also accessed lazily by the Merged props supplier.
- Object mergedPropsVmObject = lazyBindings.get(SharedComponentProperties.MERGED_PROPERTIES);
- assertTrue(mergedPropsVmObject instanceof LazyLikeBindings.Supplier);
-
- // reset the Global and Shared properties bindings to contain the supplied values that will be consumed by
- // the Merged properties supplier binding.
- lazyBindings.put(SharedComponentProperties.GLOBAL_PROPERTIES, globalProps);
- lazyBindings.put(SharedComponentProperties.SHARED_PROPERTIES, sharedProps);
- // NOW call the merged properties supplier function.
- ValueMap mergedProps = (ValueMap) ((LazyLikeBindings.Supplier) mergedPropsVmObject).get();
-
- // compare the contents of the ValueMap returned by the supplier with the expected key/values from the separate maps
- assertEquals("value", mergedProps.get("global", String.class));
- assertEquals("value", mergedProps.get("shared", String.class));
- assertEquals("value", mergedProps.get("local", String.class));
- }
-
- @Test
- public void addToLazyBindings_NonConformant() {
- final SharedComponentPropertiesImpl sharedComponentProperties = new SharedComponentPropertiesImpl();
- sharedComponentProperties.pageRootProvider = pageRootProvider;
-
- final SharedComponentPropertiesBindingsValuesProvider sharedComponentPropertiesBindingsValuesProvider
- = new SharedComponentPropertiesBindingsValuesProvider();
-
-
- sharedComponentPropertiesBindingsValuesProvider.sharedComponentProperties = sharedComponentProperties;
- sharedComponentPropertiesBindingsValuesProvider.activate();
- sharedComponentPropertiesBindingsValuesProvider.checkAndSetLazyBindingsType(SimpleBindings.class);
-
- // test that the wrapSupplier() method returns the value from the supplier, rather than a supplier itself
- assertEquals("immediate", sharedComponentPropertiesBindingsValuesProvider
- .wrapSupplier(() -> "immediate").toString());
-
- SimpleBindings lazyBindings = new SimpleBindings();
- lazyBindings.putAll(bindings);
-
- sharedComponentPropertiesBindingsValuesProvider.addBindings(lazyBindings);
-
- // confirm that the non-conformant bindings is storing the resource
- Object sharedPropsObject = lazyBindings.get(SharedComponentProperties.SHARED_PROPERTIES_RESOURCE);
- // compare that the value returned by the supplier with the expected resource
- assertEquals(sharedPropsResource, sharedPropsObject);
-
- // confirm that the non-conformant bindings is storing the resource
- Object globalPropsObject = lazyBindings.get(SharedComponentProperties.GLOBAL_PROPERTIES_RESOURCE);
- // compare that the value returned by the supplier with the expected resource
- assertEquals(globalPropsResource, globalPropsObject);
-
- // confirm that the non-conformant bindings is storing the ValueMap
- Object sharedPropsVmObject = lazyBindings.get(SharedComponentProperties.SHARED_PROPERTIES);
+ LazyBindings.Supplier mergedPropsVmObject = suppliers.get(SharedComponentProperties.MERGED_PROPERTIES);
+ assertNotNull(mergedPropsVmObject);
// compare that the value returned by the supplier with the expected ValueMap
- assertEquals(sharedProps, sharedPropsVmObject);
-
- // confirm that the non-conformant bindings is storing the ValueMap
- Object globalPropsVmObject = lazyBindings.get(SharedComponentProperties.GLOBAL_PROPERTIES);
- // compare that the value returned by the supplier with the expected ValueMap
- assertEquals(globalProps, globalPropsVmObject);
-
- // confirm that the bindings is storing a marked Supplier, rather than a resource. Acquire this Supplier BEFORE
- // resetting the Global and Shared properties bindings to demonstrate that the same bindings instance
- // is also accessed lazily by the Merged props supplier.
- Object mergedPropsVmObject = lazyBindings.get(SharedComponentProperties.MERGED_PROPERTIES);
- ValueMap mergedProps = (ValueMap) mergedPropsVmObject;
+ ValueMap mergedProps = (ValueMap) mergedPropsVmObject.get();
// compare the contents of the ValueMap returned by the supplier with the expected key/values from the separate maps
assertEquals("value", mergedProps.get("global", String.class));
assertEquals("value", mergedProps.get("shared", String.class));
assertEquals("value", mergedProps.get("local", String.class));
}
-
- @Test
- public void addToLazyBindings_SlingApiJar() throws Exception {
- try (final URLClassLoader slingApiClassLoader = new URLClassLoader(
- new URL[]{getClass().getClassLoader().getResource(REL_PATH_SLING_API_2_22_0)},
- getClass().getClassLoader())) {
-
- final SharedComponentPropertiesImpl sharedComponentProperties = new SharedComponentPropertiesImpl();
- sharedComponentProperties.pageRootProvider = pageRootProvider;
-
- final SharedComponentPropertiesBindingsValuesProvider sharedComponentPropertiesBindingsValuesProvider
- = new SharedComponentPropertiesBindingsValuesProvider();
- // swap classloader
- sharedComponentPropertiesBindingsValuesProvider.swapLazyBindingsClassLoaderForTesting(slingApiClassLoader);
- sharedComponentPropertiesBindingsValuesProvider.sharedComponentProperties = sharedComponentProperties;
- // activate service to load classes
- sharedComponentPropertiesBindingsValuesProvider.activate();
-
- // test that the wrapSupplier() method returns the proxy supplier, rather than the supplied value
- assertEquals(SharedComponentPropertiesBindingsValuesProvider.SUPPLIER_PROXY_LABEL,
- sharedComponentPropertiesBindingsValuesProvider.wrapSupplier(() -> "immediate").toString());
-
- // inject our own suppliers map for a side-channel to the suppliers
- final Map suppliers = new HashMap<>();
- Bindings lazyBindings = sharedComponentPropertiesBindingsValuesProvider
- .getLazyBindingsType().getConstructor(Map.class).newInstance(suppliers);
- lazyBindings.putAll(bindings);
- final Class extends Supplier> supplierType = sharedComponentPropertiesBindingsValuesProvider.getSupplierType();
-
- sharedComponentPropertiesBindingsValuesProvider.addBindings(lazyBindings);
-
- // confirm that the bindings is storing a marked Supplier, rather than a resource
- Object sharedPropsObject = suppliers.get(SharedComponentProperties.SHARED_PROPERTIES_RESOURCE);
- assertTrue(supplierType.isInstance(sharedPropsObject));
- // compare that the value returned by the supplier with the expected resource
- assertEquals(sharedPropsResource, ((Supplier>) sharedPropsObject).get());
-
- // confirm that the bindings is storing a marked Supplier, rather than a resource
- Object globalPropsObject = suppliers.get(SharedComponentProperties.GLOBAL_PROPERTIES_RESOURCE);
- assertTrue(supplierType.isInstance(globalPropsObject));
- // compare that the value returned by the supplier with the expected resource
- assertEquals(globalPropsResource, ((Supplier>) globalPropsObject).get());
-
- // confirm that the bindings is storing a marked Supplier, rather than a ValueMap
- Object sharedPropsVmObject = suppliers.get(SharedComponentProperties.SHARED_PROPERTIES);
- assertTrue(supplierType.isInstance(sharedPropsVmObject));
- // compare that the value returned by the supplier with the expected ValueMap
- assertEquals(sharedProps, ((Supplier>) sharedPropsVmObject).get());
-
- // confirm that the bindings is storing a marked Supplier, rather than a ValueMap
- Object globalPropsVmObject = suppliers.get(SharedComponentProperties.GLOBAL_PROPERTIES);
- assertTrue(supplierType.isInstance(globalPropsVmObject));
- // compare that the value returned by the supplier with the expected ValueMap
- assertEquals(globalProps, ((Supplier>) globalPropsVmObject).get());
-
- // confirm that the bindings is storing a marked Supplier, rather than a resource. Acquire this Supplier BEFORE
- // resetting the Global and Shared properties bindings to demonstrate that the same bindings instance
- // is also accessed lazily by the Merged props supplier.
- Object mergedPropsVmObject = suppliers.get(SharedComponentProperties.MERGED_PROPERTIES);
- assertTrue(supplierType.isInstance(mergedPropsVmObject));
- // compare that the value returned by the supplier with the expected ValueMap
- ValueMap mergedProps = (ValueMap) ((Supplier>) mergedPropsVmObject).get();
-
- // compare the contents of the ValueMap returned by the supplier with the expected key/values from the separate maps
- assertEquals("value", mergedProps.get("global", String.class));
- assertEquals("value", mergedProps.get("shared", String.class));
- assertEquals("value", mergedProps.get("local", String.class));
- }
- }
}
diff --git a/bundle/src/test/java/com/adobe/acs/commons/workflow/impl/WorkflowPackageManagerImplTest.java b/bundle/src/test/java/com/adobe/acs/commons/workflow/impl/WorkflowPackageManagerImplTest.java
index a64589da35..e79d567659 100644
--- a/bundle/src/test/java/com/adobe/acs/commons/workflow/impl/WorkflowPackageManagerImplTest.java
+++ b/bundle/src/test/java/com/adobe/acs/commons/workflow/impl/WorkflowPackageManagerImplTest.java
@@ -31,7 +31,9 @@
import static org.mockito.Mockito.when;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import java.util.stream.Stream;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
@@ -189,6 +191,11 @@ public List list(final String[] strings) throws RepositoryException {
return nodes;
}
+ @Override
+ public boolean hasNode(String path) {
+ return Arrays.asList(paths).contains(path);
+ }
+
@Override
public void add(final Node node) {
diff --git a/oakpal-checks/pom.xml b/oakpal-checks/pom.xml
index 02a4829d3d..36ac9482d1 100644
--- a/oakpal-checks/pom.xml
+++ b/oakpal-checks/pom.xml
@@ -131,6 +131,7 @@
+ com.google.guava:*
org.osgi:osgi.core
@@ -293,6 +294,30 @@
osgi.core
compile
+
+ com.google.guava
+ guava
+ 31.1-jre
+ compile
+
+
+ com.google.j2objc
+ j2objc-annotations
+
+
+ com.google.code.findbugs
+ jsr305
+
+
+ com.google.errorprone
+ error_prone_annotations
+
+
+ org.checkerframework
+ checker-qual
+
+
+
diff --git a/pom.xml b/pom.xml
index f4765bc109..410b6c23c0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -465,7 +465,7 @@ Bundle-DocURL: https://adobe-consulting-services.github.io/acs-aem-commons/
io.wcm.maven
io.wcm.maven.aem-dependencies
- 6.4.0.0004
+ 6.5.7.0002
pom
import
diff --git a/ui.apps/pom.xml b/ui.apps/pom.xml
index 410ab8d28e..00ad19675d 100644
--- a/ui.apps/pom.xml
+++ b/ui.apps/pom.xml
@@ -202,7 +202,7 @@
com.adobe.aem
uber-jar
- apis
+ apis-with-deprecations
provided
diff --git a/ui.content/pom.xml b/ui.content/pom.xml
index f426eeb450..d456af0fe9 100644
--- a/ui.content/pom.xml
+++ b/ui.content/pom.xml
@@ -172,7 +172,7 @@
com.adobe.aem
uber-jar
- apis
+ apis-with-deprecations
provided