You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by iv...@apache.org on 2015/07/16 11:26:46 UTC

[50/51] [abbrv] incubator-ignite git commit: #ignite-961: add promises

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8616eebb/modules/nodejs/src/test/js/test-cache-api.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-cache-api.js b/modules/nodejs/src/test/js/test-cache-api.js
index 9855fa3..ed05a90 100644
--- a/modules/nodejs/src/test/js/test-cache-api.js
+++ b/modules/nodejs/src/test/js/test-cache-api.js
@@ -23,264 +23,570 @@ var CacheEntry = Ignite.CacheEntry;
 var assert = require("assert");
 
 testPutGet = function() {
-    startTest(false, "mycache", {trace: [put, getExist], entry: ["key" , "6"]});
+    var key = "key";
+    var val = "6";
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+        cache.put(key, val).then(function() {
+            return cache.get(key);
+        }).then(function(res) {
+            assert(TestUtils.compareObject(val, res), "Get incorrect value on get [exp=" +
+                JSON.stringify(val) + ", val=" + JSON.stringify(res) + "]");
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    }).catch(function (err) {
+        assert(err === null, err);
+    });
 }
 
 testPutGetObject = function() {
     var key = {"name" : "Paul"};
     var val = {"age" : 12, "books" : ["1", "Book"]};
 
-    startTest(false, "mycache", {trace: [put, getExist], entry: [key , val]});
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.put(key, val).then(function() {
+            return cache.get(key);
+        }).then(function(res) {
+            assert(TestUtils.compareObject(val, res), "Get incorrect value on get [exp=" +
+                JSON.stringify(val) + ", val=" + JSON.stringify(res) + "]");
+            TestUtils.testDone();
+        })
+    });
 }
 
 testPutContains = function() {
-    startTest(false, "mycache", {trace: [put, containsKey], entry: ["key" , "6"]});
+    var key = "key";
+    var val = "6";
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.put(key, val).then(function() {
+            return cache.containsKey(key);
+        }).then(function(res) {
+            assert(res === true, "Incorrect result [expected=" + true + ", val=" + res + "]");
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testContains = function() {
-    startTest(false, "mycache", {trace: [notContainsKey], entry: ["key" , "6"]});
+    var key = "key";
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.containsKey(key).then(function(res) {
+            assert(res === false, "Incorrect result [expected=" + false + ", val=" + res + "]");
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testPutContainsAll = function() {
-    startTest(false, "mycache", {trace: [putAll, containsKeys], entry: objectEntries()});
+    var entries = objectEntries();
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.putAll(entries).then(function(res) {
+            var keys = []
+
+            for (var entry of entries) {
+                keys.push(entry.key);
+            }
+
+            return cache.containsKeys(keys);
+        }).then(function(res) {
+            assert(res === true, "Incorrect result [expected=" + true + ", val=" + res + "]");
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testNotContainsAll = function() {
-    startTest(false, "mycache", {trace: [notContainsKeys], entry: stringEntries()});
+    var entries = stringEntries();
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        var keys = []
+
+        for (var entry of entries) {
+            keys.push(entry.key);
+        }
+
+        cache.containsKeys(entries).then(function(res) {
+            assert(res === false, "Incorrect result [expected=" + false + ", val=" + res + "]");
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testRemove = function() {
-    startTest(false, "mycache", {trace: [put, getExist, remove, getNonExist], entry: ["key" , "6"]});
+    var key = "key";
+    var val = "6";
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.put(key, val).then(function(res) {
+            return cache.get(key);
+        }).then(function(res) {
+            assert (res === val, "Incorrect result [expected=" + val + ", val=" + res + "]");
+
+            return cache.remove(key);
+        }).then(function(res) {
+            assert (res === true, "Incorrect result [expected=" + true + ", val=" + res + "]");
+
+            return cache.get(key);
+        }).then(function(res) {
+            assert (res === null, "Incorrect result [expected=" + null + ", val=" + res + "]");
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testRemoveNoKey = function() {
-    startTest(false, "mycache", {trace: [remove, getNonExist], entry: ["key" , "6"]});
+    var key = "key";
+    var val = "6";
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.remove(key).then(function(res) {
+            assert (res === false, "Incorrect result [expected=" + false + ", val=" + res + "]");
+
+            return cache.get(key);
+        }).then(function(res) {
+            assert (res === null, "Incorrect result [expected=" + null + ", val=" + res + "]");
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testPutAllGetAll = function() {
-    startTest(false, "mycache", {trace: [putAll, getAll], entry: stringEntries()});
+    var entries = stringEntries();
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.putAll(entries).then(function(res) {
+            var keys = getKeys(entries);
+
+            return cache.getAll(keys);
+        }).then(function(res) {
+            onGetAll(entries, res);
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testPutAllObjectGetAll = function() {
-    startTest(false, "mycache", {trace: [putAll, getAll], entry: objectEntries()});
+    var entries = objectEntries();
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.putAll(entries).then(function(res) {
+            var keys = getKeys(entries);
+
+            return cache.getAll(keys);
+        }).then(function(res) {
+            onGetAll(entries, res);
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testRemoveAllObjectGetAll = function() {
-    startTest(false, "mycache", {trace: [putAll, getAll, removeAll, getNone], entry: objectEntries()});
+    var entries = objectEntries();
+    var keys = getKeys(entries);
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.putAll(entries).then(function(res) {
+            return cache.getAll(keys);
+        }).then(function(res) {
+            onGetAll(entries, res);
+
+            return cache.removeAll(keys);
+        }).then(function(res) {
+            assert (res === true, "Incorrect result [expected=" + true + ", val=" + res + "]");
+
+            return cache.getAll(keys);
+         }).then(function(res) {
+             for (var i = 0; i < res.length; ++i) {
+                assert(res[i] === null, "Incorrect result [expected=" + null + ", val=" + res[i] + "]");
+             }
+
+             TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testRemoveAll = function() {
-    startTest(false, "mycache", {trace: [putAll, getAll, removeAll, getNone], entry: stringEntries()});
+    var entries = stringEntries();
+    var keys = getKeys(entries);
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.putAll(entries).then(function(res) {
+            return cache.getAll(keys);
+        }).then(function(res) {
+            onGetAll(entries, res);
+
+            return cache.removeAll(keys);
+        }).then(function(res) {
+            assert (res === true, "Incorrect result [expected=" + true + ", val=" + res + "]");
+
+            return cache.getAll(keys);
+         }).then(function(res) {
+             for (var i = 0; i < res.length; ++i) {
+                assert(res[i] === null, "Incorrect result [expected=" + null + ", val=" + res[i] + "]");
+             }
+
+             TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testIncorrectCacheName = function() {
-    startTest(false, "mycache1", {trace: [incorrectPut], entry: ["key", "6"]});
+    var key = "key";
+    var val = "6";
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache1");
+
+        cache.put(key, val).then(function(res) {
+            assert(false, "Do not get exception.");
+        }).catch(function (err) {
+            assert(err !== null, err);
+            assert(err.indexOf("Failed to find cache for given cache name") !== -1,
+                "Incorrect message on not exist cache. " + err);
+
+            TestUtils.testDone();
+        })
+    });
 }
 
 testGetOrCreateCacheName = function() {
-    startTest(true, "mycache2", {trace: [put, getExist], entry: ["key", "6"]});
+    var key = "key";
+    var val = "6";
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        return ignite.getOrCreateCache("mycache2");
+    }).then(function(cache) {
+        return cache.put(key, val);
+    }).then(function(res) {
+        TestUtils.testDone();
+    }).catch(function (err) {
+        assert(err === null, err);
+    });
 }
 
 testGetAndPut = function() {
-    function onGetAndPut(err, res) {
-        assert(err === null, "Get error on get and put [err=" + err + "]");
-        assert(res === "6", "Incorrect result for getAndPut [expected=6, val" + res + "]");
+    var key = "key";
+    var val = "6";
+    var val2 = "7";
 
-        TestUtils.testDone();
-    }
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
 
-    function getAndPut(cache, entry, next) {
-        cache.getAndPut("key", "7", onGetAndPut);
-    }
+        cache.put(key, val).then(function() {
+            return cache.getAndPut(key, val2);
+        }).then(function(res) {
+            assert(res === val, "Incorrect result [expected=" + val + ", val=" + res + "]");
 
-    startTest(false, "mycache", {trace: [put, getAndPut], entry: ["key", "6"]});
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testGetAndPutIfAbsent = function() {
-    function getAndPutIfAbsent(cache, entry, next) {
-        cache.getAndPutIfAbsent("key", "7", onGetAndPutIfAbsent);
+    var key = "key";
+    var val = "6";
+    var val2 = "7";
 
-        function onGetAndPutIfAbsent(err, res) {
-            assert(err === null, "Get error on get and put [err=" + err + "]");
-            assert(res === "6", "Incorrect result for getAndPutIfAbsent [expected=6, val" + res + "]");
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
 
-            next();
-        }
-    }
+        cache.put(key, val).then(function() {
+            return cache.getAndPutIfAbsent(key, val2);
+        }).then(function(res) {
+            assert(res === val, "Incorrect result [expected=" + val + ", val=" + res + "]");
 
-    startTest(false, "mycache", {trace: [put, getAndPutIfAbsent, getExist], entry: ["key", "6"]});
+            return cache.get(key);
+        }).then(function(res) {
+            assert(res === val, "Incorrect result [expected=" + val + ", val=" + res + "]");
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testPutIfAbsent = function() {
-    function putIfAbsent(cache, entry, next) {
-        cache.putIfAbsent("key", "7", onPutIfAbsent);
+    var key = "key";
+    var val = "6";
+    var val2 = "7";
 
-        function onPutIfAbsent(err, res) {
-            assert(err === null, "Get error on get and put [err=" + err + "]");
-            assert(res === false, "Incorrect result for putIfAbsent [expected=false, val" + res + "]");
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
 
-            next();
-        }
-    }
+        cache.put(key, val).then(function() {
+            return cache.putIfAbsent(key, val2);
+        }).then(function(res) {
+            assert(res === false, "Incorrect result [expected=" + false + ", val=" + res + "]");
 
-    startTest(false, "mycache", {trace: [put, putIfAbsent, getExist], entry: ["key", "6"]});
+            return cache.get(key);
+        }).then(function(res) {
+            assert(res === val, "Incorrect result [expected=" + val + ", val=" + res + "]");
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testRemoveValue = function() {
-    function removeValue(cache, entry, next) {
-        cache.removeValue("key", "7", onRemoveValue);
+    var key = "key";
+    var val = "6";
+    var val2 = "7";
 
-        function onRemoveValue(err, res) {
-            assert(err === null, "Get error on get and put [err=" + err + "]");
-            assert(res === false, "Incorrect result for onRemoveValue [expected=false, val" + res + "]");
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
 
-            next();
-        }
-    }
+        cache.put(key, val).then(function() {
+            return cache.removeValue(key, val2);
+        }).then(function(res) {
+            assert(res === false, "Incorrect result [expected=" + false + ", val=" + res + "]");
+
+            return cache.get(key);
+        }).then(function(res) {
+            assert(res === val, "Incorrect result [expected=" + val + ", val=" + res + "]");
 
-    startTest(false, "mycache", {trace: [put, removeValue, getExist], entry: ["key", "6"]});
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testGetAndRemove = function() {
-    function getAndRemove(cache, entry, next) {
-        cache.getAndRemove("key", onGetAndRemove);
+    var key = "key";
+    var val = "6";
+    var val2 = "7";
 
-        function onGetAndRemove(err, res) {
-            assert(err === null, "Get error on get and put [err=" + err + "]");
-            assert(res === "6", "Incorrect result for getAndPut [expected=6, val" + res + "]");
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
 
-            next();
-        }
-    }
+        cache.put(key, val).then(function() {
+            return cache.getAndRemove(key, val2);
+        }).then(function(res) {
+            assert(res === val, "Incorrect result [expected=" + val + ", val=" + res + "]");
+
+            return cache.get(key);
+        }).then(function(res) {
+            assert(res === null, "Incorrect result [expected=" + null + ", val=" + res + "]");
 
-    startTest(false, "mycache", {trace: [put, getAndRemove, getNone], entry: ["key", "6"]});
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testRemoveAllFromCache = function() {
-    function removeAllFromCache(cache, entry, next) {
-        cache.removeAllFromCache(next);
-    }
+    var key = "key";
+    var val = "6";
 
-    startTest(false, "mycache", {trace: [put, removeAllFromCache, getNone], entry: ["key", "6"]});
-}
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
 
-testReplace = function() {
-    function replace(cache, entry, next) {
-        cache.replace(entry[0], "7", onReplace.bind(null, cache));
-
-        function onReplace(cache, err, res) {
-            assert(err === null, "Get error on get and put [err=" + err + "]");
-            assert(res === true, "Incorrect result for replace [expected=true, val=" + res + "]");
-
-            cache.get(entry[0], function(err, res) {
-                assert(!err);
-                assert("7" === res, "Get incorrect value on get [exp=7, val=" + res + "]");
-                next();
-            });
-        }
-    }
+        cache.put(key, val).then(function() {
+            return cache.removeAllFromCache();
+        }).then(function(res) {
+            return cache.get(key);
+        }).then(function(res) {
+            assert(res === null, "Incorrect result [expected=" + null + ", val=" + res + "]");
 
-    startTest(false, "mycache", {trace: [put, replace], entry: ["key", "6"]});
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
-testReplaceObject = function() {
-    function replace(cache, entry, next) {
-        var newKey = {"key" :"7"};
-        cache.replace(entry[0], newKey, onReplace.bind(null, cache));
+testReplace = function() {
+    var key = "key";
+    var val = "6";
+    var val2 = "7";
 
-        function onReplace(cache, err, res) {
-            assert(err === null, "Get error on get and put [err=" + err + "]");
-            assert(res === true, "Incorrect result for replace [expected=true, val" + res + "]");
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
 
-            cache.get(entry[0], function(err, res) {
-                assert(!err);
-                assert(TestUtils.compareObject(newKey, res), "Get incorrect value on get.");
+        cache.put(key, val).then(function() {
+            return cache.replace(key, val2);
+        }).then(function(res) {
+            assert(res === true, "Incorrect result [expected=" + true + ", val=" + res + "]");
 
-                next();
-            });
-        }
-    }
+            return cache.get(key);
+        }).then(function(res) {
+            assert(res === val2, "Incorrect result [expected=" + val2 + ", val=" + res + "]");
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
+}
 
+testReplaceObject = function() {
     var key = {"name" : "Paul"};
     var val = {"age" : 12, "books" : ["1", "Book"]};
+    var val2 = {"key" :"7"};
 
-    startTest(false, "mycache", {trace: [put, replace], entry: [key, val]});
-}
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
 
-testGetAndReplaceObject = function() {
-    function getAndReplace(cache, entry, next) {
-        var newKey = {"key" :"7"};
-        cache.getAndReplace(entry[0], newKey, onGetAndReplace.bind(null, cache));
+        cache.put(key, val).then(function() {
+            return cache.replace(key, val2);
+        }).then(function(res) {
+            assert(res === true, "Incorrect result [expected=" + true + ", val=" + res + "]");
 
-        function onGetAndReplace(cache, err, res) {
-            assert(err === null, "Get error on get and put [err=" + err + "]");
-            assert(TestUtils.compareObject(val, res), "Get incorrect value on get.");
+            return cache.get(key);
+        }).then(function(res) {
+            assert(TestUtils.compareObject(val2, res), "Incorrect result [expected=" + val2 + ", val=" + res + "]");
 
-            next();
-        }
-    }
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
+}
 
+testGetAndReplaceObject = function() {
     var key = {"name" : "Paul"};
     var val = {"age" : 12, "books" : ["1", "Book"]};
+    var val2 = {"key" :"7"};
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
 
-    startTest(false, "mycache", {trace: [put, getAndReplace], entry: [key, val]});
+        cache.put(key, val).then(function() {
+            return cache.getAndReplace(key, val2);
+        }).then(function(res) {
+            assert(TestUtils.compareObject(val, res), "Incorrect result [expected=" + val + ", val=" + res + "]");
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testReplaceValueObject = function() {
-    function replaceValue(cache, entry, next) {
-        var newVal = {"key" :"7"};
-        cache.replaceValue(entry[0], newVal, entry[1], onReplaceValue.bind(null, cache));
-
-        function onReplaceValue(cache, err, res) {
-            assert(err === null, "Get error on get and put [err=" + err + "]");
-            assert(res === true, "Incorrect result for replace [expected=true, val" + res + "]");
-            next();
-        }
-    }
-
     var key = {"name" : "Paul"};
     var val = {"age" : 12, "books" : ["1", "Book"]};
+    var val2 = {"key" :"7"};
+
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.put(key, val).then(function() {
+            return cache.replaceValue(key, val2, val);
+        }).then(function(res) {
+            assert(res === true, "Incorrect result [expected=" + true + ", val=" + res + "]");
 
-    startTest(false, "mycache", {trace: [put, replaceValue], entry: [key, val]});
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 testIncorrectReplaceObject = function() {
-    function replace(cache, entry, next) {
-        cache.replace(entry[0], "7", onReplace.bind(null, cache));
+    var key = {"name" : "Paul"};
+    var val = {"age" : 12, "books" : ["1", "Book"]};
+    var val2 = "7";
 
-        function onReplace(cache, err, res) {
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.put(key, val).then(function() {
+            return cache.replace(key, val2);
+        }).then(function(res) {
+            assert(false, "Do not get exception.");
+        }).catch(function (err) {
             assert(err !== null, "Do not get error");
             assert(err.indexOf("Failed to update keys") > -1, "Incorrect error message: " + err);
-            next();
-        }
-    }
 
-    var key = {"name" : "Paul"};
-    var val = {"age" : 12, "books" : ["1", "Book"]};
-
-    startTest(false, "mycache", {trace: [put, replace], entry: [key, val]});
+            TestUtils.testDone();
+        })
+    });
 }
 
 testSize = function() {
-    function onSize(exp, next, cache, err, res) {
-            assert(err === null, "Do not get error");
-            assert(res === exp, "Incorrect size: " + res);
-
-            next();
-    }
+    var key = {"name" : "Paul"};
+    var val = {"age" : 12, "books" : ["1", "Book"]};
 
-    function size0(cache, entry, next) {
-        cache.size(onSize.bind(null, 0, next, cache));
-    }
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
 
-    function size1(cache, entry, next) {
-        cache.size(onSize.bind(null, 1, next, cache));
-    }
+        cache.size().then(function(res) {
+            assert(res === 0, "Incorrect result [expected=" + 0 + ", val=" + res + "]");
 
-    var key = {"name" : "Paul"};
-    var val = {"age" : 12, "books" : ["1", "Book"]};
+            return cache.put(key, val);
+        }).then(function() {
+            return cache.size();
+        }).then(function(res) {
+            assert(res === 1, "Incorrect result [expected=" + 1 + ", val=" + res + "]");
 
-    startTest(false, "mycache", {trace: [size0, put, size1], entry: [key, val]});
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    });
 }
 
 function objectEntries() {
@@ -306,203 +612,46 @@ function stringEntries() {
     return entries;
 }
 
-function startTest(createCache, cacheName, testDescription) {
-    TestUtils.startIgniteNode(onStart.bind(null, createCache, cacheName, testDescription));
-}
-
-function onStart(createCache, cacheName, testDescription, error, ignite) {
-    if (createCache) {
-        ignite.getOrCreateCache(cacheName, function(err, cache) {
-            assert(err === null, err);
+function onGetAll(expected, values) {
+    var keys = getKeys(expected);
 
-            function callNext(error) {
-                assert(!error);
-                var next = testDescription.trace.shift();
-                if (next)
-                    next.call(null, cache, testDescription.entry, callNext);
-                else
-                    TestUtils.testDone();
-            }
+    assert(values.length === keys.length, "Values length is incorrect "
+        + "[expected=" + keys.length + ", real=" + values.length + "]");
 
-            callNext();
-        });
-    }
-    else {
-        var cache = ignite.cache(cacheName);
-
-        function callNext(error) {
-            assert(!error);
-            var next = testDescription.trace.shift();
-            if (next)
-                next.call(null, cache, testDescription.entry, callNext);
-            else
-                TestUtils.testDone();
-        }
-
-        callNext();
-    }
-
-
-}
-
-function put(cache, entry, next) {
-    cache.put(entry[0], entry[1], next);
-}
-
-function containsKey(cache, entry, next) {
-    cache.containsKey(entry[0], onContainsKey);
-
-    function onContainsKey(err, val) {
-        assert(err === null, "Error on contains key [err=" + err + "]");
-        assert(val === true, "Incorrect result [expected=" + true + ", val=" + val + "]");
-
-        TestUtils.testDone();
-    }
-}
-
-function notContainsKey(cache, entry, next) {
-    cache.containsKey(entry[0], onContainsKey);
-
-    function onContainsKey(err, val) {
-        assert(err === null, "Error on contains key [err=" + err + "]");
-        assert(val === false, "Incorrect result [expected=" + false + ", val=" + val + "]");
-
-        TestUtils.testDone();
-    }
-}
-
-function containsKeys(cache, entries, next) {
-    var keys = []
-
-    for (var entry of entries) {
-        keys.push(entry.key);
-    }
+    for (var i = 0; i < keys.length; ++i) {
+        var key = keys[i];
 
-    cache.containsKeys(keys, onContainsKeys);
+        var foundVal = null;
 
-    function onContainsKeys(err, val) {
-        assert(err === null, "Error on contains key [err=" + err + "]");
-        assert(val === true, "Incorrect result [expected=" + true + ", val=" + val + "]");
-
-        TestUtils.testDone();
-    }
-}
-
-function notContainsKeys(cache, entries, next) {
-    var keys = []
-
-    for (var entry of entries) {
-        keys.push(entry.key);
-    }
-
-    cache.containsKeys(keys, onContainsKeys);
-
-    function onContainsKeys(err, val) {
-        assert(err === null, "Error on contains key [err=" + err + "]");
-        assert(val === false, "Incorrect result [expected=" + false + ", val=" + val + "]");
-
-        TestUtils.testDone();
-    }
-}
+        for (var j = 0; j < values.length; ++j) {
+            if (TestUtils.compareObject(key, values[j].key)) {
+                foundVal = values[j];
+            }
+        }
 
-function getExist(cache, entry, next) {
-    function onGet(error, value) {
-        assert(!error);
-        assert(TestUtils.compareObject(entry[1], value), "Get incorrect value on get [exp=" +
-            JSON.stringify(entry[1]) + ", val=" + JSON.stringify(value) + "]");
-        next();
-    }
+        var foundExp = null;
 
-    cache.get(entry[0], onGet);
-}
-
-function remove(cache, entry, next) {
-    cache.remove(entry[0], next);
-}
+        for (var j = 0; j < expected.length; ++j) {
+            if (TestUtils.compareObject(key, expected[j].key)) {
+                foundExp = expected[j];
+            }
+        }
 
-function getNonExist(cache, entry, next) {
-    cache.get(entry[0], onGet);
+        assert(foundVal !== null, "Cannot find key. [key=" + key + "].");
+        assert(foundExp !== null, "Cannot find key. [key=" + key + "].");
 
-    function onGet(error, value) {
-        assert(!error);
-        assert(!value);
-        next();
+        assert(TestUtils.compareObject(foundExp, foundVal), "Incorrect value");
     }
-}
 
-function putAll(cache, entries, next) {
-    cache.putAll(entries, next);
+    return true;
 }
 
-function getAll(cache, entries, next) {
+function getKeys(entries) {
     var keys = []
 
     for (var entry of entries) {
         keys.push(entry.key);
     }
 
-    cache.getAll(keys, onGetAll.bind(null, keys));
-
-    var expected = entries;
-
-    function onGetAll(keys, error, values) {
-        assert(!error, error);
-
-        assert(values.length === keys.length, "Values length is incorrect "
-            + "[expected=" + keys.length + ", real=" + values.length + "]");
-
-        for (var i = 0; i < keys.length; ++i) {
-            var key = keys[i];
-
-            var foundVal = null;
-
-            for (var j = 0; j < values.length; ++j) {
-                if (TestUtils.compareObject(key, values[j].key)) {
-                    foundVal = values[j];
-                }
-            }
-
-            var foundExp = null;
-
-            for (var j = 0; j < expected.length; ++j) {
-                if (TestUtils.compareObject(key, expected[j].key)) {
-                    foundExp = expected[j];
-                }
-            }
-
-            assert(foundVal !== null, "Cannot find key. [key=" + key + "].");
-            assert(foundExp !== null, "Cannot find key. [key=" + key + "].");
-
-            assert(TestUtils.compareObject(foundExp, foundVal), "Incorrect value");
-        }
-
-        next();
-    }
-}
-
-function removeAll(cache, entries, next) {
-    cache.removeAll(Object.keys(entries), next)
-}
-
-function getNone(cache, entries, next) {
-    cache.getAll(Object.keys(entries), onGetAll);
-
-    function onGetAll(error, values) {
-        assert(!error, error);
-        assert(!values || !Object.keys(values).length);
-
-        next();
-    }
-}
-
-function incorrectPut(cache, entry, next) {
-    cache.put(entry[0], entry[1], callback);
-
-    function callback(error) {
-        assert(!!error, "Do not get error for not exist cache");
-        assert(error.indexOf("Failed to find cache for given cache name") !== -1,
-            "Incorrect message on not exist cache. " + error);
-
-        next();
-    }
+    return keys;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8616eebb/modules/nodejs/src/test/js/test-compute.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-compute.js b/modules/nodejs/src/test/js/test-compute.js
index 5cdc3e0..600f11d 100644
--- a/modules/nodejs/src/test/js/test-compute.js
+++ b/modules/nodejs/src/test/js/test-compute.js
@@ -23,28 +23,222 @@ var CacheEntry = Ignite.CacheEntry;
 var assert = require("assert");
 
 testComputeRunScript = function() {
-    TestUtils.startIgniteNode(onStart.bind(null, computeRunScript));
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.putAll(getEntries()).then(function(res) {
+            var comp = ignite.compute();
+
+            var f = function (args) {
+                print("!!!!" + args + " " + ignite.name());
+                return args + " " + ignite.name();
+            }
+
+            return comp.run(f, "GridGain");
+        }).then(function(res) {
+            assert(res.indexOf("NodeJsComputeSelfTest") !== -1, "Incorrect result message. [mes=" + res + "].");
+            assert(res.indexOf("GridGain") !== -1, "Incorrect result message. [mes=" + res + "].");
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    })
 }
 
 testComputeExecute = function() {
-    TestUtils.startIgniteNode(computeExecute);
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.putAll(getEntries()).then(function(res) {
+            var map = function(nodes, arg) {
+                var words = arg.split(" ");
+
+                for (var i = 0; i < words.length; i++) {
+                    var f = function (word) {
+                        print(">>> Printing " + word);
+
+                        return word.length;
+                    };
+
+                    emit(f, words[i], nodes[i %  nodes.length]);
+                }
+            };
+
+            var reduce = function(results) {
+                var sum = 0;
+
+                for (var i = 0; i < results.length; ++i) {
+                    sum += results[i];
+                }
+
+                return sum;
+            };
+
+            return ignite.compute().mapReduce(map, reduce, "Hi Alice");
+        }).then(function(res) {
+            assert.equal(res, 7);
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    })
 }
 
 testComputeAllNodeExecute = function() {
-    TestUtils.startIgniteNode(computeAllNodeExecute);
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.putAll(getEntries()).then(function(res) {
+            var map = function(nodes, arg) {
+                for (var i = 0; i < nodes.length; i++) {
+                    var f = function (node) {
+                        print(">>> Printing " + node.id().toString());
+
+                        return "";
+                    };
+
+                    emit(f, nodes[i %  nodes.length], nodes[i %  nodes.length]);
+                }
+            };
+
+            var reduce = function(results) {};
+
+            return ignite.compute().mapReduce(map, reduce, "");
+        }).then(function(res) {
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    })
 }
 
 testComputeCacheSizeExecute = function() {
-    TestUtils.startIgniteNode(computeCacheSizeExecute);
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        cache.put("key", "val").then(function(res) {
+            var map = function(nodes, arg) {
+                for (var i = 0; i < nodes.length; i++) {
+                    var f = function (args) {
+                        print("!!!!!Node id " + ignite.localNode().id());
+
+                        return ignite.cache("mycache").localSize();
+                    };
+
+                    emit(f, [1, 2], nodes[i]);
+                }
+            };
+
+            var reduce = function(results) {
+                var sum = 0;
+
+                for (var i = 0; i < results.length; i++) {
+                    sum += results[i];
+                }
+
+                return sum;
+            };
+
+            return ignite.compute().mapReduce(map, reduce, "");
+        }).then(function(res) {
+            console.log("Result=" + res);
+
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    })
 }
 
 testComputeCacheExecute = function() {
-    TestUtils.startIgniteNode(computeCacheExecute);
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var cache = ignite.cache("mycache");
+
+        entries = [];
+
+        var key1 = {"name" : "Ann"};
+        var key2 = {"name" : "Paul"};
+        var val1 = {"age" : 12, "books" : ["1", "Book"]};
+        var val2 = {"age" : 13, "books" : ["1", "Book"]};
+
+        entries.push(new CacheEntry(key1, val1));
+        entries.push(new CacheEntry(key2, val2));
+
+        cache.putAll(entries).then(function(res) {
+            var map = function(nodes, args) {
+                for (var i = 0; i < 1; i++) {
+                    var f = function (args1) {
+                        ignite.cache("mycache").put({"1": "1"},  2);
+
+                        var val = ignite.cache("mycache").get({"1": "1"});
+
+                        if (val !== 2) {
+                            throw "Incorrect return val [expected=2, val=" + val + "]";
+                        }
+
+                        var val1 = ignite.cache("mycache").get(args1.get(0));
+
+                        if (val1["age"] !== 12) {
+                            throw "Incorrect age [expected=12, val=" + val + "]";
+                        }
+
+                        print("BOOKS=" + val1.books);
+
+                        if (val1.books.length !== 2) {
+                            throw "Incorrect books length [expected=2, val=" +
+                                val1.books.length + "]";
+                        }
+
+                        if (val1.books[0] !== "1") {
+                            throw "Incorrect books value [expected=1, val=" +
+                                val1.books[0] + "]";
+                        }
+                        if (val1.books[1] !== "Book") {
+                            throw "Incorrect books value [expected=Book, val=" +
+                                val1.books[1] + "]";
+                        }
+
+                        return val1;
+                    };
+
+                    emit(f, args, nodes[i]);
+                }
+            };
+
+            var reduce = function(results) {
+                return {"1" : 1};
+            };
+
+            return ignite.compute().mapReduce(map, reduce, [key1, val1]);
+        }).then(function(res) {
+            assert(TestUtils.compareObject({"1": 1}, res),
+                "Incorrect result [exp= {1:1}, val=" + res);
+
+            return cache.size();
+        }).then(function(size){
+            assert(size === 3, "Incorrect size [size=" + 3 + ", res=" + size + "]");
+            TestUtils.testDone();
+        }).catch(function (err) {
+            assert(err === null, err);
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    })
 }
 
 testComputeRunScriptContainsKey = function() {
-    function computeRunScriptContainsKey(error, ignite) {
-        assert(error == null, "Error on start:" + error);
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var initKey = {"1" : ["1", "2"]};
 
         var comp = ignite.compute();
 
@@ -58,28 +252,25 @@ testComputeRunScriptContainsKey = function() {
             return key;
         }
 
-        function onEnd(err, res) {
-            assert(err == null);
-            assert(TestUtils.compareObject(initKey, res), "Incorrect result after script.")
-
-            ignite.cache("mycache").containsKey(initKey, function(err0, res0) {
-                assert(err0 === null, "Get error on js contatins key [err=" + err0 + "]");
-                assert(res0 === true, "Incorrect value on js contains key [res=" + res0 + "]");
-                TestUtils.testDone();
-            });
-        }
-
-        var initKey = {"1" : ["1", "2"]};
+        comp.run(f, initKey).then(function(res) {
+            assert(TestUtils.compareObject(initKey, res), "Incorrect result after script.");
 
-        comp.run(f, initKey, onEnd.bind(null));
-    }
+            return ignite.cache("mycache").containsKey(initKey);
+        }).then(function(res) {
+            assert(res === true, "Incorrect value on js contains key [res=" + res + "]");
 
-    TestUtils.startIgniteNode(computeRunScriptContainsKey);
+            TestUtils.testDone();
+        }).catch(function(err) {
+            assert(err === null, err);
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    })
 }
 
 testComputeAffinityRunScriptContainsKey = function() {
-    function computeRunScriptContainsKey(error, ignite) {
-        assert(error == null, "Error on start:" + error);
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var initKey = {"1" : ["1", "2"]};
 
         var comp = ignite.compute();
 
@@ -93,28 +284,26 @@ testComputeAffinityRunScriptContainsKey = function() {
             return key;
         }
 
-        function onEnd(err, res) {
-            assert(err == null, err);
-            assert(TestUtils.compareObject(initKey, res), "Incorrect result after script.")
-
-            ignite.cache("mycache").containsKey(initKey, function(err0, res0) {
-                assert(err0 === null, "Get error on js contatins key [err=" + err0 + "]");
-                assert(res0 === true, "Incorrect value on js contains key [res=" + res0 + "]");
-                TestUtils.testDone();
-            });
-        }
-
-        var initKey = {"1" : ["1", "2"]};
+        comp.affinityRun("mycache", initKey, f, initKey).then(function(res) {
+            assert(TestUtils.compareObject(initKey, res), "Incorrect result after script.");
 
-        comp.affinityRun("mycache", initKey, f, initKey, onEnd.bind(null));
-    }
+            return ignite.cache("mycache").containsKey(initKey);
+        }).then(function(res) {
+            assert(res === true, "Incorrect value on js contains key [res=" + res + "]");
 
-    TestUtils.startIgniteNode(computeRunScriptContainsKey);
+            TestUtils.testDone();
+        }).catch(function(err) {
+            assert(err === null, err);
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    })
 }
 
 testComputeRunScriptContainsKeys = function() {
-    function computeRunScriptContainsKey(error, ignite) {
-        assert(error == null, "Error on start:" + error);
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var initKey0 = {"1" : ["1", "2"]};
+        var initKey1 = {"2" : "AAA"};
 
         var comp = ignite.compute();
 
@@ -129,29 +318,29 @@ testComputeRunScriptContainsKeys = function() {
             return keys;
         }
 
-        function onEnd(err, res) {
-            assert(err == null);
+        comp.run(f, [initKey0, initKey1]).then(function(res) {
             assert(TestUtils.compareObject([initKey0, initKey1], res), "Incorrect result after script.")
 
-            ignite.cache("mycache").containsKey(initKey0, function(err0, res0) {
-                assert(err0 === null, "Get error on js contatins key [err=" + err0 + "]");
-                assert(res0 === true, "Incorrect value on js contains key [res=" + res0 + "]");
-                TestUtils.testDone();
-            });
-        }
+            return ignite.cache("mycache").containsKey(initKey0);
+        }).then(function(res) {
+            assert(res === true, "Incorrect value on js contains key [res=" + res + "]");
 
-        var initKey0 = {"1" : ["1", "2"]};
-        var initKey1 = {"2" : "AAA"};
-
-        comp.run(f, [initKey0, initKey1], onEnd.bind(null));
-    }
-
-    TestUtils.startIgniteNode(computeRunScriptContainsKey);
+            TestUtils.testDone();
+        }).catch(function(err) {
+            assert(err === null, err);
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    })
 }
 
 testComputeRunScriptPutAllGetAll = function() {
-    function computeRunScriptPutAllGetAll(error, ignite) {
-        assert(error == null, "Error on start:" + error);
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var initKey0 = {"1" : ["1", "2"]};
+        var initKey1 = {"2" : "AAA"};
+        var initVal0 = {"1" : ["1", "2"]};
+        var initVal1 = {"2" : "AAA"};
+        var initEntries = [new CacheEntry(initKey0, initVal0), new CacheEntry(initKey1, initVal1)];
 
         var comp = ignite.compute();
 
@@ -163,281 +352,121 @@ testComputeRunScriptPutAllGetAll = function() {
             return cache.getAll(args[1]);
         }
 
-        function onEnd(err, res) {
-            assert(err == null);
-
+        comp.run(f, [initEntries, [initKey0, initKey1]]).then(function(res) {
             assert(TestUtils.compareObject(initEntries[0].key, res[0].key), "Incorrect result after script " +
                 "[InitEntries=" + JSON.stringify(initEntries[0].key) + ", val=" + JSON.stringify(res[0].key) + "]");
 
-            ignite.cache("mycache").containsKey(initKey0, function(err0, res0) {
-                assert(err0 === null, "Get error on js contatins key [err=" + err0 + "]");
-                assert(res0 === true, "Incorrect value on js contains key [res=" + res0 + "]");
-                TestUtils.testDone();
-            });
-        }
+            return ignite.cache("mycache").containsKey(initKey0);
+        }).then(function(res) {
+            assert(res === true, "Incorrect value on js contains key [res=" + res + "]");
 
-        var initKey0 = {"1" : ["1", "2"]};
-        var initKey1 = {"2" : "AAA"};
-        var initVal0 = {"1" : ["1", "2"]};
-        var initVal1 = {"2" : "AAA"};
-        var initEntries = [new CacheEntry(initKey0, initVal0), new CacheEntry(initKey1, initVal1)];
-
-        comp.run(f, [initEntries, [initKey0, initKey1]],
-            onEnd.bind(null));
-    }
-
-    TestUtils.startIgniteNode(computeRunScriptPutAllGetAll);
+            TestUtils.testDone();
+        }).catch(function(err) {
+            assert(err === null, err);
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    })
 }
 
 testComputeRunScriptRemoveOperations = function() {
-    computeRunScriptRemoveOperations = function(error, ignite) {
-        assert(error === null, "Error on put:" + error);
-
-        var comp = ignite.compute();
-
-        var f = function (args) {
-            var cache = ignite.cache("mycache");
-
-            if (cache.remove("key1") === true) {
-                throw "Incorrect remove from empty map";
-            }
-
-            var key0 = {"keyName" : "keyVal"};
-            var key1 = {"keyName" : "keyVal1"};
-            var val0 = {"valName" : 1};
-            var val1 = {"valName" : 2};
-
-            var entries = [new CacheEntry(key0, val0), new CacheEntry(key1, val1)];
-            var keys = [key0, key1];
-
-            cache.put(key0, val0);
-
-            if (cache.removeValue(key0, val1) === true) {
-                throw "Incorrect removeValue from empty map [key=" + JSON.stringify(key0) + "]";
-            }
-
-            if (cache.remove(key0) === false) {
-                throw "Incorrect remove from empty map [key=" + JSON.stringify(key0) + "]";
-            }
-
-            cache.put(key0, val0);
-
-            if (cache.replaceValue(key0, val0, val1) === true) {
-                throw "Incorrect replaceValue result [key=" + JSON.stringify(key0) + "]";
-            }
-
-            var prevVal = cache.getAndReplace(key0, val1);
-
-            if (prevVal.valName !== val0.valName) {
-                throw "Incorrect getAndReplace result [key=" + JSON.stringify(key0) +
-                 ", prevVal=" + prevVal.valName +
-                 ", expected=" + val0.valName + "]";
-            }
+    var f = function(args) {
+        var cache = ignite.cache("mycache");
 
-            prevVal = cache.get(key0);
-
-            if (prevVal.valName !== val1.valName) {
-                throw "Incorrect getAndReplace result [key=" + JSON.stringify(key0) + "]";
-            }
-
-            cache.removeAllFromCache();
-
-            if (cache.get(key0) !== null) {
-                throw "Incorrect removeAll result";
-            }
-
-            cache.putAll(entries);
-
-            if (cache.replace(key1, val0) !== true) {
-                throw "Incorrect replace result";
-            }
+        if (cache.remove("key1") === true) {
+            throw "Incorrect remove from empty map";
+        }
 
-            prevVal = cache.get(key1);
+        var key0 = {"keyName" : "keyVal"};
+        var key1 = {"keyName" : "keyVal1"};
+        var val0 = {"valName" : 1};
+        var val1 = {"valName" : 2};
 
-            if (prevVal.valName !== val0.valName) {
-                throw "Incorrect replace [key=" + JSON.stringify(key1) + "]";
-            }
+        var entries = [new CacheEntry(key0, val0), new CacheEntry(key1, val1)];
+        var keys = [key0, key1];
 
-            cache.removeAll(keys);
+        cache.put(key0, val0);
 
-            if (cache.size() !== 0) {
-                throw "Incorrect removeAll result.";
-            }
+        if (cache.removeValue(key0, val1) === true) {
+            throw "Incorrect removeValue from empty map [key=" + JSON.stringify(key0) + "]";
         }
 
-        function onEnd(err, res) {
-            assert(err == null);
-
-            TestUtils.testDone();
+        if (cache.remove(key0) === false) {
+            throw "Incorrect remove from empty map [key=" + JSON.stringify(key0) + "]";
         }
 
-        comp.run(f, [], onEnd.bind(null));
-    }
-
-    TestUtils.startIgniteNode(computeRunScriptRemoveOperations);
-}
-
-testComputeMapReduceGetAndPut = function() {
-    function computeMapReduceGetAndPut(error, ignite) {
-        assert(error == null, "Error on start:" + error);
-
-        var map = function(nodes, arg) {
-            for (var i = 0; i < nodes.length; i++) {
-                var f = function (val) {
-                    var prev = ignite.cache("mycache").getAndPutIfAbsent(val, val);
+        cache.put(key0, val0);
 
-                    if (prev !== null) {
-                        throw "Get and put if absent does not work.";
-                    }
-
-                    return val;
-                };
-
-                emit(f, i, nodes[i]);
-            }
-        };
-
-        var reduce = function(results) {
-            var sum = 0;
-
-            for (var i = 0; i < results.length; ++i) {
-                if (results.indexOf(i) === -1) {
-                    throw "Do not find " + i;
-                }
-
-                var prev = ignite.cache("mycache").getAndPut(i, i + 1);
-
-                if (prev !== i) {
-                    throw "Incorrect previous value [key=" + i + ", val=" + prev + "]";
-                }
-
-                sum += prev;
-            }
-
-            return sum;
-        };
-
-        var callback = function(err, res) {
-            assert(err == null, "Get error on compute task [err=" + err + "]");
-            assert(res === 1);
-
-            TestUtils.testDone();
+        if (cache.replaceValue(key0, val0, val1) === true) {
+            throw "Incorrect replaceValue result [key=" + JSON.stringify(key0) + "]";
         }
 
-        ignite.compute().mapReduce(map, reduce, [], callback);
-    }
+        var prevVal = cache.getAndReplace(key0, val1);
 
-    TestUtils.startIgniteNode(computeMapReduceGetAndPut);
-}
-
-testComputeMapReduceGetAndRemoveObject = function() {
-    function computeMapReduceGetAndRemove(error, ignite) {
-        assert(error == null, "Error on start:" + error);
-
-        var map = function(nodes, entries) {
-            for (var i = 0; i < entries.length; i++) {
-                var f = function (entry) {
-                    var cache = ignite.cache("mycache");
-                    print("ENTRY =" + entry);
-
-                    print("ENTRY Key=" + entry.key);
-
-                    if (cache.putIfAbsent(entry.key, entry.value) !== true) {
-                        throw "Incorrect put if absent result."
-                    }
-
-                    if (cache.putIfAbsent(entry.key, "1") !== false) {
-                        throw "Incorrect put if absent result."
-                    }
-
-                    return cache.getAndRemove(entry.key);
-                };
-
-                emit(f, entries[i], nodes[i % nodes.length]);
-            }
-        };
-
-        var reduce = function(results) {
-            var sum = 0;
-
-            for (var i = 0; i < results.length; ++i) {
-                sum += results[i].age;
-            }
-
-            return sum;
-        };
-
-        var callback = function(err, res) {
-            assert(err == null, "Get error on compute task [err=" + err + "]");
-            assert(res === 25, "Incorrect reduce result.");
-
-            TestUtils.testDone();
+        if (prevVal.valName !== val0.valName) {
+            throw "Incorrect getAndReplace result [key=" + JSON.stringify(key0) +
+             ", prevVal=" + prevVal.valName +
+             ", expected=" + val0.valName + "]";
         }
 
+        prevVal = cache.get(key0);
 
-        entries = [];
-
-        var key1 = {"name" : "Ann"};
-        var key2 = {"name" : "Paul"};
-        var val1 = {"age" : 12, "books" : ["1", "Book"]};
-        var val2 = {"age" : 13, "books" : ["1", "Book"]};
-
-        entries.push(new CacheEntry(key1, val1));
-        entries.push(new CacheEntry(key2, val2));
-
-        ignite.compute().mapReduce(map, reduce, entries, callback);
-    }
+        if (prevVal.valName !== val1.valName) {
+            throw "Incorrect getAndReplace result [key=" + JSON.stringify(key0) + "]";
+        }
 
-    TestUtils.startIgniteNode(computeMapReduceGetAndRemove);
-}
+        cache.removeAllFromCache();
 
-function onStart(onPut, error, ignite) {
-    var cache = ignite.cache("mycache");
+        if (cache.get(key0) !== null) {
+            throw "Incorrect removeAll result";
+        }
 
-    var params = [];
+        cache.putAll(entries);
 
-    for (var i = 900; i < 1000; ++i) {
-        params.push(new CacheEntry("key" + i,  "val" + i));
-    }
+        if (cache.replace(key1, val0) !== true) {
+            throw "Incorrect replace result";
+        }
 
-    cache.putAll(params, onPut.bind(null, ignite))
-}
+        prevVal = cache.get(key1);
 
-function computeRunScript(ignite, error) {
-    assert(error == null, "Error on put:" + error);
+        if (prevVal.valName !== val0.valName) {
+            throw "Incorrect replace [key=" + JSON.stringify(key1) + "]";
+        }
 
-    var comp = ignite.compute();
+        cache.removeAll(keys);
 
-    var f = function (args) {
-        print("!!!!" + args + " " + ignite.name());
-        return args + " " + ignite.name();
+        if (cache.size() !== 0) {
+            throw "Incorrect removeAll result.";
+        }
     }
 
-    function onEnd(err, res) {
-        assert(err == null);
-        assert(res.indexOf("NodeJsComputeSelfTest") !== -1, "Incorrect result message. [mes=" + res + "].");
-        assert(res.indexOf("GridGain") !== -1, "Incorrect result message. [mes=" + res + "].");
-
-        TestUtils.testDone();
-    }
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var comp = ignite.compute();
 
-    comp.run(f, "GridGain", onEnd.bind(null));
+        comp.run(f, []).then(function(res) {
+            TestUtils.testDone();
+        }).catch(function(err) {
+            assert(err === null, err);
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    });
 }
 
-function computeExecute(error, ignite) {
-    assert(error == null, "Error on put:" + error);
-
+testComputeMapReduceGetAndPut = function() {
     var map = function(nodes, arg) {
-        var words = arg.split(" ");
+        for (var i = 0; i < nodes.length; i++) {
+            var f = function (val) {
+                var prev = ignite.cache("mycache").getAndPutIfAbsent(val, val);
 
-        for (var i = 0; i < words.length; i++) {
-            var f = function (word) {
-                print(">>> Printing " + word);
+                if (prev !== null) {
+                    throw "Get and put if absent does not work.";
+                }
 
-                return word.length;
+                return val;
             };
 
-            emit(f, words[i], nodes[i %  nodes.length]);
+            emit(f, i, nodes[i]);
         }
     };
 
@@ -445,159 +474,90 @@ function computeExecute(error, ignite) {
         var sum = 0;
 
         for (var i = 0; i < results.length; ++i) {
-            sum += results[i];
-        }
-
-        return sum;
-    };
-
-    var callback = function(err, res) {
-        assert(err == null, "Get error on compute task [err=" + err + "]");
-        assert.equal(res, 7);
-
-        TestUtils.testDone();
-    }
-
-    ignite.compute().mapReduce(map, reduce, "Hi Alice", callback);
-}
-
-function computeAllNodeExecute(error, ignite) {
-    assert(error == null, "Error on put:" + error);
-
-    var map = function(nodes, arg) {
-        for (var i = 0; i < nodes.length; i++) {
-            var f = function (node) {
-                print(">>> Printing " + node.id().toString());
-
-                return "";
-            };
-
-            emit(f, nodes[i %  nodes.length], nodes[i %  nodes.length]);
-        }
-    };
-
-    var reduce = function(results) {};
-
-    var callback = function(err, res) {
-        assert(err == null, "Get error on compute task [err=" + err + "]");
-        TestUtils.testDone();
-    }
-
-    ignite.compute().mapReduce(map, reduce, "", callback);
-}
-
-function computeCacheExecute(error, ignite) {
-    assert(error == null, "Error on put:" + error);
-
-    var map = function(nodes, args) {
-        for (var i = 0; i < 1; i++) {
-            var f = function (args1) {
-                ignite.cache("mycache").put({"1": "1"},  2);
-
-                var val = ignite.cache("mycache").get({"1": "1"});
-
-                if (val !== 2) {
-                    throw "Incorrect return val [expected=2, val=" + val + "]";
-                }
-
-                var val1 = ignite.cache("mycache").get(args1.get(0));
-
-                if (val1["age"] !== 12) {
-                    throw "Incorrect age [expected=12, val=" + val + "]";
-                }
-
-                print("BOOKS=" + val1.books);
-
-                if (val1.books.length !== 2) {
-                    throw "Incorrect books length [expected=2, val=" +
-                        val1.books.length + "]";
-                }
+            if (results.indexOf(i) === -1) {
+                throw "Do not find " + i;
+            }
 
-                if (val1.books[0] !== "1") {
-                    throw "Incorrect books value [expected=1, val=" +
-                        val1.books[0] + "]";
-                }
-                if (val1.books[1] !== "Book") {
-                    throw "Incorrect books value [expected=Book, val=" +
-                        val1.books[1] + "]";
-                }
+            var prev = ignite.cache("mycache").getAndPut(i, i + 1);
 
-                return val1;
-            };
+            if (prev !== i) {
+                throw "Incorrect previous value [key=" + i + ", val=" + prev + "]";
+            }
 
-            emit(f, args, nodes[i]);
+            sum += prev;
         }
-    };
 
-    var reduce = function(results) {
-        return {"1" : 1};
+        return sum;
     };
 
-    var callback = function(err, res) {
-        assert(err == null, "Get error on compute task [err=" + err + "]");
-
-        assert(TestUtils.compareObject({"1": 1}, res),
-            "Incorrect result [exp= {1:1}, val=" + res);
+    TestUtils.startIgniteNode().then(function(ignite) {
+        ignite.compute().mapReduce(map, reduce, []).then(function(res) {
+            assert(res === 1);
 
-        ignite.cache("mycache").size(function(err, size){
-            assert(size === 3, "Incorrect size [size=" + 3 + ", res=" + size + "]");
             TestUtils.testDone();
+        }).catch(function(err) {
+            assert(err === null, err);
         })
-    }
-
-    entries = [];
-
-    var key1 = {"name" : "Ann"};
-    var key2 = {"name" : "Paul"};
-    var val1 = {"age" : 12, "books" : ["1", "Book"]};
-    var val2 = {"age" : 13, "books" : ["1", "Book"]};
-
-    entries.push(new CacheEntry(key1, val1));
-    entries.push(new CacheEntry(key2, val2));
-
-    ignite.cache("mycache").putAll(entries, function(err) {
-        ignite.compute().mapReduce(map, reduce, [key1, val1], callback);
+    }).catch(function(err) {
+        assert(err === null, err);
     });
 }
 
-function computeCacheSizeExecute(error, ignite) {
-    assert(error == null, "Error on put:" + error);
+testComputeMapReduceGetAndRemoveObject = function() {
+    var map = function(nodes, entries) {
+        for (var i = 0; i < entries.length; i++) {
+            var f = function (entry) {
+                var cache = ignite.cache("mycache");
+                print("ENTRY =" + entry);
+
+                print("ENTRY Key=" + entry.key);
 
-    var map = function(nodes, arg) {
-        for (var i = 0; i < nodes.length; i++) {
-            var f = function (args) {
-                print("!!!!!Node id " + ignite.localNode().id());
+                if (cache.putIfAbsent(entry.key, entry.value) !== true) {
+                    throw "Incorrect put if absent result."
+                }
 
-                return ignite.cache("mycache").localSize();
+                if (cache.putIfAbsent(entry.key, "1") !== false) {
+                    throw "Incorrect put if absent result."
+                }
+
+                return cache.getAndRemove(entry.key);
             };
 
-            emit(f, [1, 2], nodes[i]);
+            emit(f, entries[i], nodes[i % nodes.length]);
         }
     };
 
     var reduce = function(results) {
         var sum = 0;
 
-        for (var i = 0; i < results.length; i++) {
-            sum += results[i];
+        for (var i = 0; i < results.length; ++i) {
+            sum += results[i].age;
         }
 
         return sum;
     };
 
-    var callback = function(err, res) {
-        assert(err == null, "Get error on compute task [err=" + err + "]");
+    TestUtils.startIgniteNode().then(function(ignite) {
+        entries = [];
+
+        var key1 = {"name" : "Ann"};
+        var key2 = {"name" : "Paul"};
+        var val1 = {"age" : 12, "books" : ["1", "Book"]};
+        var val2 = {"age" : 13, "books" : ["1", "Book"]};
+
+        entries.push(new CacheEntry(key1, val1));
+        entries.push(new CacheEntry(key2, val2));
+
+        ignite.compute().mapReduce(map, reduce, entries).then(function(res) {
+            assert(res === 25, "Incorrect reduce result.");
 
-        ignite.cache("mycache").size(function(err, size){
-            assert(size === res, "Incorrect size [size=" + size + ", res=" + res + "]");
             TestUtils.testDone();
+        }).catch(function(err) {
+            assert(err === null, err);
         })
-    }
-
-    ignite.cache("mycache").put("key", "val",
-        function(err) {
-            ignite.compute().mapReduce(map, reduce, "", callback);
-        });
+    }).catch(function(err) {
+        assert(err === null, err);
+    });
 }
 
 testComputeFuncWithErrorExecute = function() {
@@ -641,18 +601,28 @@ testComputeIncorrectMapExecute = function() {
 }
 
 function testComputeWithErrors(map) {
-    function computeErrorExecute(error, ignite) {
-        var callback = function(err, res) {
-            assert(err != null, "Do not get error on compute task.");
-
+    TestUtils.startIgniteNode().then(function(ignite) {
+        ignite.compute().mapReduce(map, function (args) {}, "Hi Alice").then(function(res) {
+            assert(false, "Do not get an error.");
+        }).catch(function(err) {
+            assert(err !== null, err);
             assert(err.indexOf("Function evaluation failed") > -1, "Incorrect error "+
                 "[expected=function evaluation failed, value=" + err + "]");
 
             TestUtils.testDone();
-        }
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    });
+}
 
-        ignite.compute().mapReduce(map, function (args) {}, "Hi Alice", callback);
+
+function getEntries() {
+    var params = [];
+
+    for (var i = 900; i < 1000; ++i) {
+        params.push(new CacheEntry("key" + i,  "val" + i));
     }
 
-    TestUtils.startIgniteNode(computeErrorExecute);
-}
+    return params;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8616eebb/modules/nodejs/src/test/js/test-ignite.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-ignite.js b/modules/nodejs/src/test/js/test-ignite.js
index 29501d7..e7cb604 100644
--- a/modules/nodejs/src/test/js/test-ignite.js
+++ b/modules/nodejs/src/test/js/test-ignite.js
@@ -20,47 +20,36 @@ var TestUtils = require("./test-utils").TestUtils;
 var assert = require("assert");
 
 testIgniteVersion = function() {
-    function igniteVer(err, res) {
-        assert.equal(err, null);
-
+    TestUtils.startIgniteNode().then(function(ignite) {
+        return ignite.version();
+    }).then(function(res) {
         var verRegex = /([0-9]+)\.([0-9]+)\.([0-9]+)/;
 
         assert(verRegex.exec(res) !== null, "Incorrect ignite version [ver=" + res + "]");
 
         TestUtils.testDone();
-    }
-
-    function onStart(err, ignite) {
-        assert.equal(err, null);
-
-        ignite.version(igniteVer.bind(null));
-    }
-
-    TestUtils.startIgniteNode(onStart.bind(null));
+    }).catch(function (err) {
+        assert(err === null, err);
+    });
 }
 
 testIgniteName = function() {
-    function igniteName(err, res) {
-        assert.equal(err, null);
+    TestUtils.startIgniteNode().then(function(ignite) {
+        return ignite.name();
+    }).then(function(res) {
         assert(res.indexOf("NodeJsIgniteSelfTest") > -1, "Incorrect ignite name [ver=" + res + "]");
 
         TestUtils.testDone();
-    }
-
-    function onStart(err, ignite) {
-        assert.equal(err, null);
-
-        ignite.name(igniteName.bind(null));
-    }
-
-    TestUtils.startIgniteNode(onStart.bind(null));
+    }).catch(function (err) {
+        assert(err === null, err);
+    });
 }
 
 testCluster = function() {
-    function igniteCluster(err, res) {
-        assert.equal(err, null);
+    TestUtils.startIgniteNode().then(function(ignite) {
+        return ignite.cluster();
+    }).then(function(res) {
         assert(res.length > 0);
-
         assert(res[0].nodeId() !== null)
 
         var attrs = res[0].attributes();
@@ -69,49 +58,34 @@ testCluster = function() {
         assert(attrs["os.version"] !== null, "Not correct node attributes [attr=" + res[0].attributes() + "]");
 
         TestUtils.testDone();
-    }
-
-    function onStart(err, ignite) {
-        assert.equal(err, null);
-
-        ignite.cluster(igniteCluster.bind(null));
-    }
-
-    TestUtils.startIgniteNode(onStart.bind(null));
+    }).catch(function (err) {
+        assert(err === null, err);
+    });
 }
 
 testDestroyCache = function() {
     var cacheName = "NEW_CACHE";
 
-    function onErrorPut(err) {
-        assert(err !== null);
-
-        TestUtils.testDone();
-    }
-
-    function onDestroy(cache, err) {
+    TestUtils.startIgniteNode().then(function(ignite) {
+        ignite.getOrCreateCache(cacheName).then(function(cache) {
+            return cache.put("1", "1");
+        }).then(function() {
+            return ignite.destroyCache(cacheName);
+        }).then(function() {
+            var cache0 = ignite.cache(cacheName);
+
+            cache0.put("1", "1").then(function() {
+                assert(false, "Do not get an error.");
+            }).catch(function(err){
+                assert(err !== null, "Do nto get an error");
+                assert(err.indexOf("Failed to find cache for given cache name") > -1, "Incorrect error message: " + err);
+
+                TestUtils.testDone();
+            });
+        }).catch(function(err) {
+            assert(err === null, err);
+        })
+    }).catch(function (err) {
         assert(err === null, err);
-
-        cache.put("1", "1", onErrorPut);
-    }
-
-    function onPut(ignite, cache, err) {
-        assert(err === null, err);
-
-        ignite.destroyCache(cacheName, onDestroy.bind(null, cache));
-    }
-
-    function onGetOrCreateCache(ignite, err, cache) {
-        assert(err === null, err);
-
-        cache.put("1", "1", onPut.bind(null, ignite, cache));
-    }
-
-    function onStart(err, ignite) {
-        assert.equal(err, null);
-
-        ignite.getOrCreateCache(cacheName, onGetOrCreateCache.bind(null, ignite));
-    }
-
-    TestUtils.startIgniteNode(onStart.bind(null));
+    });
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8616eebb/modules/nodejs/src/test/js/test-ignition.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-ignition.js b/modules/nodejs/src/test/js/test-ignition.js
index fd80e61..9e98d41 100644
--- a/modules/nodejs/src/test/js/test-ignition.js
+++ b/modules/nodejs/src/test/js/test-ignition.js
@@ -23,70 +23,44 @@ var Ignition = Ignite.Ignition;
 var assert = require("assert");
 
 testIgnitionFail = function ()  {
-    Ignition.start(['127.0.0.3:9091', '127.0.0.1:9092'], null, onConnect);
+    Ignition.start(['127.0.0.3:9091', '127.0.0.1:9092'], null).then(function(ignite) {
+        assert(false, "Do not get an error.")
+    }).catch(function(err){
+        assert(err !== null);
+        assert(err.indexOf("Cannot connect to servers.") > -1, "Incorrect error message: " + err);
 
-    function onConnect(error, server) {
-        if (error) {
-            if (error.indexOf("Cannot connect to servers.") == -1) {
-                TestUtils.testFails("Incorrect error message: " + error);
-            }
-            else {
-                TestUtils.testDone();
-            }
-
-            return;
-        }
-
-        TestUtils.testFails("Test should fail.");
-    }
+        TestUtils.testDone();
+    });
 }
 
-ignitionStartSuccess = function() {
-    Ignition.start(['127.0.0.0:9095', '127.0.0.1:9095'], null, onConnect);
-
-    function onConnect(error, server) {
-        if (error) {
-          TestUtils.testFails(error);
-
-          return;
-        }
-
+testIgnitionStartSuccess = function() {
+    Ignition.start(['127.0.0.0:9095', '127.0.0.1:9095'], null).then(function(ignite) {
         TestUtils.testDone();
-    }
+    }).catch(function(err){
+        assert(err === null);
+    });
 }
 
-ignitionStartSuccessWithSeveralPorts = function() {
-    Ignition.start(['127.0.0.1:9090..9100'], null, onConnect);
-
-    function onConnect(error, ignite) {
-        if (error) {
-            TestUtils.testFails(error);
-
-            return;
-        }
-
+testIgnitionStartSuccessWithSeveralPorts = function() {
+    Ignition.start(['127.0.0.1:9090..9100'], null).then(function(ignite) {
         var server = ignite.server();
-
         var host = server.host();
 
-        assert.ok(host.indexOf('127.0.0.1') !== -1, "Incorrect host.");
+        assert(host.indexOf('127.0.0.1') !== -1, "Incorrect host.");
 
         TestUtils.testDone();
-    }
+    }).catch(function(err){
+        assert(err === null);
+    });
 }
 
-ignitionNotStartWithSeveralPorts = function() {
-    Ignition.start(['127.0.0.1:9090...9100'], null, onConnect);
-
-    function onConnect(error, ignite) {
-        if (error) {
-            assert.ok(error.indexOf("Incorrect address format") !== -1, "Incorrect message.")
+testIgnitionNotStartWithSeveralPorts = function() {
+    Ignition.start(['127.0.0.1:9090...9100'], null).then(function(ignite) {
+        assert(false, "Do not get an error.")
+    }).catch(function(err){
+        assert(err !== null);
+        assert(err.indexOf("Incorrect address format") > -1, "Incorrect error message: " + err);
 
-            TestUtils.testDone();
-
-            return;
-        }
-
-        TestUtils.testFails("Exception should be thrown.");
-    }
+        TestUtils.testDone();
+    });
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8616eebb/modules/nodejs/src/test/js/test-key.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-key.js b/modules/nodejs/src/test/js/test-key.js
index be5888e..6ecad30 100644
--- a/modules/nodejs/src/test/js/test-key.js
+++ b/modules/nodejs/src/test/js/test-key.js
@@ -20,39 +20,37 @@ var TestUtils = require("./test-utils").TestUtils;
 var assert = require("assert");
 
 testStartWithoutKey = function() {
-    TestUtils.startIgniteNode(onIncorrectStart);
+    TestUtils.startIgniteNode().then(function(ignite) {
+        assert(false, "Do not get an error.");
+    }).catch(function (err) {
+        assert(err !== null, "Do not get an error.");
+        assert(err.indexOf("Authentication failed. Status code 401.") !== -1, "Incorrect error message: " + err);
+
+        TestUtils.testDone();
+    });
 }
 
 testStartWithKey = function() {
-    TestUtils.startIgniteNodeWithKey("secret-key", onStart);
+    TestUtils.startIgniteNodeWithKey("secret-key").then(function(ignite) {
+        assert(ignite !== null, "Cannot connect. Get null ignite.");
+        var cache = ignite.cache("mycache");
+        cache.put("key", "6").then(function(res){
+            TestUtils.testDone();
+        }).catch(function(err){
+            assert(err === null, err);
+        });
+    }).catch(function (err) {
+        assert(err === null, err);
+    });
 }
 
 testStartWithIncorrectKey = function() {
-    TestUtils.startIgniteNodeWithKey("secret-key1", onIncorrectStart);
-}
-
-function onIncorrectStart(error, ignite) {
-    assert(error != null, "Do not get authentication error");
-
-    assert(error.indexOf("Authentication failed. Status code 401.") !== -1, "Incorrect error message: " + error);
-
-    TestUtils.testDone();
-}
-
-function onStart(error, ignite) {
-    assert(error === null, "Get error: " + error);
-
-    assert(ignite !== null, "Cannot connect. Get null ignite.");
-
-    var cache = ignite.cache("mycache");
-
-    assert(cache !== null, "Cache is null.")
-
-    cache.put("key", "6", onPut);
-}
-
-function onPut(error) {
-    assert(error === null, "Error on put:" + error);
-
-    TestUtils.testDone();
+    TestUtils.startIgniteNodeWithKey("secret-key1").then(function(ignite) {
+        assert(false, "Do not get an error.");
+    }).catch(function (err) {
+        assert(err !== null, "Do not get an error.");
+        assert(err.indexOf("Authentication failed. Status code 401.") !== -1, "Incorrect error message: " + err);
+
+        TestUtils.testDone();
+    });
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8616eebb/modules/nodejs/src/test/js/test-query.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-query.js b/modules/nodejs/src/test/js/test-query.js
index a86c057..dcbb310 100644
--- a/modules/nodejs/src/test/js/test-query.js
+++ b/modules/nodejs/src/test/js/test-query.js
@@ -24,62 +24,107 @@ var SqlQuery = Ignite.SqlQuery;
 var SqlFieldsQuery = Ignite.SqlFieldsQuery;
 
 testSqlQuery = function() {
-    function sqlQuery(ignite, error) {
-        assert(error == null, "error on sql query [err=" + error + "]");
+    TestUtils.startIgniteNode().then(function(ignite) {
+        ignite.cache("mycache").put("key0", "val0").then(function() {
+            var qry = new SqlQuery("select * from String");
 
-        var qry = new SqlQuery("select * from String");
+            qry.setReturnType("String");
 
-        qry.setReturnType("String");
+            var fullRes = [];
 
-        var fullRes = [];
-
-        qry.on("page", function(res) {
-            fullRes = fullRes.concat(res);
-        });
+            function onQuery(cursor) {
+                var page = cursor.page();
 
-        qry.on("end", function(err) {
-            assert(err === null, "Error on query [err=" + err + "].");
+                fullRes = fullRes.concat(page);
 
-            assert(fullRes.length === 1, "Result length is not correct" +
-                "[expected=1, val = " + fullRes.length + "]");
+                if (cursor.isFinished()) {
+                    assert(fullRes.length === 1, "Result length is not correct" +
+                        "[expected=1, val = " + fullRes.length + "]");
 
-            assert(fullRes[0]["key"] === "key0", "Result value for key is not correct "+
-                "[expected=key0, real=" + fullRes[0]["key"] + "]");
+                    assert(fullRes[0]["key"] === "key0", "Result value for key is not correct "+
+                        "[expected=key0, real=" + fullRes[0]["key"] + "]");
 
-            assert(fullRes[0]["value"] === "val0", "Result value for key is not correct "+
-                "[expected=val0, real=" + fullRes[0]["value"] + "]");
+                    assert(fullRes[0]["value"] === "val0", "Result value for key is not correct "+
+                        "[expected=val0, real=" + fullRes[0]["value"] + "]");
 
-            TestUtils.testDone();
-        });
+                    TestUtils.testDone();
 
-        ignite.cache("mycache").query(qry);
-    }
+                    return;
+                }
 
-    function put(error, ignite) {
-        assert(error == null, "error on put [err=" + error + "]");
+                cursor.nextPage().then(onQuery);
+            }
 
-        ignite.cache("mycache").put("key0", "val0", sqlQuery.bind(null, ignite))
-    }
+            var cursor = ignite.cache("mycache").query(qry);
 
-    TestUtils.startIgniteNode(put);
+            cursor.nextPage().then(onQuery);
+        }).catch(function(err) {
+            assert(err === null, err);
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    });
 }
 
 testSqlFieldsQuery = function() {
-    function sqlFieldsQuery(error, ignite) {
-        assert(error == null, "error on sqlfields query [err=" + error + "]");
-
+    TestUtils.startIgniteNode().then(function(ignite) {
         var qry = new SqlFieldsQuery("select concat(firstName, ' ', lastName) from Person");
 
         var fullRes = [];
 
-        qry.on("page", function(res) {
-            console.log("PAGE:" + res);
-            fullRes = fullRes.concat(res);
-        });
+        function onQuery(cursor) {
+            var page = cursor.page();
+
+            fullRes = fullRes.concat(page);
+
+            if (cursor.isFinished()) {
+                assert(fullRes.length === 4, "Result length is not correct" +
+                    "[expected=1, val = " + fullRes.length + "]");
+
+                fullRes.sort();
 
-        qry.on("end", function(err) {
-            assert(err === null, "Error on query [err=" + err + "].");
+                assert(fullRes[0].indexOf("Jane Doe") > -1,
+                    "Result does not contain Jane Doe [res=" + fullRes[0] + "]");
 
+                console.log("Result: " + JSON.stringify(fullRes));
+
+                return ignite.cache("person").get("key");
+            }
+
+            return cursor.nextPage().then(onQuery);
+        }
+
+        ignite.cache("person").query(qry).nextPage().then(onQuery).then(function(){
+            TestUtils.testDone();
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    });
+}
+
+testCloseQuery = function() {
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var qry = new SqlFieldsQuery("select concat(firstName, ' ', lastName) from Person");
+
+        function onQuery(cursor) {
+            return cursor.close();
+        }
+
+        ignite.cache("person").query(qry).nextPage().then(onQuery).then(function(res){
+            TestUtils.testDone();
+        }).catch(function(err){
+            assert(err === null, err);
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    });
+}
+
+testSqlFieldsGetAllQuery = function() {
+    TestUtils.startIgniteNode().then(function(ignite) {
+        var qry = new SqlFieldsQuery("select concat(firstName, ' ', lastName) from Person");
+
+        function onQuery(fullRes) {
             assert(fullRes.length === 4, "Result length is not correct" +
                 "[expected=1, val = " + fullRes.length + "]");
 
@@ -88,19 +133,21 @@ testSqlFieldsQuery = function() {
             assert(fullRes[0].indexOf("Jane Doe") > -1,
                 "Result does not contain Jane Doe [res=" + fullRes[0] + "]");
 
-            TestUtils.testDone();
-        });
+            console.log("Result: " + JSON.stringify(fullRes));
 
-        ignite.cache("person").query(qry);
-    }
+            return ignite.cache("person").get("key");
+        }
 
-    TestUtils.startIgniteNode(sqlFieldsQuery.bind(null));
+        ignite.cache("person").query(qry).getAll().then(onQuery).then(function(){
+            TestUtils.testDone();
+        })
+    }).catch(function(err) {
+        assert(err === null, err);
+    });
 }
 
 testSqlQueryWithParams = function() {
-    function sqlQueryWithParams(error, ignite) {
-        assert(error == null, "error on sql query [err=" + error + "]");
-
+    TestUtils.startIgniteNode().then(function(ignite) {
         var qry = new SqlQuery("salary > ? and salary <= ?");
 
         qry.setReturnType("Person");
@@ -109,25 +156,31 @@ testSqlQueryWithParams = function() {
 
         var fullRes = [];
 
-        qry.on("page", function(res) {
-            fullRes = fullRes.concat(res);
-        });
+        function onQuery(cursor) {
+            var page = cursor.page();
 
-        qry.on("end", function(err) {
-            assert(err === null, "Error on query [err=" + err + "].");
+            fullRes = fullRes.concat(page);
 
-            assert(fullRes.length === 2, "Result length is not correct" +
-                "[expected=1, val = " + fullRes.length + "]");
+            if (cursor.isFinished()) {
+                assert(fullRes.length === 2, "Result length is not correct" +
+                    "[expected=1, val = " + fullRes.length + "]");
 
-            assert(((fullRes[0]["value"]["firstName"].indexOf("Jane") > -1) ||
-                (fullRes[0]["value"]["firstName"].indexOf("John") > -1)),
-                "Result does not contain Jane and John [res=" + fullRes[0]["value"]["firstName"] + "]");
+                assert(((fullRes[0]["value"]["firstName"].indexOf("Jane") > -1) ||
+                    (fullRes[0]["value"]["firstName"].indexOf("John") > -1)),
+                    "Result does not contain Jane and John [res=" + fullRes[0]["value"]["firstName"] + "]");
 
-            TestUtils.testDone();
-        });
+                console.log("Result: " + JSON.stringify(fullRes));
+
+                TestUtils.testDone();
+
+                return;
+            }
 
-        ignite.cache("person").query(qry);
-    }
+            cursor.nextPage().then(onQuery);
+        }
 
-    TestUtils.startIgniteNode(sqlQueryWithParams.bind(null));
+        ignite.cache("person").query(qry).nextPage().then(onQuery);
+    }).catch(function(err) {
+        assert(err === null, err);
+    });
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8616eebb/modules/nodejs/src/test/js/test-utils.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-utils.js b/modules/nodejs/src/test/js/test-utils.js
index 8beb3dc..bc06e72 100644
--- a/modules/nodejs/src/test/js/test-utils.js
+++ b/modules/nodejs/src/test/js/test-utils.js
@@ -149,27 +149,24 @@ TestUtils.testDone = function() {
 
 /**
  * Starts ignite node with default config
- *
- * @param {Ignition~onStart} callback Called on connect
  */
-TestUtils.startIgniteNode = function(callback) {
+TestUtils.startIgniteNode = function() {
     var Ignite = require(TestUtils.scriptPath());
     var Ignition = Ignite.Ignition;
 
-    Ignition.start(['127.0.0.1:9095'], null, callback);
+    return Ignition.start(['127.0.0.1:9095'], null);
 }
 
 /**
  * Starts ignite node with default config
  *
  * @param {string} secretKey Secret key
- * @param {Ignition~onStart} callback Called on connect
  */
-TestUtils.startIgniteNodeWithKey = function(secretKey, callback) {
+TestUtils.startIgniteNodeWithKey = function(secretKey) {
     var Ignite = require(TestUtils.scriptPath());
     var Ignition = Ignite.Ignition;
 
-    Ignition.start(['127.0.0.1:9095'], secretKey, callback);
+    return Ignition.start(['127.0.0.1:9095'], secretKey);
 }
 
 exports.TestUtils = TestUtils;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8616eebb/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
index 20f0a88..69108a4 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
@@ -650,6 +650,17 @@ public class GridJettyRestHandler extends AbstractHandler {
                 break;
             }
 
+            case CLOSE_SQL_QUERY: {
+                RestSqlQueryRequest restReq0 = new RestSqlQueryRequest();
+
+                restReq0.queryId(Long.parseLong((String)params.get("qryId")));
+                restReq0.cacheName((String)params.get("cacheName"));
+
+                restReq = restReq0;
+
+                break;
+            }
+
             default:
                 throw new IgniteCheckedException("Invalid command: " + cmd);
         }