You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/06/08 14:58:05 UTC

[2/2] incubator-ignite git commit: #nodejs: add test for incorrect cache name.

#nodejs: add test for incorrect cache name.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c590202d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c590202d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c590202d

Branch: refs/heads/ignite-nodejs
Commit: c590202d57f065860147ecbae4683b5520559bc5
Parents: b7753a8
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jun 8 15:57:56 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jun 8 15:57:56 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/NodeJsPutGetSelfTest.java   |  7 +++++
 modules/nodejs/src/test/js/test-put-get.js      | 29 +++++++++++++++++---
 2 files changed, 32 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c590202d/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsPutGetSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsPutGetSelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsPutGetSelfTest.java
index 92fe258..bc0acd1 100644
--- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsPutGetSelfTest.java
+++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsPutGetSelfTest.java
@@ -42,4 +42,11 @@ public class NodeJsPutGetSelfTest extends NodeJsAbstractTest {
     public void testPutGet() throws Exception {
         runJsScript("testPutGet");
     }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testIncorrectCache() throws Exception {
+        runJsScript("testIncorrectCacheName");
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c590202d/modules/nodejs/src/test/js/test-put-get.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-put-get.js b/modules/nodejs/src/test/js/test-put-get.js
index a1dab93..b591605 100644
--- a/modules/nodejs/src/test/js/test-put-get.js
+++ b/modules/nodejs/src/test/js/test-put-get.js
@@ -23,13 +23,17 @@ var Cache = Apache.Cache;
 var Server = Apache.Server;
 
 testPutGet = function() {
-  Ignition.start(['127.0.0.1:9095'], onStart);
+  Ignition.start(['127.0.0.1:9095'], onStart.bind(null, onPut, "mycache"));
 }
 
-function onStart(error, ignite) {
-  var cache = ignite.cache("mycache");
+testIncorrectCacheName = function() {
+  Ignition.start(['127.0.0.1:9095'], onStart.bind(null, onIncorrectPut, "mycache1"));
+}
+
+function onStart(onPut1, cacheName, error, ignite) {
+  var cache = ignite.cache(cacheName);
 
-  cache.put("key", "6", onPut.bind(null, cache));
+  cache.put("key", "6", onPut1.bind(null, cache));
 }
 
 function onPut(cache, error) {
@@ -46,6 +50,7 @@ function onPut(cache, error) {
 function onGet(error, value) {
   if (error) {
     console.error("Failed to get " + error);
+
     TestUtils.testFails("Incorrect error message: " + error);
     return;
   }
@@ -55,4 +60,20 @@ function onGet(error, value) {
   assert.equal(value, 6, "Get return incorrect value. + [expected=" + 6 + ", val=" + value + "].");
 
   TestUtils.testDone();
+}
+
+function onIncorrectPut(cache, error) {
+  if (error) {
+    console.error("Failed to get " + error);
+
+    var assert = require("assert");
+
+    assert(error.indexOf("Failed to find cache for given cache name") !== -1);
+
+    TestUtils.testDone();
+
+    return;
+  }
+
+  TestUtils.testFails("Exception should be thrown.");
 }
\ No newline at end of file