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 10:51:16 UTC

incubator-ignite git commit: #nodejs: Add test put get.

Repository: incubator-ignite
Updated Branches:
  refs/heads/nodejs bfa16e5ce -> f14c06c23


#nodejs: Add test put get.


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

Branch: refs/heads/nodejs
Commit: f14c06c233097d042af784f47f93156df77703ef
Parents: bfa16e5
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jun 8 11:51:03 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jun 8 11:51:03 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/NodeJsAbstractTest.java     |  2 +-
 .../ignite/internal/NodeJsPutGetSelfTest.java   | 45 ++++++++++++++++++++
 .../apache/ignite/internal/NodeJsSelfTest.java  |  4 +-
 .../testsuites/IgniteNodeJsTestSuite.java       |  1 +
 modules/nodejs/src/test/nodejs/test_ignition.js |  4 +-
 modules/nodejs/src/test/nodejs/test_put_get.js  | 33 ++++++++++++++
 6 files changed, 84 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f14c06c2/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsAbstractTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsAbstractTest.java
index 05cd6ef..01abc22 100644
--- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsAbstractTest.java
+++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsAbstractTest.java
@@ -131,7 +131,7 @@ public class NodeJsAbstractTest extends GridCommonAbstractTest {
                         if (s.contains(SCRIPT_FINISHED))
                             readyLatch.countDown();
 
-                        if (/*s.contains("error") || s.contains("fail") || */s.contains(SCRIPT_FAILED)) {
+                        if (s.contains("assert") || s.contains(SCRIPT_FAILED)) {
                             errors.add(s);
 
                             readyLatch.countDown();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f14c06c2/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
new file mode 100644
index 0000000..3c6a819
--- /dev/null
+++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsPutGetSelfTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+/**
+ * Test node js client put/get.
+ */
+public class NodeJsPutGetSelfTest extends NodeJsAbstractTest {
+    /** Constructor. */
+    public NodeJsPutGetSelfTest() {
+        super("test_put_get.js");
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGrid(0);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPutGet() throws Exception {
+        runJsScript("testPutGet");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f14c06c2/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSelfTest.java
index 93b6fc6..e58ef72 100644
--- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSelfTest.java
+++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSelfTest.java
@@ -40,13 +40,13 @@ public class NodeJsSelfTest extends NodeJsAbstractTest {
      * @throws Exception If failed.
      */
     public void testIgnitionStart() throws Exception {
-        runJsScript("ignition_start_success");
+        runJsScript("ignitionStartSuccess");
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testIgnitionFailedStart() throws Exception {
-        runJsScript("test_ignition_fail");
+        runJsScript("testIgnitionFail");
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f14c06c2/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java b/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java
index bba1ece..73b40fe 100644
--- a/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java
+++ b/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java
@@ -32,6 +32,7 @@ public class IgniteNodeJsTestSuite extends TestSuite {
         TestSuite suite = new TestSuite("Ignite Node JS Test Suite");
 
         suite.addTest(new TestSuite(NodeJsSelfTest.class));
+        suite.addTest(new TestSuite(NodeJsPutGetSelfTest.class));
 
         return suite;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f14c06c2/modules/nodejs/src/test/nodejs/test_ignition.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/nodejs/test_ignition.js b/modules/nodejs/src/test/nodejs/test_ignition.js
index db9f9f5..f2293d0 100644
--- a/modules/nodejs/src/test/nodejs/test_ignition.js
+++ b/modules/nodejs/src/test/nodejs/test_ignition.js
@@ -1,7 +1,7 @@
 var TestUtils = require("./test_utils").TestUtils;
 var Ignition = require(TestUtils.scriptPath() + "ignition").Ignition;
 
-test_ignition_fail = function ()  {
+testIgnitionFail = function ()  {
     Ignition.start(['127.0.0.3:9091', '127.0.0.1:9092'], onConnect);
 
     function onConnect(error, server) {
@@ -18,7 +18,7 @@ test_ignition_fail = function ()  {
     }
 }
 
-ignition_start_success = function() {
+ignitionStartSuccess = function() {
     Ignition.start(['127.0.0.0:9090', '127.0.0.1:9090'], onConnect);
 
     function onConnect(error, server) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f14c06c2/modules/nodejs/src/test/nodejs/test_put_get.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/nodejs/test_put_get.js b/modules/nodejs/src/test/nodejs/test_put_get.js
new file mode 100644
index 0000000..fb59286
--- /dev/null
+++ b/modules/nodejs/src/test/nodejs/test_put_get.js
@@ -0,0 +1,33 @@
+var TestUtils = require("./test_utils").TestUtils;
+var Cache = require(TestUtils.scriptPath() + "cache").Cache;
+var Server = require(TestUtils.scriptPath() + "server").Server;
+
+testPutGet = function() {
+    var server = new Server('127.0.0.1', 9090);
+    var cache = new Cache(server, "mycache");
+    cache.put("mykey", "6", onPut.bind(null, cache));
+}
+
+function onPut(cache, error) {
+    if (error) {
+        TestUtils.testFails("Incorrect error message: " + error);
+        return;
+    }
+
+    console.log("Put finished");
+    cache.get("mykey", onGet);
+}
+
+function onGet(error, value) {
+    if (error) {
+        console.error("Failed to get " + error);
+        TestUtils.testFails("Incorrect error message: " + error);
+        return;
+    }
+
+    var assert = require("assert");
+
+    assert.equal(value, 6, "Get return incorrect value. + [expected=" + 6 + ", val=" + value + "].");
+
+    TestUtils.testDone();
+}
\ No newline at end of file