Skip to content

Commit

Permalink
Adding DirectAccess tests, completing API
Browse files Browse the repository at this point in the history
  • Loading branch information
nka11 committed Jun 23, 2011
1 parent 7fe96a4 commit f9c7218
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/NuQCore.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/NuQCore.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/ImplTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(function() {

}).call(this);
39 changes: 37 additions & 2 deletions test/NodeImplTest.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ sessionInstance = null
getSession = () ->
sessionInstance

getSessionAsync = (callback, err) ->
callback err,sessionInstance

setSession = (session) ->
sessionInstance = session

Expand All @@ -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
Expand Down
54 changes: 51 additions & 3 deletions test/NodeImplTest.js
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -18,6 +18,9 @@
getSession = function() {
return sessionInstance;
};
getSessionAsync = function(callback, err) {
return callback(err, sessionInstance);
};
setSession = function(session) {
return sessionInstance = session;
};
Expand All @@ -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");
}
}
};
Expand Down
37 changes: 37 additions & 0 deletions test/NuQTest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f9c7218

Please sign in to comment.