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

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


The following commit(s) were added to refs/heads/master by this push:
     new c580d14  SLING-9977 CAConfig in bindings
c580d14 is described below

commit c580d14cd8928aa28d4f3dc0176c86506a9d17de
Author: Nicolas Peltier <[email protected]>
AuthorDate: Mon Dec 7 16:57:01 2020 +0100

    SLING-9977 CAConfig in bindings
---
 pom.xml                                            |  26 +++-
 src/main/java/org/apache/sling/pipes/BasePipe.java |  12 +-
 .../java/org/apache/sling/pipes/PipeBindings.java  |  19 ++-
 src/main/java/org/apache/sling/pipes/Plumber.java  |   9 +-
 .../apache/sling/pipes/internal/PlumberImpl.java   |  31 +++--
 .../internal/{ => bindings}/BindingProvider.java   |   2 +-
 .../pipes/internal/bindings/ConfigurationMap.java  | 137 +++++++++++++++++++++
 .../pipes/internal/{ => bindings}/JxltEngine.java  |   2 +-
 .../java/org/apache/sling/pipes/package-info.java  |   2 +-
 .../org/apache/sling/pipes/AbstractPipeTest.java   |   6 +-
 .../java/org/apache/sling/pipes/BasePipeTest.java  |   3 +-
 .../org/apache/sling/pipes/PipeBindingsTest.java   |  14 ++-
 .../org/apache/sling/pipes/TestConfiguration.java} |   8 +-
 .../internal/{ => bindings}/JxltEngineTest.java    |   2 +-
 .../apache/sling/pipes/it/PipesTestSupport.java    |   2 +
 ...org.apache.sling.pipes.internal.PlumberImpl.xml |   1 +
 .../resources/initial-content/content/fruits.json  |   1 +
 17 files changed, 244 insertions(+), 33 deletions(-)

diff --git a/pom.xml b/pom.xml
index 87013d8..7d8c88a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
   </parent>
 
   <artifactId>org.apache.sling.pipes</artifactId>
-  <version>4.0.1-SNAPSHOT</version>
+  <version>4.1.0-SNAPSHOT</version>
 
   <name>Apache Sling Pipes</name>
   <description>bulk content changes tool</description>
@@ -268,6 +268,18 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
+      <artifactId>org.apache.sling.caconfig.api</artifactId>
+      <version>1.1.0</version>
+      <groupId>org.apache.sling</groupId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <artifactId>org.apache.sling.caconfig.impl</artifactId>
+      <version>1.4.10</version>
+      <groupId>org.apache.sling</groupId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
       <groupId>org.jetbrains</groupId>
       <artifactId>annotations</artifactId>
       <scope>provided</scope>
@@ -392,5 +404,17 @@
       <version>2.27.2</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
+      <scope>test</scope>
+      <version>1.3.0</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.commons</groupId>
+          <artifactId>commons-lang3</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
   </dependencies>
 </project>
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/pipes/BasePipe.java 
b/src/main/java/org/apache/sling/pipes/BasePipe.java
index 1cda564..05a616c 100644
--- a/src/main/java/org/apache/sling/pipes/BasePipe.java
+++ b/src/main/java/org/apache/sling/pipes/BasePipe.java
@@ -20,7 +20,7 @@ import org.apache.commons.lang3.StringUtils;
 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.pipes.internal.BindingProvider;
