mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
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
This commit is contained in:
@@ -176,9 +176,8 @@ public class RhinoScriptTest extends TestCase
|
|||||||
{
|
{
|
||||||
Scriptable scope = cx.initStandardObjects();
|
Scriptable scope = cx.initStandardObjects();
|
||||||
|
|
||||||
// wrap System.out so we can perform println() from within scripts
|
// add logger object so we can perform output from within scripts
|
||||||
Object wrappedOut = Context.javaToJS(System.out, scope);
|
ScriptableObject.putProperty(scope, "logger", new ScriptLogger());
|
||||||
ScriptableObject.putProperty(scope, "out", wrappedOut);
|
|
||||||
|
|
||||||
// wrap a simple NodeRef Java object
|
// wrap a simple NodeRef Java object
|
||||||
// we can use Java style method calls within the script to access it's properties
|
// 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));
|
assertEquals(ref1.getId(), cx.toString(result));
|
||||||
|
|
||||||
// wrap a scriptable Alfresco Node object - the Node object is a wrapper like TemplateNode
|
// 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);
|
Object wrappedNode = Context.javaToJS(node1, scope);
|
||||||
ScriptableObject.putProperty(scope, "root", wrappedNode);
|
ScriptableObject.putProperty(scope, "root", wrappedNode);
|
||||||
|
|
||||||
@@ -384,16 +383,16 @@ public class RhinoScriptTest extends TestCase
|
|||||||
|
|
||||||
private static final String TESTSCRIPT1 =
|
private static final String TESTSCRIPT1 =
|
||||||
"var id = root.id;\r\n" +
|
"var id = root.id;\r\n" +
|
||||||
"out.println(id);\r\n" +
|
"logger.log(id);\r\n" +
|
||||||
"var name = root.name;\r\n" +
|
"var name = root.name;\r\n" +
|
||||||
"out.println(name);\r\n" +
|
"logger.log(name);\r\n" +
|
||||||
"var type = root.type;\r\n" +
|
"var type = root.type;\r\n" +
|
||||||
"out.println(type);\r\n" +
|
"logger.log(type);\r\n" +
|
||||||
"var childList = root.children;\r\n" +
|
"var childList = root.children;\r\n" +
|
||||||
"out.println(\"zero index node name: \" + childList[0].name);\r\n" +
|
"logger.log(\"zero index node name: \" + childList[0].name);\r\n" +
|
||||||
"out.println(\"name property access: \" + childList[0].properties.name );\r\n" +
|
"logger.log(\"name property access: \" + childList[0].properties.name);\r\n" +
|
||||||
"var childByNameNode = root.childByNamePath(\"/\" + childList[0].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" +
|
"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";
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
var id = root.id;
|
var id = root.id;
|
||||||
var name = root.name;
|
var name = root.name;
|
||||||
out.println("Name: " + name);
|
logger.log("Name: " + name);
|
||||||
var type = root.type;
|
var type = root.type;
|
||||||
out.println("ID: " + id + " of type: " + type);
|
logger.log("ID: " + id + " of type: " + type);
|
||||||
var noderef = root.nodeRef;
|
var noderef = root.nodeRef;
|
||||||
out.println("NodeRef: " + noderef);
|
logger.log("NodeRef: " + noderef);
|
||||||
var childList = root.children;
|
var childList = root.children;
|
||||||
out.println("Has " + childList.length + " child nodes");
|
logger.log("Has " + childList.length + " child nodes");
|
||||||
var properties = root.properties;
|
var properties = root.properties;
|
||||||
out.println("Property Count: " + properties.length);
|
logger.log("Property Count: " + properties.length);
|
||||||
var assocs = root.assocs;
|
var assocs = root.assocs;
|
||||||
out.println("Assoc Count: " + assocs.length);
|
logger.log("Assoc Count: " + assocs.length);
|
||||||
|
|
||||||
// test various access mechanisms
|
// test various access mechanisms
|
||||||
var childname1 = childList[0].name;
|
var childname1 = childList[0].name;
|
||||||
|
Reference in New Issue
Block a user