From 30136a58eb8392218b34eccfc0d8cc63df0cb9f5 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Wed, 6 Jun 2007 17:16:43 +0000 Subject: [PATCH] Fix up script service tests to expect native JavaScript array return types instead of assuming java arrays git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5869 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/jscript/RhinoScriptTest.java | 21 +++++++++---------- .../org/alfresco/repo/jscript/test_script1.js | 12 +++++------ 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/source/java/org/alfresco/repo/jscript/RhinoScriptTest.java b/source/java/org/alfresco/repo/jscript/RhinoScriptTest.java index 8befe30559..15322a3fee 100644 --- a/source/java/org/alfresco/repo/jscript/RhinoScriptTest.java +++ b/source/java/org/alfresco/repo/jscript/RhinoScriptTest.java @@ -176,9 +176,8 @@ public class RhinoScriptTest extends TestCase { Scriptable scope = cx.initStandardObjects(); - // wrap System.out so we can perform println() from within scripts - Object wrappedOut = Context.javaToJS(System.out, scope); - ScriptableObject.putProperty(scope, "out", wrappedOut); + // add logger object so we can perform output from within scripts + ScriptableObject.putProperty(scope, "logger", new ScriptLogger()); // wrap a simple NodeRef Java object // we can use Java style method calls within the script to access it's properties @@ -192,7 +191,7 @@ public class RhinoScriptTest extends TestCase assertEquals(ref1.getId(), cx.toString(result)); // wrap a scriptable Alfresco Node object - the Node object is a wrapper like TemplateNode - Node node1 = new Node(root, serviceRegistry, null); + Node node1 = new Node(root, serviceRegistry, scope); Object wrappedNode = Context.javaToJS(node1, scope); ScriptableObject.putProperty(scope, "root", wrappedNode); @@ -384,16 +383,16 @@ public class RhinoScriptTest extends TestCase private static final String TESTSCRIPT1 = "var id = root.id;\r\n" + - "out.println(id);\r\n" + + "logger.log(id);\r\n" + "var name = root.name;\r\n" + - "out.println(name);\r\n" + + "logger.log(name);\r\n" + "var type = root.type;\r\n" + - "out.println(type);\r\n" + + "logger.log(type);\r\n" + "var childList = root.children;\r\n" + - "out.println(\"zero index node name: \" + childList[0].name);\r\n" + - "out.println(\"name property access: \" + childList[0].properties.name );\r\n" + + "logger.log(\"zero index node name: \" + childList[0].name);\r\n" + + "logger.log(\"name property access: \" + childList[0].properties.name);\r\n" + "var childByNameNode = root.childByNamePath(\"/\" + childList[0].name);\r\n" + - "out.println(\"child by name path: \" + childByNameNode.name);\r\n" + + "logger.log(\"child by name path: \" + childByNameNode.name);\r\n" + "var xpathResults = root.childrenByXPath(\"/*\");\r\n" + - "out.println(\"children of root from xpath: \" + xpathResults.length);\r\n"; + "logger.log(\"children of root from xpath: \" + xpathResults.length);\r\n"; } diff --git a/source/java/org/alfresco/repo/jscript/test_script1.js b/source/java/org/alfresco/repo/jscript/test_script1.js index 4c50ce9e97..1637b432b7 100644 --- a/source/java/org/alfresco/repo/jscript/test_script1.js +++ b/source/java/org/alfresco/repo/jscript/test_script1.js @@ -1,16 +1,16 @@ var id = root.id; var name = root.name; -out.println("Name: " + name); +logger.log("Name: " + name); var type = root.type; -out.println("ID: " + id + " of type: " + type); +logger.log("ID: " + id + " of type: " + type); var noderef = root.nodeRef; -out.println("NodeRef: " + noderef); +logger.log("NodeRef: " + noderef); var childList = root.children; -out.println("Has " + childList.length + " child nodes"); +logger.log("Has " + childList.length + " child nodes"); var properties = root.properties; -out.println("Property Count: " + properties.length); +logger.log("Property Count: " + properties.length); var assocs = root.assocs; -out.println("Assoc Count: " + assocs.length); +logger.log("Assoc Count: " + assocs.length); // test various access mechanisms var childname1 = childList[0].name;