incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r742951 - /incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java
Date Tue, 10 Feb 2009 12:22:22 GMT
Author: fmeschbe
Date: Tue Feb 10 12:22:11 2009
New Revision: 742951

URL: http://svn.apache.org/viewvc?rev=742951&view=rev
Log:
SLING-534 Apply patch by Eric Norman (Thanks) with multi value unit test

Modified:
    incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java

Modified: incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java?rev=742951&r1=742950&r2=742951&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java
Tue Feb 10 12:22:11 2009
@@ -23,10 +23,11 @@
 
 import javax.jcr.Node;
 import javax.jcr.Property;
+import javax.jcr.Value;
 
+import org.apache.sling.commons.json.jcr.JsonItemWriter;
 import org.apache.sling.scripting.RepositoryScriptingTestBase;
 import org.apache.sling.scripting.javascript.internal.ScriptEngineHelper;
-import org.apache.sling.commons.json.jcr.JsonItemWriter;
 
 /** Test the ScriptableNode class "live", by retrieving
  *  Nodes from a Repository and executing javascript code
@@ -334,4 +335,31 @@
                 script.eval("node.getSession().getRootNode().getPath()", data)
         );
     }
+
+    /**
+     * Test for regressing this issue:
+     * https://issues.apache.org/jira/browse/SLING-534
+     */
+    public void testMultiValReferencePropLookup() throws Exception {
+        Node refNode1 = getNewNode();
+        refNode1.addMixin("mix:referenceable");
+        Node refNode2 = getNewNode();
+        refNode2.addMixin("mix:referenceable");
+
+        node.setProperty("singleRef", refNode1);
+        node.setProperty("multiRef", new Value[] {
+            session.getValueFactory().createValue(refNode1),
+            session.getValueFactory().createValue(refNode2) });
+
+        String code = "node['singleRef']";
+        assertTrue(script.eval(code, data) instanceof Node);
+        code = "node.singleRef instanceof Array";
+        assertEquals(false, script.eval(code, data));
+
+        code = "node.multiRef instanceof Array";
+        assertEquals(true, script.eval(code, data));
+
+        code = "node.multiRef[0]";
+        assertTrue(script.eval(code, data) instanceof Node);
+    }
 }



Mime
View raw message