Browse files

Adding DirectAccess tests, completing API

  • Loading branch information...
1 parent 7fe96a4 commit f9c7218580a687c953607354fd99c8e87f220d68 @nka11 nka11 committed Jun 23, 2011
Showing with 138 additions and 5 deletions.
  1. +4 −0 src/NuQCore.coffee
  2. +6 −0 src/NuQCore.js
  3. +3 −0 test/ImplTest.js
  4. +37 −2 test/NodeImplTest.coffee
  5. +51 −3 test/NodeImplTest.js
  6. +37 −0 test/NuQTest.js
View
4 src/NuQCore.coffee
@@ -58,6 +58,10 @@ class NuQSession
# Returns a new session
impersonate: (credentials) ->
throw new Error "method not implemented"
+ itemExists: (abspath, callback) ->
+ throw new Error "method not implemented"
+ nodeExists: (abspath, callback) ->
+ throw new Error "method not implemented"
exports.Session = NuQSession
class NuQRepository
View
6 src/NuQCore.js
@@ -75,6 +75,12 @@
NuQSession.prototype.impersonate = function(credentials) {
throw new Error("method not implemented");
};
+ NuQSession.prototype.itemExists = function(abspath, callback) {
+ throw new Error("method not implemented");
+ };
+ NuQSession.prototype.nodeExists = function(abspath, callback) {
+ throw new Error("method not implemented");
+ };
return NuQSession;
})();
exports.Session = NuQSession;
View
3 test/ImplTest.js
@@ -0,0 +1,3 @@
+(function() {
+
+}).call(this);
View
39 test/NodeImplTest.coffee
@@ -20,6 +20,9 @@ sessionInstance = null
getSession = () ->
sessionInstance
+getSessionAsync = (callback, err) ->
+ callback err,sessionInstance
+
setSession = (session) ->
sessionInstance = session
@@ -33,11 +36,43 @@ getSuite = ->
assert.ok node instanceof core.Item ,"Node is not instance of NuQItem"
"GetPath returns String": (err, node) ->
assert.ok typeof node.getPath() == 'string',"GetPath return type is not string"
- "getNode node.getPath == node":
+ "Verify Session":
topic: () ->
getSession().getNode getTestedNode().getPath(), this.callback
"Compare objects": (err, node) ->
- assert.ok getTestedNode() == node, "equality should be verified"
+ assert.ok node != undefined, "node is undefined"
+ assert.ok node instanceof core.Node ,"Node is not instance of NuQNode"
+ assert.ok node instanceof core.Item ,"Node is not instance of NuQItem"
+
+ ## Additional test against S.getNode(p(N)) returns N.
+ assert.ok getTestedNode() == node, "equality must be verified"
+ "Direct Access tests (cf jcr-spec.pdf p88, v2)":
+ topic: () ->
+ getSessionAsync this.callback
+ "S.getItem(p(N)) returns N.": (err,S) ->
+ S.getItem getTestedNode().getPath(), (err, N) ->
+ assert.ok N == getTestedNode(), "equality must be verified"
+ "S.itemExists(p(N)) returns true": (err,S) ->
+ S.itemExists getTestedNode().getPath(), (err,res)->
+ assert.ok res
+ "S.getNode(p(N)) returns N.": (err,S) ->
+ S.getNode getTestedNode().getPath(), (err, N) ->
+ assert.ok N == getTestedNode(), "equality must be verified"
+ "S.nodeExists(p(N)) returns true": (err,S) ->
+ S.nodeExists getTestedNode().getPath(), (err, res) ->
+ assert.ok res
+ "S.getNodeByIdentifier(id(N)) returns N": (err, S) ->
+ S.getNodeByIdentifier getTestedNode().getIdentifier(), (err, N) ->
+ assert.ok N == getTestedNode(), "equality must be verified"
+ "If N is the primary item of a node M then M.getPrimaryItem() returns N": (err, S) ->
+ assert.ok false, "Test not implemented"
+ "If N is the root node of the workspace then S.getRootNode() returns N": (err, S) ->
+ assert.ok false, "Test not implemented"
+ "For all nodes M to which S has direct access, M.getNode(p(M,N)) returns N": (err, S) ->
+ assert.ok false, "Test not implemented"
+ "For all nodes M to which S has direct access, M.hasNode(p(M,N)) returns true": (err, S) ->
+ assert.ok false, "Test not implemented"
+
exports.getTestedNode = getTestedNode
exports.getSuite = getSuite
View
54 test/NodeImplTest.js
@@ -1,5 +1,5 @@
(function() {
- var assert, core, getNodeAsync, getSession, getSuite, getTestedNode, nodeInstance, sessionInstance, setNode, setSession, vows, _;
+ var assert, core, getNodeAsync, getSession, getSessionAsync, getSuite, getTestedNode, nodeInstance, sessionInstance, setNode, setSession, vows, _;
vows = require("vows");
assert = require("assert");
core = require("../src/NuQCore.js");
@@ -18,6 +18,9 @@
getSession = function() {
return sessionInstance;
};
+ getSessionAsync = function(callback, err) {
+ return callback(err, sessionInstance);
+ };
setSession = function(session) {
return sessionInstance = session;
};
@@ -38,12 +41,57 @@
return assert.ok(typeof node.getPath() === 'string', "GetPath return type is not string");
}
},
- "getNode node.getPath == node": {
+ "Verify Session": {
topic: function() {
return getSession().getNode(getTestedNode().getPath(), this.callback);
},
"Compare objects": function(err, node) {
- return assert.ok(getTestedNode() === node, "equality should be verified");
+ assert.ok(node !== void 0, "node is undefined");
+ assert.ok(node instanceof core.Node, "Node is not instance of NuQNode");
+ assert.ok(node instanceof core.Item, "Node is not instance of NuQItem");
+ return assert.ok(getTestedNode() === node, "equality must be verified");
+ }
+ },
+ "Direct Access tests (cf jcr-spec.pdf p88, v2)": {
+ topic: function() {
+ return getSessionAsync(this.callback);
+ },
+ "S.getItem(p(N)) returns N.": function(err, S) {
+ return S.getItem(getTestedNode().getPath(), function(err, N) {
+ return assert.ok(N === getTestedNode(), "equality must be verified");
+ });
+ },
+ "S.itemExists(p(N)) returns true": function(err, S) {
+ return S.itemExists(getTestedNode().getPath(), function(err, res) {
+ return assert.ok(res);
+ });
+ },
+ "S.getNode(p(N)) returns N.": function(err, S) {
+ return S.getNode(getTestedNode().getPath(), function(err, N) {
+ return assert.ok(N === getTestedNode(), "equality must be verified");
+ });
+ },
+ "S.nodeExists(p(N)) returns true": function(err, S) {
+ return S.nodeExists(getTestedNode().getPath(), function(err, res) {
+ return assert.ok(res);
+ });
+ },
+ "S.getNodeByIdentifier(id(N)) returns N": function(err, S) {
+ return S.getNodeByIdentifier(getTestedNode().getIdentifier(), function(err, N) {
+ return assert.ok(N === getTestedNode(), "equality must be verified");
+ });
+ },
+ "If N is the primary item of a node M then M.getPrimaryItem() returns N": function(err, S) {
+ return assert.ok(false, "Test not implemented");
+ },
+ "If N is the root node of the workspace then S.getRootNode() returns N": function(err, S) {
+ return assert.ok(false, "Test not implemented");
+ },
+ "For all nodes M to which S has direct access, M.getNode(p(M,N)) returns N": function(err, S) {
+ return assert.ok(false, "Test not implemented");
+ },
+ "For all nodes M to which S has direct access, M.hasNode(p(M,N)) returns true": function(err, S) {
+ return assert.ok(false, "Test not implemented");
}
}
};
View
37 test/NuQTest.js
@@ -0,0 +1,37 @@
+(function() {
+ /*
+ * This file is part of Nu-Q.
+ *
+ * Nu-Q is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * Nu-Q is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Nu-Q. If not, see <http://www.gnu.org/licenses/>.
+ */ var Node, a, core;
+ var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
+ for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
+ function ctor() { this.constructor = child; }
+ ctor.prototype = parent.prototype;
+ child.prototype = new ctor;
+ child.__super__ = parent.prototype;
+ return child;
+ };
+ core = require('./NuQCore.coffee');
+ Node = (function() {
+ __extends(Node, core.Node);
+ function Node() {}
+ Node.prototype.accept = function() {};
+ return Node;
+ })();
+ console.log("test");
+ a = new Node();
+ console.log(a);
+ a.accept;
+}).call(this);

0 comments on commit f9c7218

Please sign in to comment.