ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ivasilin...@apache.org
Subject incubator-ignite git commit: #ignite-964: test put/get works
Date Thu, 02 Jul 2015 22:03:33 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-964-1 1c2fc8975 -> 91ed4f6da


#ignite-964: test put/get works


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

Branch: refs/heads/ignite-964-1
Commit: 91ed4f6da69220c746bae3aac6d066ded6f48e5c
Parents: 1c2fc89
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Fri Jul 3 01:03:48 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Fri Jul 3 01:03:48 2015 +0300

----------------------------------------------------------------------
 .../handlers/scripting/JSONCacheObject.java     | 71 ++++++++++++--------
 .../scripting/IgniteScriptProcessor.java        |  7 +-
 modules/nodejs/src/test/js/test-compute.js      | 52 +++++++-------
 3 files changed, 71 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/91ed4f6d/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/JSONCacheObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/JSONCacheObject.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/JSONCacheObject.java
index ec19c50..7264f16 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/JSONCacheObject.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/JSONCacheObject.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.rest.handlers.scripting;
 
 import jdk.nashorn.api.scripting.JSObject;
+import org.apache.ignite.internal.util.typedef.internal.U;
 
 import java.util.*;
 
@@ -25,7 +26,7 @@ import java.util.*;
  * Json cache object.
  */
 public class JSONCacheObject implements JSObject {
-    Map <Object, Object> fields = new HashMap<Object, Object>();
+    Map<Object, Object> fields = new HashMap();
     /**
      * Empty constructor.
      */
@@ -47,6 +48,7 @@ public class JSONCacheObject implements JSObject {
     @Override public boolean equals(Object obj) {
         if (obj == null || !(obj instanceof JSONCacheObject))
             return false;
+
         return fields.equals(((JSONCacheObject)obj).fields);
     }
 
@@ -91,98 +93,113 @@ public class JSONCacheObject implements JSObject {
             for (Object v : o1)
                 val.add(toSimpleObject(v));
 
-            return val;
+            return val.toArray();
         }
 
         return o;
     }
 
     @Override public Object call(Object o, Object... objects) {
+        System.out.println("!!!!CALL");
         return null;
     }
 
     @Override public Object newObject(Object... objects) {
+        System.out.println("!!!!newObject");
         return null;
     }
 
     @Override public Object eval(String s) {
+        System.out.println("!!!!eval");
         return null;
     }
 
     @Override public Object getMember(String s) {
+        System.out.println("!!!!getMember + " + s);
         return fields.get(s);
     }
 
     @Override public Object getSlot(int i) {
+        System.out.println("!!!!getSlot");
         return null;
     }
 
     @Override public boolean hasMember(String s) {
+        System.out.println("!!!!hasMember");
         return fields.containsKey(s);
     }
 
     @Override
     public boolean hasSlot(int i) {
+        System.out.println("!!!!hasSlot");
         return false;
     }
 
-    @Override
-    public void removeMember(String s) {
+    @Override public void removeMember(String s) {
+        System.out.println("!!!!removeMember");
+        fields.remove(s);
+    }
 
+    @Override public void setMember(String s, Object o) {
+        System.out.println("!!!!setMember");
+        fields.put(s, o);
     }
 
-    @Override
-    public void setMember(String s, Object o) {
+    @Override public void setSlot(int i, Object o) {
+        System.out.println("!!!!setSlot");
 
     }
 
-    @Override
-    public void setSlot(int i, Object o) {
+    @Override public Set<String> keySet() {
+        System.out.println("!!!!keySet");
+        Set<String> keys = new HashSet<>();
 
-    }
+        for (Object o : keys) {
+            if (!(o instanceof JSONCacheObject))
+                keys.add(o.toString());
+        }
 
-    @Override
-    public Set<String> keySet() {
-        return null;
+        return keys;
     }
 
-    @Override
-    public Collection<Object> values() {
+    @Override public Collection<Object> values() {
+        System.out.println("!!!!values");
         return fields.values();
     }
 
     @Override
     public boolean isInstance(Object o) {
+        System.out.println("!!!!isInstance");
         return false;
     }
 
-    @Override
-    public boolean isInstanceOf(Object o) {
+    @Override public boolean isInstanceOf(Object o) {
+        System.out.println("!!!!isInstanceOf");
         return false;
     }
 
-    @Override
-    public String getClassName() {
-        return null;
+    @Override public String getClassName() {
+        System.out.println("!!!!getClassName");
+        return U.getSimpleName(JSONCacheObject.class);
     }
 
-    @Override
-    public boolean isFunction() {
+    @Override public boolean isFunction() {
+        System.out.println("!!!!isFunction");
         return false;
     }
 
-    @Override
-    public boolean isStrictFunction() {
+    @Override public boolean isStrictFunction() {
+        System.out.println("!!!!isStrictFunction");
         return false;
     }
 
-    @Override
-    public boolean isArray() {
+    @Override public boolean isArray() {
+        System.out.println("!!!!isArray");
         return false;
     }
 
-    @Override
-    public double toNumber() {
+    @Override public double toNumber() {
+        System.out.println("!!!!toNumber");
         return 0;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/91ed4f6d/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
index 6248695..950c956 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
@@ -63,7 +63,6 @@ public class IgniteScriptProcessor extends GridProcessorAdapter {
 
         String internalJSCall = "function __internalJSCall(funcSource, arg1, arg2) { " +
                 "var func = __createJSFunction(funcSource); " +
-                "println('INIT arg=' + arg1);"+
                 "return func.apply(null, [JSON.parse(arg1), arg2]); }";
 
         addEngineFunction(createJSFunction);
@@ -137,10 +136,12 @@ public class IgniteScriptProcessor extends GridProcessorAdapter {
             return invocable.invokeFunction("__internalCall", src, arg, arg2);
         }
         catch (ScriptException e) {
-            throw new IgniteCheckedException("Function evaluation failed [funcName=" + src
+ "].");
+            throw new IgniteCheckedException("Function evaluation failed [funcName=" + src
+
+                    ", err= " + e.getMessage() + "].");
         }
         catch (NoSuchMethodException e) {
-            throw new IgniteCheckedException("Cannot find function [func=__internalCall].");
+            throw new IgniteCheckedException("Cannot find function [func=__internalCall"
+
+                    ", err= " + e.getMessage() + "].");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/91ed4f6d/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 1cd17ad..0999748 100644
--- a/modules/nodejs/src/test/js/test-compute.js
+++ b/modules/nodejs/src/test/js/test-compute.js
@@ -143,38 +143,37 @@ function computeCacheExecute(error, ignite) {
     var map = function(nodes, args) {
         for (var i = 0; i < 1; i++) {
             var f = function (args1) {
-                print("IN FUNCTION");
-
                 ignite.cache("mycache").put({"1": "1"},  2);
 
-                print("PUT 1:1");
-
                 var val = ignite.cache("mycache").get({"1": "1"});
 
-
-                print("Get 1:1");
-
-
-                print("GET 1,1 = " + val);
+                if (val !== 2) {
+                    throw "Incorrect return val [expected=2, val=" + val + "]";
+                }
 
                 var val1 = ignite.cache("mycache").get(args1.get(0));
 
-                print("GET 1,2 = " + val1);
-                print("GET TYPE=" + (typeof val1));
+                if (val1["age"] !== 12) {
+                    throw "Incorrect age [expected=12, val=" + val + "]";
+                }
 
-                print("GET TYPE AGE=" + (val1["age"]));
-                print("GET TYPE AGE2=" + (val1.age));
+                print("BOOKS=" + val1.books);
 
-                var jsArgs = JSON.parse(args1);
-                print("!!!!jsArgs " + JSON.stringify(jsArgs[0]));
-                println("ARG0=" + args1.get(0));
-                var cacheO = new org.apache.ignite.internal.processors.rest.protocols.http.jetty.JSONCacheObject(args1.get(0));
-                println("CACHE OBJ= " + cacheO);
-                var o =  ignite.cache("mycache").get(cacheO);
+                if (val1.books.length !== 2) {
+                    throw "Incorrect books length [expected=2, val=" +
+                        val1.books.length + "]";
+                }
 
-                println("!!!!!!!o" + o);
+                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 o;
+                return val1;
             };
 
             emit(f, args, nodes[i]);
@@ -188,15 +187,10 @@ function computeCacheExecute(error, ignite) {
     var callback = function(err, res) {
         assert(err == null, "Get error on compute task [err=" + err + "]");
 
-        console.log("RESULT:" + res + "; keys=" + Object.keys(res));
-        console.log("key:" + res["BB"]);
-        console.log("key:" + res.BB);
-
+        assert(TestUtils.compareObject({"1": 1}, res),
+            "Incorrect result [exp= {1:1}, val=" + res);
 
-        ignite.cache("mycache").size(function(err, size){
-            assert(size === res, "Incorrect size [size=" + size + ", res=" + res + "]");
-            TestUtils.testDone();
-        })
+        TestUtils.testDone();
     }
 
     entries = [];


Mime
View raw message