You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2015/12/07 15:19:52 UTC
svn commit: r1718377 [3/3] - in /sling/trunk/contrib/extensions/sling-pipes:
./ src/ src/main/ src/main/java/ src/main/java/org/
src/main/java/org/apache/ src/main/java/org/apache/sling/
src/main/java/org/apache/sling/pipes/ src/main/java/org/apache/sl...
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/RemovePipeTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/RemovePipeTest.java?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/RemovePipeTest.java (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/RemovePipeTest.java Mon Dec 7 14:19:52 2015
@@ -0,0 +1,85 @@
+/*
+ * 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;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ValueMap;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.jcr.Node;
+import java.util.Iterator;
+
+import static org.junit.Assert.*;
+
+/**
+ * testing removal
+ */
+public class RemovePipeTest extends AbstractPipeTest{
+
+ @Before
+ public void setUp() throws Exception {
+ context.load().json("/remove.json", PATH_PIPE);
+ }
+
+ @Test
+ public void testRemoveNode() throws Exception{
+ ResourceResolver resolver = context.resourceResolver();
+ Resource resource = resolver.getResource(PATH_PIPE + "/" + NN_SIMPLE);
+ resource.adaptTo(Node.class).setProperty(Pipe.PN_PATH, PATH_BANANA);
+ resolver.commit();
+ Pipe pipe = plumber.getPipe(resource);
+ Iterator<Resource> outputs = pipe.getOutput();
+ outputs.next();
+ resolver.commit();
+ resolver.refresh();
+ assertNotNull("Apple should still be here", resolver.getResource(PATH_APPLE));
+ assertNull("Banana should not", resolver.getResource(PATH_BANANA));
+ }
+
+ @Test
+ public void testRemoveProperty() throws Exception {
+ String indexPath = PATH_FRUITS + "/index";
+ ResourceResolver resolver = context.resourceResolver();
+ Resource resource = resolver.getResource(PATH_PIPE + "/" + NN_SIMPLE);
+ resource.adaptTo(Node.class).setProperty(Pipe.PN_PATH, indexPath);
+ resolver.commit();
+ Pipe pipe = plumber.getPipe(resource);
+ Iterator<Resource> outputs = pipe.getOutput();
+ outputs.next();
+ resolver.commit();
+ resolver.refresh();
+ assertNull("Index property should not be here", resolver.getResource(indexPath));
+ assertNotNull("Apple should still be here", resolver.getResource(PATH_APPLE));
+ assertNotNull("Banana should still be here", resolver.getResource(PATH_BANANA));
+ }
+
+ @Test
+ public void testComplexRemove() throws Exception {
+ ResourceResolver resolver = context.resourceResolver();
+ Resource resource = resolver.getResource(PATH_PIPE + "/" + NN_COMPLEX);
+ Pipe pipe = plumber.getPipe(resource);
+ assertTrue("resource should be solved", pipe.getOutput().hasNext());
+ pipe.getOutput().next();
+ resolver.commit();
+ assertNull("isnota carrot should be removed", resolver.getResource(PATH_APPLE + "/isnota/carrot"));
+ Resource isNotAPea = resolver.getResource(PATH_APPLE + "/isnota/pea");
+ assertNotNull("isnota pea should not be removed", isNotAPea);
+ assertFalse("isnota pea color property should not be here", isNotAPea.adaptTo(ValueMap.class).containsKey("color"));
+ }
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/SlingQueryPipeTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/SlingQueryPipeTest.java?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/SlingQueryPipeTest.java (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/SlingQueryPipeTest.java Mon Dec 7 14:19:52 2015
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+import org.apache.sling.api.resource.Resource;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Iterator;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * test the sling query pipe
+ */
+public class SlingQueryPipeTest extends AbstractPipeTest {
+
+ @Before
+ public void setup() {
+ super.setup();
+ context.load().json("/users.json", "/content/users");
+ context.load().json("/slingQuery.json", PATH_PIPE);
+ }
+
+ @Test
+ public void testChildren() throws Exception {
+ Resource resource = context.resourceResolver().getResource(PATH_PIPE + "/" + NN_SIMPLE);
+ SlingQueryPipe pipe = (SlingQueryPipe)plumber.getPipe(resource);
+ assertNotNull("A Sling query pipe should be built out from the given configuration", pipe);
+ Iterator<Resource> it = pipe.getOutput();
+ assertTrue("this pipe should have an output", it.hasNext());
+ }
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/WritePipeTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/WritePipeTest.java?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/WritePipeTest.java (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/WritePipeTest.java Mon Dec 7 14:19:52 2015
@@ -0,0 +1,119 @@
+/*
+ * 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;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ValueMap;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import java.util.Iterator;
+
+import static org.junit.Assert.*;
+
+/**
+ * test write
+ */
+public class WritePipeTest extends AbstractPipeTest {
+
+ public static final String NN_PIPED = "piped";
+ public static final String NN_VARIABLE_PIPED = "variablePipe";
+ public static final String NN_SIMPLETREE = "simpleTree";
+
+ @Before
+ public void setup() {
+ super.setup();
+ context.load().json("/write.json", PATH_PIPE);
+ }
+
+ @Test
+ public void testSimple() throws Exception {
+ Resource confResource = context.resourceResolver().getResource(PATH_PIPE + "/" + NN_SIMPLE);
+ Pipe pipe = plumber.getPipe(confResource);
+ assertNotNull("pipe should be found", pipe);
+ assertTrue("this pipe should be marked as content modifier", pipe.modifiesContent());
+ pipe.getOutput();
+ context.resourceResolver().commit();
+ ValueMap properties = context.resourceResolver().getResource("/content/fruits/apple").adaptTo(ValueMap.class);
+ assertTrue("There should be hasSeed set to true", properties.get("hasSeed", false));
+ assertArrayEquals("Colors should be correctly set", new String[]{"green", "red"}, properties.get("colors", String[].class));
+ }
+
+ /**
+ *
+ * @param resource
+ */
+ public static void assertPiped(Resource resource) {
+ ValueMap properties = resource.adaptTo(ValueMap.class);
+ assertArrayEquals("Second fruit should have been correctly instantiated & patched, added to the first", new String[]{"apple","banana"}, properties.get("fruits", String[].class));
+ assertArrayEquals("Fixed mv should be there", new String[]{"cabbage","carrot"}, properties.get("fixedVegetables", String[].class));
+ }
+
+ @Test
+ public void testPiped() throws Exception {
+ Resource confResource = context.resourceResolver().getResource(PATH_PIPE + "/" + NN_PIPED);
+ Pipe pipe = plumber.getPipe(confResource);
+ assertNotNull("pipe should be found", pipe);
+ assertTrue("this pipe should be marked as content modifier", pipe.modifiesContent());
+ Iterator<Resource> it = pipe.getOutput();
+ assertTrue("There should be one result", it.hasNext());
+ Resource resource = it.next();
+ assertNotNull("The result should not be null", resource);
+ assertEquals("The result should be the configured one in the piped write pipe", "/content/fruits", resource.getPath());
+ context.resourceResolver().commit();
+ ValueMap properties = resource.adaptTo(ValueMap.class);
+ assertArrayEquals("First fruit should have been correctly instantiated & patched from nothing", new String[]{"apple"}, properties.get("fruits", String[].class));
+ assertTrue("There should be a second result awaiting", it.hasNext());
+ resource = it.next();
+ assertNotNull("The second result should not be null", resource);
+ assertEquals("The second result should be the configured one in the piped write pipe", "/content/fruits", resource.getPath());
+ context.resourceResolver().commit();
+ assertPiped(resource);
+ }
+
+ @Test
+ public void testVariablePiped() throws Exception {
+ String pipePath = PATH_PIPE + "/" + NN_VARIABLE_PIPED;
+ Resource confResource = context.resourceResolver().getResource(pipePath);
+ Pipe pipe = plumber.getPipe(confResource);
+ assertNotNull("pipe should be found", pipe);
+ Iterator<Resource> it = pipe.getOutput();
+ Resource resource = it.next();
+ assertEquals("path should be the one configured in first pipe", pipePath + "/conf/fruit/conf/apple", resource.getPath());
+ context.resourceResolver().commit();
+ assertEquals("Configured value should be written", "apple is a fruit and its color is green", resource.adaptTo(ValueMap.class).get("jcr:description", ""));
+ }
+
+ @Test
+ public void testSimpleTree() throws Exception {
+ Resource confResource = context.resourceResolver().getResource(PATH_PIPE + "/" + NN_SIMPLETREE);
+ Pipe pipe = plumber.getPipe(confResource);
+ assertNotNull("pipe should be found", pipe);
+ assertTrue("this pipe should be marked as content modifier", pipe.modifiesContent());
+ pipe.getOutput();
+ context.resourceResolver().commit();
+ Resource appleResource = context.resourceResolver().getResource("/content/fruits/apple");
+ ValueMap properties = appleResource.adaptTo(ValueMap.class);
+ assertTrue("There should be hasSeed set to true", properties.get("hasSeed", false));
+ assertArrayEquals("Colors should be correctly set", new String[]{"green", "red"}, properties.get("colors", String[].class));
+ Node appleNode = appleResource.adaptTo(Node.class);
+ NodeIterator children = appleNode.getNodes();
+ assertTrue("Apple node should have children", children.hasNext());
+ }
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/dummies/DummyNull.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/dummies/DummyNull.java?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/dummies/DummyNull.java (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/dummies/DummyNull.java Mon Dec 7 14:19:52 2015
@@ -0,0 +1,43 @@
+/*
+ * 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.dummies;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.pipes.BasePipe;
+import org.apache.sling.pipes.Plumber;
+
+import java.util.Collections;
+import java.util.Iterator;
+
+/**
+ * this pipe has nothing in output
+ */
+public class DummyNull extends BasePipe {
+ public DummyNull(Plumber plumber, Resource resource) throws Exception {
+ super(plumber, resource);
+ }
+
+ @Override
+ public Object getOutputBinding() {
+ return null;
+ }
+
+ @Override
+ public Iterator<Resource> getOutput() {
+ return Collections.emptyIterator();
+ }
+}
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/dummies/DummySearch.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/dummies/DummySearch.java?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/dummies/DummySearch.java (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/java/org/apache/sling/pipes/dummies/DummySearch.java Mon Dec 7 14:19:52 2015
@@ -0,0 +1,73 @@
+/*
+ * 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.dummies;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.pipes.BasePipe;
+import org.apache.sling.pipes.Plumber;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import java.util.Collections;
+import java.util.Iterator;
+
+/**
+ * dummy search reads its conf node children and returns them.
+ */
+public class DummySearch extends BasePipe {
+
+ public DummySearch(Plumber plumber, Resource resource) throws Exception {
+ super(plumber, resource);
+ }
+
+ @Override
+ public boolean modifiesContent() {
+ return false;
+ }
+
+ @Override
+ public Iterator<Resource> getOutput() {
+ try {
+ final NodeIterator iterator = getConfiguration().adaptTo(Node.class).getNodes();
+ return new Iterator<Resource>() {
+
+ @Override
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+
+ @Override
+ public Resource next() {
+ try {
+ return resolver.getResource(iterator.nextNode().getPath());
+ } catch (Exception e) {
+
+ }
+ return null;
+ }
+
+ @Override
+ public void remove() {
+
+ }
+ };
+ } catch (Exception e){
+
+ }
+ return Collections.<Resource>emptyList().iterator();
+ }
+}
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/resources/container.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/resources/container.json?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/resources/container.json (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/resources/container.json Mon Dec 7 14:19:52 2015
@@ -0,0 +1,126 @@
+{
+ "jcr:primaryType":"nt:unstructured",
+ "dummyTree": {
+ "jcr:primaryType":"nt:unstructured",
+ "jcr:description":"2 parents, 2 kids, 1 grand kid: we expect exactly 4 outputs",
+ "sling:resourceType":"slingPipes/container",
+ "conf":{
+ "jcr:primaryType":"sling:OrderedFolder",
+ "dummyParent":{
+ "sling:resourceType":"slingPipes/dummySearch",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "apple":{"jcr:primaryType":"nt:unstructured","color":"green", "name":"apple"},
+ "banana":{"jcr:primaryType":"nt:unstructured", "color":"yellow", "name":"banana"}
+ }
+ },
+ "dummyChild":{
+ "sling:resourceType":"slingPipes/dummySearch",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "pea":{"jcr:primaryType":"nt:unstructured","color":"green", "name":"pea"},
+ "carrot":{"jcr:primaryType":"nt:unstructured", "color":"orange", "name":"carrot"}
+ }
+ },
+ "dummyGrandChild": {
+ "sling:resourceType":"slingPipes/base",
+ "path":"/content/fruits/${dummyParent.name}/isnota/${dummyChild.name}/${(dummyParent.color == dummyChild.color ? '/buttheyhavesamecolor' : '/andtheircolorisdifferent')}"
+ }
+ }
+ },
+ "otherTree": {
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType":"slingPipes/container",
+ "jcr:description":"2 parents, 1 kid, 1 grand kid: we expect exactly 2 outputs",
+ "conf":{
+ "jcr:primaryType":"sling:OrderedFolder",
+ "dummyParent":{
+ "sling:resourceType":"slingPipes/dummySearch",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "apple":{"jcr:primaryType":"nt:unstructured","color":"green", "name":"apple"},
+ "banana":{"jcr:primaryType":"nt:unstructured", "color":"yellow", "name":"banana"}
+ }
+ },
+ "dummyChild":{
+ "sling:resourceType":"slingPipes/dummySearch",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "pea":{"jcr:primaryType":"nt:unstructured","color":"green", "name":"pea"}
+ }
+ },
+ "dummyGrandChild": {
+ "sling:resourceType":"slingPipes/base",
+ "path":"/content/fruits/${dummyParent.name}/isnota/${dummyChild.name}/${(dummyParent.color == dummyChild.color ? '/buttheyhavesamecolor' : '/andtheircolorisdifferent')}"
+ }
+ }
+ },
+ "rottenTree": {
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType":"slingPipes/container",
+ "jcr:description":"2 parents, 1 null, 1 grand kid: we expect nothing, but no failure!",
+ "conf":{
+ "jcr:primaryType":"sling:OrderedFolder",
+ "dummyParent":{
+ "sling:resourceType":"slingPipes/dummySearch",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "apple":{"jcr:primaryType":"nt:unstructured","color":"green", "name":"apple"},
+ "banana":{"jcr:primaryType":"nt:unstructured", "color":"yellow", "name":"banana"}
+ }
+ },
+ "dummyNull":{
+ "sling:resourceType":"slingPipes/dummyNull"
+ },
+ "dummyGrandChild": {
+ "sling:resourceType":"slingPipes/base",
+ "path":"/content/fruits/${dummyParent.name}/isnota/${dummyChild.name }/${(dummyParent.color == dummyChild.color ? '/buttheyhavesamecolor' : '/andtheircolorisdifferent')}"
+ }
+ }
+ },
+ "moreBindings": {
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType":"slingPipes/container",
+ "jcr:description":"1 parent, additional bindings",
+ "conf":{
+ "jcr:primaryType":"sling:OrderedFolder",
+ "dummyParent":{
+ "sling:resourceType":"slingPipes/dummySearch",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "apple":{"jcr:primaryType":"nt:unstructured","color":"green", "name":"apple"},
+ "banana":{"jcr:primaryType":"nt:unstructured", "color":"yellow", "name":"banana"}
+ }
+ }
+ },
+ "additionalBindings": {
+ "jcr:primaryType": "sling:Folder",
+ "three": "3"
+ },
+ "additionalScripts": ["/content/test/testSum.js"]
+ },
+ "onePipeContainer": {
+ "jcr:primaryType": "nt:unstructured",
+ "jcr:description": "one pipe only",
+ "sling:resourceType": "slingPipes/container",
+ "conf": {
+ "jcr:primaryType": "sling:OrderedFolder",
+ "dummyParent": {
+ "sling:resourceType": "slingPipes/dummySearch",
+ "conf": {
+ "jcr:primaryType": "nt:unstructured",
+ "apple": {
+ "jcr:primaryType": "nt:unstructured",
+ "color": "green",
+ "name": "apple"
+ },
+ "banana": {
+ "jcr:primaryType": "nt:unstructured",
+ "color": "yellow",
+ "name": "banana"
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/resources/filter.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/resources/filter.json?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/resources/filter.json (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/resources/filter.json Mon Dec 7 14:19:52 2015
@@ -0,0 +1,79 @@
+{
+ "properties": {
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType":"slingPipes/container",
+ "conf":{
+ "jcr:primaryType":"sling:OrderedFolder",
+ "dummyParent":{
+ "jcr:primaryType":"sling:OrderedFolder",
+ "sling:resourceType":"slingPipes/dummySearch",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "apple":{"jcr:primaryType":"nt:unstructured","color":"green", "name":"apple"},
+ "banana":{"jcr:primaryType":"nt:unstructured", "color":"yellow", "name":"banana"},
+ "strangeFruit":{"jcr:primaryType":"nt:unstructured", "color":"yellow"}
+ }
+ },
+ "filter":{
+ "jcr:primaryType":"sling:OrderedFolder",
+ "sling:resourceType":"slingPipes/filter",
+ "jcr:description":"filters resource with green color, and non void name property",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "color":"green",
+ "name":".+"
+ }
+ }
+ }
+ },
+ "noChildrenPasses": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "slingPipes/filter",
+ "path":"/content/fruits/apple",
+ "jcr:description": "filters resource with given subtree having NO child",
+ "conf": {
+ "jcr:primaryType": "nt:unstructured",
+ "isnota": {
+ "jcr:primaryType": "nt:unstructured",
+ "pea": {
+ "jcr:primaryType": "nt:unstructured",
+ "color": "green",
+ "buttheyhavesamecolor": {
+ "jcr:primaryType": "nt:unstructured",
+ "slingPipesFilter_noChildren": "${true}"
+ }
+ }
+ }
+ }
+ },
+ "noChildrenVoid": {
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType":"slingPipes/filter",
+ "jcr:description":"filters resource that shouldn't have child",
+ "path":"/content/fruits/apple",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "slingPipesFilter_noChildren":"${true}"
+ }
+ },
+ "testPasses": {
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType":"slingPipes/filter",
+ "jcr:description":"filters resource that should have child",
+ "path":"/content/fruits/apple",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "slingPipesFilter_test":"${true}"
+ }
+ },
+ "testFails": {
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType":"slingPipes/filter",
+ "jcr:description":"filters resource that should have child",
+ "path":"/content/fruits/apple",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "slingPipesFilter_test":"${false}"
+ }
+ },
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/resources/fruits.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/resources/fruits.json?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/resources/fruits.json (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/resources/fruits.json Mon Dec 7 14:19:52 2015
@@ -0,0 +1,41 @@
+{
+ "jcr:primaryType":"nt:unstructured",
+ "index":["apple","banana"],
+ "apple":{
+ "jcr:primaryType":"nt:unstructured",
+ "isnota":{
+ "jcr:primaryType":"nt:unstructured",
+ "pea":{
+ "jcr:primaryType":"nt:unstructured",
+ "color":"green",
+ "buttheyhavesamecolor":{
+ "jcr:primaryType":"nt:unstructured"
+ }
+ },
+ "carrot":{
+ "jcr:primaryType":"nt:unstructured",
+ "andtheircolorisdifferent":{
+ "jcr:primaryType":"nt:unstructured"
+ }
+ }
+ }
+ },
+ "banana":{
+ "jcr:primaryType":"nt:unstructured",
+ "isnota":{
+ "jcr:primaryType":"nt:unstructured",
+ "pea":{
+ "jcr:primaryType":"nt:unstructured",
+ "andtheircolorisdifferent":{
+ "jcr:primaryType":"nt:unstructured"
+ }
+ },
+ "carrot":{
+ "jcr:primaryType":"nt:unstructured",
+ "andtheircolorisdifferent":{
+ "jcr:primaryType":"nt:unstructured"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/resources/json.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/resources/json.json?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/resources/json.json (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/resources/json.json Mon Dec 7 14:19:52 2015
@@ -0,0 +1,73 @@
+{
+ "jcr:primaryType":"nt:unstructured",
+ "conf": {
+ "weather": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "slingPipes/container",
+ "conf": {
+ "jcr:primaryType": "sling:Folder",
+ "selector": {
+ "sling:resourceType": "slingPipes/dummySearch",
+ "conf": {
+ "jcr:primaryType": "nt:unstructured",
+ "paris": {
+ "jcr:primaryType": "nt:unstructured",
+ "city": "paris",
+ "country": "fr"
+ },
+ "bucharest": {
+ "jcr:primaryType": "nt:unstructured",
+ "city": "bucharest",
+ "country": "ro"
+ }
+ }
+ },
+ "yahoo": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "slingPipes/json",
+ "expr": "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22${selector.city }%2C%20${selector.country}%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"
+ },
+ "write": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "slingPipes/write",
+ "path":"/content/json/windSpeed",
+ "conf": {
+ "${yahoo.get('query').get('results').get('channel').get('location').get('city')}":"${yahoo.get('query').get('results').get('channel').get('wind').get('speed')}"
+ }
+ }
+ }
+ },
+ "array": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "slingPipes/container",
+ "conf": {
+ "jcr:primaryType": "sling:Folder",
+ "json": {
+ "sling:resourceType": "slingPipes/json",
+ "expr": "[{\"path\":\"one\"},{\"path\":\"two\"},{\"path\":\"three\"}]"
+ },
+ "user": {
+ "sling:resourceType": "slingPipes/base",
+ "path":"/content/json/array/${json.get('path')}"
+ }
+ }
+
+
+ }
+ },
+ "windSpeed":{
+ "jcr:primaryType": "nt:unstructured"
+ },
+ "array": {
+ "jcr:primaryType": "nt:unstructured",
+ "one": {
+ "jcr:primaryType": "nt:unstructured"
+ },
+ "two": {
+ "jcr:primaryType": "nt:unstructured"
+ },
+ "three": {
+ "jcr:primaryType": "nt:unstructured"
+ }
+ }
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/resources/move.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/resources/move.json?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/resources/move.json (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/resources/move.json Mon Dec 7 14:19:52 2015
@@ -0,0 +1,13 @@
+{
+ "jcr:primaryType":"nt:unstructured",
+ "moveProperty": {
+ "sling:resourceType":"slingPipes/mv",
+ "path": "/content/fruits/index",
+ "expr": "/content/fruits/fruitsIndex"
+ },
+ "moveNode": {
+ "sling:resourceType":"slingPipes/mv",
+ "path": "/content/fruits/apple",
+ "expr": "/content/fruits/granny"
+ }
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/resources/multiProperty.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/resources/multiProperty.json?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/resources/multiProperty.json (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/resources/multiProperty.json Mon Dec 7 14:19:52 2015
@@ -0,0 +1,23 @@
+{
+ "jcr:primaryType": "nt:unstructured",
+ "working": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "slingPipes/multiProperty",
+ "path":"/content/fruits/index"
+ },
+ "typo": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "slingPipes/multiProperty",
+ "path":"/content/fruits/indexWithTypo"
+ },
+ "notProperty": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "slingPipes/multiProperty",
+ "path":"/content/fruits"
+ },
+ "notMultiple": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "slingPipes/multiProperty",
+ "path":"/etc/pipe/notMultiple/path"
+ }
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/resources/plumber.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/resources/plumber.json?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/resources/plumber.json (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/resources/plumber.json Mon Dec 7 14:19:52 2015
@@ -0,0 +1,4 @@
+{
+ "jcr:primaryType":"sling:Folder",
+ "sling:resourceType":"slingPipes/plumber"
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/resources/remove.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/resources/remove.json?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/resources/remove.json (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/resources/remove.json Mon Dec 7 14:19:52 2015
@@ -0,0 +1,26 @@
+{
+ "jcr:primaryType": "nt:unstructured",
+ "simple": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "slingPipes/rm"
+ },
+ "complex": {
+ "jcr:primaryType": "nt:unstructured",
+ "jcr:description": "configured here to remove the color property of ./isnota/pea and ./isnota/carrot subtree",
+ "path": "/content/fruits/apple",
+ "sling:resourceType": "slingPipes/rm",
+ "conf": {
+ "jcr:primaryType": "nt:unstructured",
+ "isnota": {
+ "jcr:primaryType": "nt:unstructured",
+ "pea": {
+ "jcr:primaryType": "nt:unstructured",
+ "color": "green"
+ },
+ "carrot": {
+ "jcr:primaryType": "nt:unstructured"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/resources/slingQuery.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/resources/slingQuery.json?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/resources/slingQuery.json (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/resources/slingQuery.json Mon Dec 7 14:19:52 2015
@@ -0,0 +1,9 @@
+{
+ "jcr:primaryType":"nt:unstructured",
+ "simple": {
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType":"slingPipes/slingQuery",
+ "path":"/content/users",
+ "expr":"[type=user]"
+ }
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/resources/testSum.js
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/resources/testSum.js?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/resources/testSum.js (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/resources/testSum.js Mon Dec 7 14:19:52 2015
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+var testSumFunction = function (a, b) {
+ return a + b;
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/resources/users.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/resources/users.json?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/resources/users.json (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/resources/users.json Mon Dec 7 14:19:52 2015
@@ -0,0 +1,15 @@
+{
+ "jcr:primaryType":"nt:unstructured",
+ "name":"root",
+ "users":"[user1,user2]",
+ "user1" : {
+ "jcr:primaryType":"nt:unstructured",
+ "name":"user1",
+ "type":"user"
+ },
+ "user2" : {
+ "jcr:primaryType":"nt:unstructured",
+ "name":"user2",
+ "type":"user"
+ }
+}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/sling-pipes/src/test/resources/write.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/sling-pipes/src/test/resources/write.json?rev=1718377&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/sling-pipes/src/test/resources/write.json (added)
+++ sling/trunk/contrib/extensions/sling-pipes/src/test/resources/write.json Mon Dec 7 14:19:52 2015
@@ -0,0 +1,87 @@
+{
+ "jcr:primaryType":"nt:unstructured",
+ "simple": {
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType":"slingPipes/write",
+ "path":"/content/fruits/apple",
+ "conf": {
+ "jcr:primaryType":"nt:unstructured",
+ "hasSeed":true,
+ "colors":["green","red"]
+ }
+ },
+ "piped": {
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType":"slingPipes/container",
+ "conf":{
+ "jcr:primaryType":"sling:Folder",
+ "fruit":{
+ "sling:resourceType":"slingPipes/dummySearch",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "apple":{"jcr:primaryType":"nt:unstructured","color":"green", "name":"apple"},
+ "banana":{"jcr:primaryType":"nt:unstructured", "color":"yellow", "name":"banana"}
+ }
+ },
+ "pipedWrite":{
+ "sling:resourceType":"slingPipes/write",
+ "jcr:description": "written resource is fixed here with path property, with a patch on fruits property",
+ "path":"/content/fruits",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "fruits": "+[${fruit.name}]",
+ "fixedVegetables":"[cabbage,carrot]"
+ }
+ }
+ }
+ },
+ "variablePipe" : {
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType":"slingPipes/container",
+ "conf":{
+ "jcr:primaryType":"sling:Folder",
+ "fruit":{
+ "sling:resourceType":"slingPipes/dummySearch",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "apple":{"jcr:primaryType":"nt:unstructured","color":"green", "name":"apple"},
+ "banana":{"jcr:primaryType":"nt:unstructured", "color":"yellow", "name":"banana"}
+ }
+ },
+ "variableInputPipedWrite":{
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType":"slingPipes/write",
+ "jcr:description":"written resource is here is coming from previous pipe",
+ "conf":{
+ "jcr:primaryType":"nt:unstructured",
+ "jcr:description":"${fruit.name} is a fruit and its color is ${fruit.color}"
+ }
+ }
+ }
+ },
+ "simpleTree": {
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType":"slingPipes/write",
+ "path":"/content/fruits/apple",
+ "conf": {
+ "jcr:primaryType":"nt:unstructured",
+ "hasSeed":true,
+ "colors":["green","red"],
+ "components": {
+ "jcr:primaryType":"sling:Folder",
+ "skin": {
+ "jcr:primaryType":"nt:unstructured"
+ },
+ "flesh": {
+ "jcr:primaryType":"nt:unstructured"
+ },
+ "seed": {
+ "jcr:primaryType":"nt:unstructured"
+ },
+ "worm": {
+ "jcr:primaryType":"nt:unstructured"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file