+import org.apache.sling.pipes.internal.bindings.BindingProvider;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.slf4j.Logger;
@@ -78,6 +78,10 @@ public class BasePipe implements Pipe {
 
     Boolean dryRunObject = null;
 
+    protected Plumber plumber;
+
+    private String name;
+
     @Override
     public SuperPipe getParent() {
         return parent;
@@ -93,10 +97,6 @@ public class BasePipe implements Pipe {
         return resource;
     }
 
-    protected Plumber plumber;
-
-    private String name;
-
     /**
      * Pipe Constructor
      * @param plumber plumber
@@ -139,7 +139,7 @@ public class BasePipe implements Pipe {
      * @param upperBindings
      */
     private void extractAdditionalBindings(@NotNull Resource resource, 
@Nullable PipeBindings upperBindings) {
-        bindings = upperBindings == null ? new PipeBindings(resource) : 
upperBindings;
+        bindings = upperBindings == null ? new PipeBindings(plumber, resource) 
: upperBindings;
         //additional bindings (global variables to use in child pipes 
expressions)
         Resource additionalBindings = resource.getChild(NN_ADDITIONALBINDINGS);
         if (additionalBindings != null) {
diff --git a/src/main/java/org/apache/sling/pipes/PipeBindings.java 
b/src/main/java/org/apache/sling/pipes/PipeBindings.java
index f0e667f..03a171c 100644
--- a/src/main/java/org/apache/sling/pipes/PipeBindings.java
+++ b/src/main/java/org/apache/sling/pipes/PipeBindings.java
@@ -20,7 +20,7 @@ import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.pipes.internal.JxltEngine;
+import org.apache.sling.pipes.internal.bindings.JxltEngine;
 import org.jetbrains.annotations.NotNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -61,6 +61,8 @@ public class PipeBindings {
      */
     public static final String PATH_BINDING = "path";
 
+    public static final String CACONFIG_BINDING = "caconfig";
+
     /**
      * add ${name.pipeName} binding allowing to retrieve pipeName's current 
resource name
      */
@@ -79,10 +81,19 @@ public class PipeBindings {
 
     Map<String, String> nameBindings = new HashMap<>();
 
+    Map<String, Map> caconfigBindings = new HashMap<>();
+
     Map<String, Resource> outputResources = new HashMap<>();
 
     String currentError;
 
+    Plumber plumber;
+
+    public PipeBindings(@NotNull Plumber plumber, @NotNull Resource resource) {
+        this(resource);
+        this.plumber = plumber;
+    }
+
     /**
      * public constructor, built from pipe's resource
      * @param resource pipe's configuration resource
@@ -99,6 +110,9 @@ public class PipeBindings {
 
         //add name bindings where name.MyPipe will give MyPipe current 
resource name
         getBindings().put(NAME_BINDING, nameBindings);
+
+        //add caconfig bindings where caconfig.MyPipe will give MyPipe current 
ca configuration
+        getBindings().put(CACONFIG_BINDING, caconfigBindings);
     }
 
     /**
@@ -327,6 +341,9 @@ public class PipeBindings {
         if (resource != null) {
             pathBindings.put(name, resource.getPath());
             nameBindings.put(name, resource.getName());
+            if (plumber != null) {
+                caconfigBindings.put(name, 
plumber.getContextAwareConfigurationMap(resource));
+            }
         }
     }
 
diff --git a/src/main/java/org/apache/sling/pipes/Plumber.java 
b/src/main/java/org/apache/sling/pipes/Plumber.java
index 63ef638..ace9be3 100644
--- a/src/main/java/org/apache/sling/pipes/Plumber.java
+++ b/src/main/java/org/apache/sling/pipes/Plumber.java
@@ -40,7 +40,6 @@ public interface Plumber {
      */
     Pipe getPipe(Resource resource);
 
-
     /**
      * Instantiate a pipe from the given resource and returns it
      *
@@ -51,7 +50,6 @@ public interface Plumber {
      */
     Pipe getPipe(Resource resource, PipeBindings upperBindings);
 
-
     /**
      * executes in a background thread
      *
@@ -107,7 +105,6 @@ public interface Plumber {
      */
     void registerPipe(String type, Class<? extends BasePipe> pipeClass);
 
-
     /**
      * returns wether or not a pipe type is registered
      *
@@ -157,4 +154,10 @@ public interface Plumber {
      * @return service user that has been configured for executing pipes;
      */
     Map<String, Object> getServiceUser();
+
+    /**
+     * @param currentResource
+     * @return context aware configuration map
+     */
+    Map getContextAwareConfigurationMap(Resource currentResource);
 }
diff --git a/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java 
b/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
index a4f2d67..ed966e8 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
@@ -27,6 +27,7 @@ import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.caconfig.spi.ConfigurationMetadataProvider;
 import org.apache.sling.distribution.DistributionRequest;
 import org.apache.sling.distribution.DistributionRequestType;
 import org.apache.sling.distribution.DistributionResponse;
@@ -45,6 +46,7 @@ import org.apache.sling.pipes.PipeBuilder;
 import org.apache.sling.pipes.PipeExecutor;
 import org.apache.sling.pipes.Plumber;
 import org.apache.sling.pipes.PlumberMXBean;
+import org.apache.sling.pipes.internal.bindings.ConfigurationMap;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Deactivate;
@@ -124,6 +126,18 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
         String[] authorizedUsers() default  {"admin"};
     }
 
+    @Reference(policy= ReferencePolicy.DYNAMIC, cardinality= 
ReferenceCardinality.OPTIONAL)
+    volatile Distributor distributor = null;
+
+    @Reference
+    JobManager jobManager;
+
+    @Reference
+    ResourceResolverFactory factory;
+
+    @Reference
+    ConfigurationMetadataProvider configMetadataProvider;
+
     Map<String, Class<? extends BasePipe>> registry;
 
     public static final String SLING_EVENT_TOPIC = 
"org/apache/sling/pipes/topic";
@@ -175,6 +189,11 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
         return serviceUser;
     }
 
+    @Override
+    public Map getContextAwareConfigurationMap(Resource currentResource) {
+        return new ConfigurationMap(currentResource, configMetadataProvider);
+    }
+
     @Deactivate
     public void deactivate(){
         toggleJmxRegistration(null, PlumberMXBean.class.getName(), false);
@@ -205,15 +224,6 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
         }
     }
 
-    @Reference(policy= ReferencePolicy.DYNAMIC, cardinality= 
ReferenceCardinality.OPTIONAL)
-    volatile Distributor distributor = null;
-
-    @Reference
-    JobManager jobManager;
-
-    @Reference
-    ResourceResolverFactory factory;
-
     @Override
     public Pipe getPipe(Resource resource) {
         return getPipe(resource, null);
@@ -343,8 +353,7 @@ public class PlumberImpl implements Plumber, JobConsumer, 
PlumberMXBean {
             success = true;
             return result;
         } catch (PersistenceException e) {
-            log.error("error while executing pipe", e);
-            throw new IllegalStateException(e);
+            throw new IllegalStateException("persistence error while executing 
pipe", e);
         } catch (InterruptedException ie) {
             log.error("execution interrupted", ie);
             Thread.currentThread().interrupt();
diff --git a/src/main/java/org/apache/sling/pipes/internal/BindingProvider.java 
b/src/main/java/org/apache/sling/pipes/internal/bindings/BindingProvider.java
similarity index 96%
rename from src/main/java/org/apache/sling/pipes/internal/BindingProvider.java
rename to 
src/main/java/org/apache/sling/pipes/internal/bindings/BindingProvider.java
index 1ff9da0..5b05bd8 100644
--- a/src/main/java/org/apache/sling/pipes/internal/BindingProvider.java
+++ 
b/src/main/java/org/apache/sling/pipes/internal/bindings/BindingProvider.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.pipes.internal;
+package org.apache.sling.pipes.internal.bindings;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ValueMap;
diff --git 
a/src/main/java/org/apache/sling/pipes/internal/bindings/ConfigurationMap.java 
b/src/main/java/org/apache/sling/pipes/internal/bindings/ConfigurationMap.java
new file mode 100644
index 0000000..0cddf73
--- /dev/null
+++ 
b/src/main/java/org/apache/sling/pipes/internal/bindings/ConfigurationMap.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.pipes.internal.bindings;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.caconfig.ConfigurationBuilder;
+import org.apache.sling.caconfig.spi.ConfigurationMetadataProvider;
+import org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This is a "virtual" containing configuration names as keys, and the 
underlying value maps/value map collections as values.
+ * The map accesses only the data that is really required in a lazy fashion.
+ */
+public class ConfigurationMap implements Map<String, Object> {
+
+    private final Resource resource;
+    private final ConfigurationMetadataProvider configMetadataProvider;
+    private Set<String> configNamesCache;
+    private Map<String, Object> valuesCache = new HashMap<>();
+
+    public ConfigurationMap(Resource resource, ConfigurationMetadataProvider 
provider) {
+        this.resource = resource;
+        this.configMetadataProvider = provider;
+    }
+
+    private Set<String> getConfigNames() {
+        if (configNamesCache == null) {
+            configNamesCache = configMetadataProvider.getConfigurationNames();
+        }
+        return configNamesCache;
+    }
+
+    @Override
+    public int size() {
+        return getConfigNames().size();
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return getConfigNames().isEmpty();
+    }
+
+    @Override
+    public boolean containsKey(Object key) {
+        return getConfigNames().contains(key);
+    }
+
+    @Override
+    public Object get(Object key) {
+        Object value = valuesCache.get(key);
+        if (value == null) {
+            value = getConfigValue((String) key);
+            if (value != null) {
+                valuesCache.put((String) key, value);
+            }
+        }
+        return value;
+    }
+
+    private Object getConfigValue(String configName) {
+        @SuppressWarnings("null")
+        ConfigurationBuilder configBuilder = 
resource.adaptTo(ConfigurationBuilder.class).name(configName);
+        if (isCollection(configName)) {
+            return configBuilder.asValueMapCollection();
+        } else {
+            return configBuilder.asValueMap();
+        }
+    }
+
+    private boolean isCollection(String configName) {
+        ConfigurationMetadata configMetadata = 
configMetadataProvider.getConfigurationMetadata(configName);
+        if (configMetadata != null) {
+            return configMetadata.isCollection();
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public Set<String> keySet() {
+        return getConfigNames();
+    }
+
+    @Override
+    public boolean containsValue(Object value) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Object put(String key, Object value) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Object remove(Object key) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void putAll(Map<? extends String, ? extends Object> m) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void clear() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Collection<Object> values() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Set<java.util.Map.Entry<String, Object>> entrySet() {
+        throw new UnsupportedOperationException();
+    }
+}
diff --git a/src/main/java/org/apache/sling/pipes/internal/JxltEngine.java 
b/src/main/java/org/apache/sling/pipes/internal/bindings/JxltEngine.java
similarity index 96%
rename from src/main/java/org/apache/sling/pipes/internal/JxltEngine.java
rename to src/main/java/org/apache/sling/pipes/internal/bindings/JxltEngine.java
index a1c5c96..ff84801 100644
--- a/src/main/java/org/apache/sling/pipes/internal/JxltEngine.java
+++ b/src/main/java/org/apache/sling/pipes/internal/bindings/JxltEngine.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.pipes.internal;
+package org.apache.sling.pipes.internal.bindings;
 
 import java.util.Map;
 
diff --git a/src/main/java/org/apache/sling/pipes/package-info.java 
b/src/main/java/org/apache/sling/pipes/package-info.java
index 8b77a39..e892a88 100644
--- a/src/main/java/org/apache/sling/pipes/package-info.java
+++ b/src/main/java/org/apache/sling/pipes/package-info.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("4.0.1")
+@Version("4.1.0")
 package org.apache.sling.pipes;
 
 import org.osgi.annotation.versioning.Version;
diff --git a/src/test/java/org/apache/sling/pipes/AbstractPipeTest.java 
b/src/test/java/org/apache/sling/pipes/AbstractPipeTest.java
index 8eb8932..914f4f6 100644
--- a/src/test/java/org/apache/sling/pipes/AbstractPipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/AbstractPipeTest.java
@@ -19,6 +19,7 @@ package org.apache.sling.pipes;
 import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.caconfig.spi.ConfigurationMetadataProvider;
 import org.apache.sling.event.jobs.JobManager;
 
 import org.apache.sling.pipes.dummies.DummyNull;
@@ -27,12 +28,14 @@ import org.apache.sling.pipes.internal.CommandExecutorImpl;
 import org.apache.sling.pipes.internal.PlumberImpl;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import org.apache.sling.testing.mock.sling.junit.SlingContext;
+import org.apache.sling.testing.mock.sling.junit.SlingContextBuilder;
 import org.junit.Before;
 import org.junit.Rule;
 
 import java.lang.reflect.InvocationTargetException;
 import java.util.Iterator;
 
+import static org.apache.sling.testing.mock.caconfig.ContextPlugins.CACONFIG;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -65,12 +68,13 @@ public class AbstractPipeTest {
     protected CommandExecutor commandsExecutor;
 
     @Rule
-    public SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);
+    public SlingContext context = new 
SlingContextBuilder(ResourceResolverType.JCR_MOCK).plugin(CACONFIG).build();
 
     @Before
     public void setup() throws PersistenceException {
         context.load().json("/initial-content/content/fruits.json", 
PATH_FRUITS);
         plumber = new PlumberImpl();
+        context.registerService(mock(ConfigurationMetadataProvider.class));
         context.registerService(mock(JobManager.class));
         context.registerInjectActivateService(plumber, "authorizedUsers", new 
String[]{},
                 "bufferSize", PlumberImpl.DEFAULT_BUFFER_SIZE,
diff --git a/src/test/java/org/apache/sling/pipes/BasePipeTest.java 
b/src/test/java/org/apache/sling/pipes/BasePipeTest.java
index 9921644..833813a 100644
--- a/src/test/java/org/apache/sling/pipes/BasePipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/BasePipeTest.java
@@ -17,10 +17,9 @@
 package org.apache.sling.pipes;
 
 import org.apache.sling.api.resource.PersistenceException;
-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.pipes.internal.BindingProvider;
+import org.apache.sling.pipes.internal.bindings.BindingProvider;
 import org.junit.Test;
 
 import javax.json.Json;
diff --git a/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java 
b/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java
index fcca73b..5b18e2c 100644
--- a/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java
+++ b/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java
@@ -18,18 +18,19 @@ package org.apache.sling.pipes;
 
 import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.testing.mock.caconfig.MockContextAwareConfig;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
-import java.util.Calendar;
+import java.lang.reflect.InvocationTargetException;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 /**
  * testing binding's expressions instanciations
@@ -136,4 +137,13 @@ public class PipeBindingsTest extends AbstractPipeTest {
         output.next();
         assertEquals("second name binding should be banana", 
bindings.instantiateExpression("${name.dummyParent}"), "banana");
     }
+
+    @Test
+    public void testCaConfigBinding() throws InvocationTargetException, 
IllegalAccessException {
+        context.build().resource("/conf/foo/sling:configs/" + 
TestConfiguration.class.getName(), "fruit", "apple");
+        MockContextAwareConfig.registerAnnotationClasses(context, 
TestConfiguration.class);
+        ExecutionResult result = execute("echo /content/fruits | echo 
${caconfig.one['org.apache.sling.pipes.TestConfiguration'].fruit}");
+        assertTrue(result.size() > 0);
+        assertEquals("/content/fruits/apple", 
result.currentPathSet.iterator().next());
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/pipes/package-info.java 
b/src/test/java/org/apache/sling/pipes/TestConfiguration.java
similarity index 79%
copy from src/main/java/org/apache/sling/pipes/package-info.java
copy to src/test/java/org/apache/sling/pipes/TestConfiguration.java
index 8b77a39..194f24e 100644
--- a/src/main/java/org/apache/sling/pipes/package-info.java
+++ b/src/test/java/org/apache/sling/pipes/TestConfiguration.java
@@ -14,7 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("4.0.1")
 package org.apache.sling.pipes;
 
-import org.osgi.annotation.versioning.Version;
+import org.apache.sling.caconfig.annotation.Configuration;
+
+@Configuration(label="Test Configuration", description = "used for testing 
CAConfig in pipes")
+public @interface TestConfiguration {
+    String fruit();
+}
diff --git a/src/test/java/org/apache/sling/pipes/internal/JxltEngineTest.java 
b/src/test/java/org/apache/sling/pipes/internal/bindings/JxltEngineTest.java
similarity index 97%
rename from src/test/java/org/apache/sling/pipes/internal/JxltEngineTest.java
rename to 
src/test/java/org/apache/sling/pipes/internal/bindings/JxltEngineTest.java
index 0fb8b0a..bfed905 100644
--- a/src/test/java/org/apache/sling/pipes/internal/JxltEngineTest.java
+++ b/src/test/java/org/apache/sling/pipes/internal/bindings/JxltEngineTest.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.pipes.internal;
+package org.apache.sling.pipes.internal.bindings;
 
 
 import static org.junit.Assert.assertEquals;
diff --git a/src/test/java/org/apache/sling/pipes/it/PipesTestSupport.java 
b/src/test/java/org/apache/sling/pipes/it/PipesTestSupport.java
index b668f47..5ea3335 100644
--- a/src/test/java/org/apache/sling/pipes/it/PipesTestSupport.java
+++ b/src/test/java/org/apache/sling/pipes/it/PipesTestSupport.java
@@ -35,6 +35,7 @@ import org.ops4j.pax.exam.ProbeBuilder;
 import org.ops4j.pax.exam.TestProbeBuilder;
 import org.ops4j.pax.exam.util.Filter;
 
+import static org.apache.sling.testing.paxexam.SlingOptions.slingCaconfig;
 import static org.apache.sling.testing.paxexam.SlingOptions.slingCommonsHtml;
 import static org.apache.sling.testing.paxexam.SlingOptions.slingDistribution;
 import static org.apache.sling.testing.paxexam.SlingOptions.slingEvent;
@@ -84,6 +85,7 @@ public abstract class PipesTestSupport extends TestSupport {
             
mavenBundle().groupId("org.apache.geronimo.bundles").artifactId("commons-httpclient").version(versionResolver),
             // testing
             slingResourcePresence(),
+            slingCaconfig(),
             
newConfiguration("org.apache.sling.jcr.base.internal.LoginAdminWhitelist")
                 .put("whitelist.bundles.regexp", "^PAXEXAM.*$")
                 .asOption(),
diff --git 
a/src/test/resources/OSGI-INF/org.apache.sling.pipes.internal.PlumberImpl.xml 
b/src/test/resources/OSGI-INF/org.apache.sling.pipes.internal.PlumberImpl.xml
index 47bd3c9..3500cc7 100644
--- 
a/src/test/resources/OSGI-INF/org.apache.sling.pipes.internal.PlumberImpl.xml
+++ 
b/src/test/resources/OSGI-INF/org.apache.sling.pipes.internal.PlumberImpl.xml
@@ -6,4 +6,5 @@
     </service>
     <reference name="factory" 
interface="org.apache.sling.api.resource.ResourceResolverFactory" 
field="factory"/>
     <reference interface="org.apache.sling.event.jobs.JobManager" 
name="jobManager" field="jobManager"/>
+    <reference 
interface="org.apache.sling.caconfig.spi.ConfigurationMetadataProvider" 
name="configMetadataProvider" field="configMetadataProvider"/>
 </scr:component>
diff --git a/src/test/resources/initial-content/content/fruits.json 
b/src/test/resources/initial-content/content/fruits.json
index 1c1a96c..b110f96 100644
--- a/src/test/resources/initial-content/content/fruits.json
+++ b/src/test/resources/initial-content/content/fruits.json
@@ -1,6 +1,7 @@
 {
   "jcr:primaryType":"nt:unstructured",
   "index":["apple","banana"],
+  "sling:configRef": "/conf/foo",
   "apple":{
     "jcr:primaryType":"nt:unstructured",
     "sling:resourceType":"/apps/pipes-it/fruit",

Reply via email to