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 39a370b  SLING-8131 fix dynamic ref regression
39a370b is described below

commit 39a370b1f69205e47805ac79284ed24a22fef123
Author: Nicolas Peltier <[email protected]>
AuthorDate: Fri Nov 23 16:31:12 2018 +0100

    SLING-8131 fix dynamic ref regression
    
    added unit test to prevent this from happening again
---
 .../org/apache/sling/pipes/internal/ReferencePipe.java   |  1 +
 .../apache/sling/pipes/internal/ReferencePipeTest.java   | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/src/main/java/org/apache/sling/pipes/internal/ReferencePipe.java 
b/src/main/java/org/apache/sling/pipes/internal/ReferencePipe.java
index 0c34395..1680c7d 100644
--- a/src/main/java/org/apache/sling/pipes/internal/ReferencePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/ReferencePipe.java
@@ -69,6 +69,7 @@ public class ReferencePipe extends SuperPipe {
 
     @Override
     protected Iterator<Resource> computeSubpipesOutput() throws Exception {
+        buildChildren();
         log.debug("getting {} output", reference);
         return reference.getOutput();
     }
diff --git 
a/src/test/java/org/apache/sling/pipes/internal/ReferencePipeTest.java 
b/src/test/java/org/apache/sling/pipes/internal/ReferencePipeTest.java
index bf6961b..d1a6eba 100644
--- a/src/test/java/org/apache/sling/pipes/internal/ReferencePipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/internal/ReferencePipeTest.java
@@ -18,6 +18,7 @@ package org.apache.sling.pipes.internal;
 
 import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.pipes.AbstractPipeTest;
+import org.apache.sling.pipes.ExecutionResult;
 import org.apache.sling.pipes.Pipe;
 import org.junit.Before;
 import org.junit.Test;
@@ -26,6 +27,7 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
@@ -72,4 +74,18 @@ public class ReferencePipeTest  extends AbstractPipeTest {
                 .run(bindings).getCurrentPathSet();
         assertTrue("paths should contain new path", paths.contains(newPath));
     }
+
+    @Test
+    public void testDynamicBinding() throws Exception {
+        plumber.newPipe(context.resourceResolver()).echo(PATH_FRUITS + 
"/apple").build(PATH_PIPE + "/applePipe");
+        plumber.newPipe(context.resourceResolver()).echo(PATH_FRUITS + 
"/banana").build(PATH_PIPE + "/bananaPipe");
+
+        ExecutionResult result = plumber.newPipe(context.resourceResolver())
+                .json("['apple','banana']").name("fruit")
+                .ref(PATH_PIPE + "/${fruit}Pipe")
+                .run();
+        assertEquals("there should be two outputs", 2, result.size());
+        assertTrue("apple should be returned", 
result.getCurrentPathSet().contains(PATH_FRUITS + "/apple"));
+        assertTrue("banana should be returned", 
result.getCurrentPathSet().contains(PATH_FRUITS + "/banana"));
+    }
 }
\ No newline at end of file

Reply via email to