ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [11/50] [abbrv] ignite git commit: IGNITE-7777: Implemented Ignite NodeJs thin client
Date Mon, 02 Jul 2018 12:51:39 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/c56d16fb/modules/platforms/nodejs/spec/cache/BinaryObject.spec.js
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/spec/cache/BinaryObject.spec.js b/modules/platforms/nodejs/spec/cache/BinaryObject.spec.js
new file mode 100644
index 0000000..0442510
--- /dev/null
+++ b/modules/platforms/nodejs/spec/cache/BinaryObject.spec.js
@@ -0,0 +1,176 @@
+/*
+ * 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.
+ */
+
+'use strict';
+
+require('jasmine-expect');
+
+const Util = require('util');
+const TestingHelper = require('../TestingHelper');
+const IgniteClient = require('apache-ignite-client');
+const ObjectType = IgniteClient.ObjectType;
+const MapObjectType = IgniteClient.MapObjectType;
+const ComplexObjectType = IgniteClient.ComplexObjectType;
+const BinaryObject = IgniteClient.BinaryObject;
+
+const CACHE_NAME = '__test_cache';
+
+describe('binary object test suite >', () => {
+    let igniteClient = null;
+    const typeName = 'TestClass1';
+    const stringValue = 'abc';
+    const doubleValue = 123.45;
+    const boolValue = false;
+    const intValue = 456;
+    const dateValue = new Date();
+
+    beforeAll((done) => {
+        Promise.resolve().
+            then(async () => {
+                await TestingHelper.init();
+                igniteClient = TestingHelper.igniteClient;
+                await testSuiteCleanup(done);
+                await igniteClient.getOrCreateCache(CACHE_NAME);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    }, TestingHelper.TIMEOUT);
+
+    afterAll((done) => {
+        Promise.resolve().
+            then(async () => {
+                await testSuiteCleanup(done);
+                await TestingHelper.cleanUp();
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    }, TestingHelper.TIMEOUT);
+
+    it('binary objects set get fields', (done) => {
+        Promise.resolve().
+            then(async () => {
+                const cache = igniteClient.getCache(CACHE_NAME).setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER);
+                try {
+                    const obj1 = new BinaryObject(typeName);
+                    obj1.setField('field_double', doubleValue);
+                    obj1.setField('field_string', stringValue);
+
+                    await cache.put(2, obj1);
+                    await cache.put(3, obj1);
+                    const obj2 = await cache.get(2);
+                    expect(await TestingHelper.compare(obj1, obj2)).toBe(true);
+
+                    const obj3 = await cache.get(3);
+                    obj2.setField('field_double', await obj1.getField('field_double'));
+                    obj2.setField('field_string', await obj1.getField('field_string'));
+                    expect(await TestingHelper.compare(obj1, obj2)).toBe(true);
+
+                    obj1.setField('field_double', await obj3.getField('field_double'));
+                    obj1.setField('field_string', await obj3.getField('field_string'));
+                    expect(await TestingHelper.compare(obj1, obj3)).toBe(true);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('binary object remove field', (done) => {
+        Promise.resolve().
+            then(async () => {
+                const cache = igniteClient.getCache(CACHE_NAME).setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER);
+                try {
+                    const obj1 = new BinaryObject(typeName);
+                    obj1.setField('field_double', doubleValue);
+                    obj1.setField('field_string', stringValue);
+                    obj1.setField('field_bool', boolValue);
+                    expect(obj1.hasField('field_bool')).toBe(true);
+                    expect(await obj1.getField('field_bool')).toBe(boolValue);
+
+                    obj1.removeField('field_bool');
+                    expect(obj1.hasField('field_bool')).toBe(boolValue);
+                    expect(await obj1.getField('field_bool')).toBe(undefined);
+
+                    await cache.put(3, obj1);
+                    const obj2 = await cache.get(3);
+                    expect(await TestingHelper.compare(obj1, obj2)).toBe(true);
+
+                    obj2.setField('field_bool', boolValue);
+                    expect(obj2.hasField('field_bool')).toBe(true);
+                    expect(await obj2.getField('field_bool')).toBe(boolValue);
+
+                    obj2.removeField('field_bool');
+                    expect(obj2.hasField('field_bool')).toBe(boolValue);
+                    expect(await obj2.getField('field_bool')).toBe(undefined);
+
+                    obj2.setField('field_bool', boolValue);
+                    await cache.put(4, obj2);
+
+                    obj1.setField('field_bool', boolValue);
+                    await cache.put(5, obj1);
+
+                    expect(await TestingHelper.compare(await cache.get(4), await cache.get(5))).toBe(true);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('binary objects of different schemas', (done) => {
+        Promise.resolve().
+            then(async () => {
+                const cache = igniteClient.getCache(CACHE_NAME).setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER);
+                try {
+                    const obj1 = new BinaryObject(typeName);
+                    obj1.setField('field_int', intValue, ObjectType.PRIMITIVE_TYPE.INTEGER);
+                    obj1.setField('field_string', stringValue);
+                    obj1.setField('field_bool', false);
+                    await cache.put(1, obj1);
+
+                    const obj2 = new BinaryObject(typeName);
+                    obj2.setField('field_int', intValue, ObjectType.PRIMITIVE_TYPE.INTEGER);
+                    obj2.setField('field_bool', false);
+                    obj2.setField('field_date', dateValue);
+                    await cache.put(2, obj2);
+
+                    const obj3 = await cache.get(1, obj1);
+                    obj3.removeField('field_string');
+                    const obj4 = await cache.get(2, obj1);
+                    obj4.removeField('field_date');
+                    expect(await TestingHelper.compare(obj3, obj4)).toBe(true);
+
+                    await cache.put(3, obj3);
+                    await cache.put(4, obj4);
+                    expect(await TestingHelper.compare(await cache.get(3), await cache.get(4))).toBe(true);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    async function testSuiteCleanup(done) {
+        await TestingHelper.destroyCache(CACHE_NAME, done);
+    }
+});

http://git-wip-us.apache.org/repos/asf/ignite/blob/c56d16fb/modules/platforms/nodejs/spec/cache/Cache.spec.js
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/spec/cache/Cache.spec.js b/modules/platforms/nodejs/spec/cache/Cache.spec.js
new file mode 100644
index 0000000..713294b
--- /dev/null
+++ b/modules/platforms/nodejs/spec/cache/Cache.spec.js
@@ -0,0 +1,262 @@
+/*
+ * 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.
+ */
+
+'use strict';
+
+require('jasmine-expect');
+
+const config = require('../config');
+const TestingHelper = require('../TestingHelper');
+const IgniteClient = require('apache-ignite-client');
+const Errors = IgniteClient.Errors;
+const CacheConfiguration = IgniteClient.CacheConfiguration;
+const QueryEntity = IgniteClient.QueryEntity;
+const QueryField = IgniteClient.QueryField;
+const QueryIndex = IgniteClient.QueryIndex;
+
+const CACHE_NAME = '__test_cache';
+const CACHE_NAME2 = '__test_cache2';
+const CACHE_NAME3 = '__test_cache3';
+
+describe('cache configuration operations test suite >', () => {
+    let igniteClient = null;
+
+    beforeAll((done) => {
+        Promise.resolve().
+            then(async () => {
+                await TestingHelper.init();
+                igniteClient = TestingHelper.igniteClient;
+                await testSuiteCleanup(done);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    }, TestingHelper.TIMEOUT);
+
+    afterAll((done) => {
+        Promise.resolve().
+            then(async () => {
+                await testSuiteCleanup(done);
+                await TestingHelper.cleanUp();
+            }).
+            then(done).
+            catch(error => done());
+    }, TestingHelper.TIMEOUT);
+
+    it('create cache', (done) => {
+        Promise.resolve().
+            then(async () => {
+                let cache = igniteClient.getCache(CACHE_NAME);
+                await testCache(cache, false, done);
+                cache = await igniteClient.createCache(CACHE_NAME);
+                await testCache(cache, true, done);
+                cache = igniteClient.getCache(CACHE_NAME);
+                await testCache(cache, true, done);
+                await igniteClient.destroyCache(CACHE_NAME);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('create cache twice', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let cache = await igniteClient.getOrCreateCache(CACHE_NAME);
+                    cache = await igniteClient.createCache(CACHE_NAME);
+                }
+                catch (err) {
+                    if (!(err instanceof Errors.OperationError)) {
+                        done.fail('cache successully created twice');
+                    }
+                }
+                finally {
+                    await igniteClient.destroyCache(CACHE_NAME);
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('get or create cache', (done) => {
+        Promise.resolve().
+            then(async () => {
+                let cache = igniteClient.getCache(CACHE_NAME2);
+                await testCache(cache, false, done);
+                cache = await igniteClient.getOrCreateCache(CACHE_NAME2);
+                await testCache(cache, true, done);
+                cache = igniteClient.getCache(CACHE_NAME2);
+                await testCache(cache, true, done);
+                await igniteClient.destroyCache(CACHE_NAME2);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('get cache names', (done) => {
+        Promise.resolve().
+            then(async () => {
+                await igniteClient.getOrCreateCache(CACHE_NAME);
+                await igniteClient.getOrCreateCache(CACHE_NAME2);
+                const cacheNames = await igniteClient.cacheNames();
+                expect(cacheNames.includes(CACHE_NAME)).toBe(true);
+                expect(cacheNames.includes(CACHE_NAME2)).toBe(true);
+                await igniteClient.destroyCache(CACHE_NAME);
+                await igniteClient.destroyCache(CACHE_NAME2);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('destroy cache', (done) => {
+        Promise.resolve().
+            then(async () => {
+                let cache = await igniteClient.getOrCreateCache(CACHE_NAME);
+                await igniteClient.destroyCache(CACHE_NAME);
+                try {
+                    await igniteClient.destroyCache(CACHE_NAME);
+                    done.fail('cache successfully deleted twice');
+                }
+                catch (err) {
+                    if (!(err instanceof Errors.OperationError)) {
+                        done.fail('unexpected error: ' + err);
+                    }
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('create cache with configuration', (done) => {
+        Promise.resolve().
+            then(async () => {
+                const cacheCfg = new CacheConfiguration().
+                    setQueryEntities(
+                        new QueryEntity().
+                            setKeyTypeName('INT').
+                            setValueTypeName('Person').
+                            setTableName('Person').
+                            setKeyFieldName('id').
+                            setValueFieldName('salary').
+                            setFields([
+                                new QueryField('id', 'INT').
+                                    setIsKeyField(true),
+                                new QueryField('firstName', 'VARCHAR').
+                                    setIsNotNull(true),
+                                new QueryField('lastName', 'VARCHAR').
+                                    setDefaultValue('lastName'),
+                                new QueryField('salary', 'DOUBLE').
+                                    setPrecision(10).
+                                    setScale(10)
+                            ]).
+                            setAliases(new Map([['id', 'id'], ['firstName', 'firstName']])).
+                            setIndexes([
+                                new QueryIndex('id_idx', QueryIndex.INDEX_TYPE.SORTED).
+                                    setName('id_idx').
+                                    setType(QueryIndex.INDEX_TYPE.SORTED).
+                                    setInlineSize(10).
+                                    setFields(new Map([['id', true], ['firstName', false]]))
+                            ]));
+                let cache = await igniteClient.createCache(CACHE_NAME3, cacheCfg);
+                let cfg = await igniteClient.getCacheConfiguration(CACHE_NAME3);
+                await igniteClient.destroyCache(CACHE_NAME3);
+
+                cache = await igniteClient.getOrCreateCache(CACHE_NAME3, cfg);
+                let cfg2 = await igniteClient.getCacheConfiguration(CACHE_NAME3);
+                await igniteClient.destroyCache(CACHE_NAME3);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('create cache with wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                const method = igniteClient.createCache.bind(igniteClient);
+                obtainCacheWithWrongName(method, done);
+                obtainCacheWithWrongConfig(method, done);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('get or create cache with wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                const method = igniteClient.getOrCreateCache.bind(igniteClient);
+                obtainCacheWithWrongName(method, done);
+                obtainCacheWithWrongConfig(method, done);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('get cache with wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                const method = igniteClient.getCache.bind(igniteClient);
+                obtainCacheWithWrongName(method, done);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    async function testSuiteCleanup(done) {
+        await TestingHelper.destroyCache(CACHE_NAME, done);
+        await TestingHelper.destroyCache(CACHE_NAME2, done);
+        await TestingHelper.destroyCache(CACHE_NAME3, done);
+    }
+
+    async function obtainCacheWithWrongName(method, done) {
+        const wrongNames = [undefined, null, ''];
+        for (let name of wrongNames) {
+            let cache;
+            try {
+                cache = await method(name);
+            }
+            catch (err) {
+                TestingHelper.checkIllegalArgumentError(err, done);
+            }
+        }
+    }
+
+    async function obtainCacheWithWrongConfig(method, done) {
+        const wrongConfigs = ['', new IgniteClient(), new Array()];
+        for (let config of wrongConfigs) {
+            let cache;
+            try {
+                cache = await method(CACHE_NAME, config);
+            }
+            catch (err) {
+                TestingHelper.checkIllegalArgumentError(err, done);
+            }
+        }
+    }
+
+    async function testCache(cache, cacheExists, done) {
+        try {
+            await cache.put(0, 0);
+            if (!cacheExists) {
+                done.fail('operation with absent cache succeeded');
+            }
+        }
+        catch (err) {
+            if (!(err instanceof Errors.OperationError)) {
+                done.fail('unexpected error: ' + err);
+            }
+        }
+    }
+});

http://git-wip-us.apache.org/repos/asf/ignite/blob/c56d16fb/modules/platforms/nodejs/spec/cache/CacheKeyValueOps.spec.js
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/spec/cache/CacheKeyValueOps.spec.js b/modules/platforms/nodejs/spec/cache/CacheKeyValueOps.spec.js
new file mode 100644
index 0000000..d34276c
--- /dev/null
+++ b/modules/platforms/nodejs/spec/cache/CacheKeyValueOps.spec.js
@@ -0,0 +1,1022 @@
+/*
+ * 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.
+ */
+
+'use strict';
+
+require('jasmine-expect');
+
+const TestingHelper = require('../TestingHelper');
+const IgniteClient = require('apache-ignite-client');
+const ObjectType = IgniteClient.ObjectType;
+const CacheClient = IgniteClient.CacheClient;
+const CacheEntry = IgniteClient.CacheEntry;
+const CacheConfiguration = IgniteClient.CacheConfiguration;
+
+const CACHE_NAME = '__test_cache';
+
+describe('cache key value operations test suite >', () => {
+    let igniteClient = null;
+    let cache = null;
+
+    beforeAll((done) => {
+        Promise.resolve().
+            then(async () => {
+                await TestingHelper.init();
+                igniteClient = TestingHelper.igniteClient;
+                await testSuiteCleanup(done);
+                await igniteClient.getOrCreateCache(CACHE_NAME);
+                cache = igniteClient.getCache(CACHE_NAME).
+                    setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER).
+                    setValueType(ObjectType.PRIMITIVE_TYPE.INTEGER);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    }, TestingHelper.TIMEOUT);
+
+    afterAll((done) => {
+        Promise.resolve().
+            then(async () => {
+                await testSuiteCleanup(done);
+                await TestingHelper.cleanUp();
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    }, TestingHelper.TIMEOUT);
+
+    it ('get', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let value = await cache.get(1);
+                    expect(value).toBe(null);
+                    await cache.put(1, 2);
+                    value = await cache.get(1);
+                    expect(value).toBe(2);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('get wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const wrongArgs = [null, undefined];
+                    for (let arg of wrongArgs) {
+                        try {
+                            let value = await cache.get(arg);
+                            done.fail(`cache.get(${arg}) is allowed`);
+                        }
+                        catch (err) {
+                            TestingHelper.checkIllegalArgumentError(err, done);
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('getAll', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    for (let i = 0; i < 5; i++) {
+                        await cache.put(i, i * 2);
+                    }
+                    let entries = await cache.getAll([3, 4, 5, 6, 7]);
+                    expect(entries.length).toBe(2, 'get all length is incorrect');
+                    for (let entry of entries) {
+                        expect(entry.getKey()).toBeWithinRange(3, 4);
+                        expect(entry.getValue()).toBe(entry.getKey() * 2);
+                    }
+                    entries = await cache.getAll([6, 7, 8]);
+                    expect(entries.length).toBe(0, 'get all length is incorrect');
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('getAll wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const wrongArgs = [null, undefined, 12345, 'abc', []];
+                    for (let arg of wrongArgs) {
+                        try {
+                            let value = await cache.getAll(arg);
+                            done.fail(`cache.getAll(${arg}) is allowed`);
+                        }
+                        catch (err) {
+                            TestingHelper.checkIllegalArgumentError(err, done);
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('put', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let value = await cache.get(1);
+                    expect(value).toBe(null);
+                    await cache.put(1, 2);
+                    value = await cache.get(1);
+                    expect(value).toBe(2);
+                    await cache.put(1, 4);
+                    value = await cache.get(1);
+                    expect(value).toBe(4);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('put wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const args = [null, undefined, 1];
+                    for (let key of args) {
+                        for (let value of args) {
+                            if (key === 1 && value === 1) {
+                                continue;
+                            }
+                            try {
+                                await cache.put(key, value);
+                                done.fail(`cache.put(${key}, ${value}) is allowed`);
+                            }
+                            catch (err) {
+                                TestingHelper.checkIllegalArgumentError(err, done);
+                            }
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('putAll', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const cacheEntries = new Array();
+                    for (let i = 0; i < 5; i++) {
+                        cacheEntries.push(new CacheEntry(i, i * 2));
+                    }
+                    await cache.putAll(cacheEntries);
+                    let entries = await cache.getAll([3, 4, 5, 6, 7]);
+                    expect(entries.length).toBe(2, 'get all length is incorrect');
+                    for (let entry of entries) {
+                        expect(entry.getKey()).toBeWithinRange(3, 4);
+                        expect(entry.getValue()).toBe(entry.getKey() * 2);
+                    }
+                    entries = await cache.getAll([-2, -1, 0, 1, 2, 3, 4, 5, 6, 7]);
+                    expect(entries.length).toBe(5, 'get all length is incorrect');
+                    for (let entry of entries) {
+                        expect(entry.getKey()).toBeWithinRange(0, 5);
+                        expect(entry.getValue()).toBe(entry.getKey() * 2);
+                    }
+                    entries = await cache.getAll([6, 7, 8]);
+                    expect(entries.length).toBe(0, 'get all length is incorrect');
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('putAll wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const wrongArgs = [null, undefined, 12345, 'abc', [], [new CacheConfiguration()]];
+                    for (let arg of wrongArgs) {
+                        try {
+                            let value = await cache.putAll(arg);
+                            done.fail(`cache.putAll(${arg}) is allowed`);
+                        }
+                        catch (err) {
+                            TestingHelper.checkIllegalArgumentError(err, done);
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('containsKey', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let result = await cache.containsKey(1);
+                    expect(result).toBe(false);
+                    await cache.put(1, 2);
+                    result = await cache.containsKey(1);
+                    expect(result).toBe(true);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('containsKey wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const wrongArgs = [null, undefined];
+                    for (let arg of wrongArgs) {
+                        try {
+                            let value = await cache.get(arg);
+                            done.fail(`cache.containsKey(${arg}) is allowed`);
+                        }
+                        catch (err) {
+                            TestingHelper.checkIllegalArgumentError(err, done);
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('containsKeys', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let result = await cache.containsKeys([1, 2, 3]);
+                    expect(result).toBe(false);
+                    await cache.putAll([new CacheEntry(1, 2), new CacheEntry(2, 4)]);
+                    result = await cache.containsKeys([1, 2, 3]);
+                    expect(result).toBe(false);
+                    await cache.put(3, 6);
+                    result = await cache.containsKeys([1, 2, 3]);
+                    expect(result).toBe(true);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('containsKeys wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const wrongArgs = [null, undefined, [], 12345, 'abc'];
+                    for (let arg of wrongArgs) {
+                        try {
+                            let value = await cache.containsKeys(arg);
+                            done.fail(`cache.containsKeys(${arg}) is allowed`);
+                        }
+                        catch (err) {
+                            TestingHelper.checkIllegalArgumentError(err, done);
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('getAndPut', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let value = await cache.getAndPut(1, 2);
+                    expect(value).toBe(null);
+                    value = await cache.getAndPut(1, 4);
+                    expect(value).toBe(2);
+                    await cache.put(1, 6);
+                    value = await cache.getAndPut(1, 8);
+                    expect(value).toBe(6);
+                    value = await cache.get(1);
+                    expect(value).toBe(8);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('getAndPut wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const args = [null, undefined, 1];
+                    for (let key of args) {
+                        for (let value of args) {
+                            if (key === 1 && value === 1) {
+                                continue;
+                            }
+                            try {
+                                await cache.getAndPut(key, value);
+                                done.fail(`cache.getAndPut(${key}, ${value}) is allowed`);
+                            }
+                            catch (err) {
+                                TestingHelper.checkIllegalArgumentError(err, done);
+                            }
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('getAndReplace', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let value = await cache.getAndReplace(1, 2);
+                    expect(value).toBe(null);
+                    await cache.put(1, 4);
+                    value = await cache.getAndReplace(1, 6);
+                    expect(value).toBe(4);
+                    value = await cache.get(1);
+                    expect(value).toBe(6);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('getAndReplace wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const args = [null, undefined, 1];
+                    for (let key of args) {
+                        for (let value of args) {
+                            if (key === 1 && value === 1) {
+                                continue;
+                            }
+                            try {
+                                await cache.getAndReplace(key, value);
+                                done.fail(`cache.getAndReplace(${key}, ${value}) is allowed`);
+                            }
+                            catch (err) {
+                                TestingHelper.checkIllegalArgumentError(err, done);
+                            }
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('getAndRemove', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let value = await cache.getAndRemove(1);
+                    expect(value).toBe(null);
+                    await cache.put(1, 2);
+                    value = await cache.getAndRemove(1);
+                    expect(value).toBe(2);
+                    value = await cache.get(1);
+                    expect(value).toBe(null);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('getAndRemove wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const args = [null, undefined];
+                    for (let key of args) {
+                        try {
+                            await cache.getAndRemove(key);
+                            done.fail(`cache.getAndRemove(${key}) is allowed`);
+                        }
+                        catch (err) {
+                            TestingHelper.checkIllegalArgumentError(err, done);
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('putIfAbsent', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let result = await cache.putIfAbsent(1, 2);
+                    expect(result).toBe(true);
+                    let value = await cache.get(1);
+                    expect(value).toBe(2);
+                    result = await cache.putIfAbsent(1, 4);
+                    expect(result).toBe(false);
+                    value = await cache.get(1);
+                    expect(value).toBe(2);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('putIfAbsent wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const args = [null, undefined, 1];
+                    for (let key of args) {
+                        for (let value of args) {
+                            if (key === 1 && value === 1) {
+                                continue;
+                            }
+                            try {
+                                await cache.putIfAbsent(key, value);
+                                done.fail(`cache.putIfAbsent(${key}, ${value}) is allowed`);
+                            }
+                            catch (err) {
+                                TestingHelper.checkIllegalArgumentError(err, done);
+                            }
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('getAndPutIfAbsent', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let value = await cache.getAndPutIfAbsent(1, 2);
+                    expect(value).toBe(null);
+                    value = await cache.get(1);
+                    expect(value).toBe(2);
+                    value = await cache.getAndPutIfAbsent(1, 4);
+                    expect(value).toBe(2);
+                    value = await cache.get(1);
+                    expect(value).toBe(2);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('getAndPutIfAbsent wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const args = [null, undefined, 1];
+                    for (let key of args) {
+                        for (let value of args) {
+                            if (key === 1 && value === 1) {
+                                continue;
+                            }
+                            try {
+                                await cache.getAndPutIfAbsent(key, value);
+                                done.fail(`cache.getAndPutIfAbsent(${key}, ${value}) is allowed`);
+                            }
+                            catch (err) {
+                                TestingHelper.checkIllegalArgumentError(err, done);
+                            }
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('replace', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let result = await cache.replace(1, 2);
+                    expect(result).toBe(false);
+                    let value = await cache.get(1);
+                    expect(value).toBe(null);
+                    await cache.put(1, 1);
+                    result = await cache.replace(1, 4);
+                    expect(result).toBe(true);
+                    value = await cache.get(1);
+                    expect(value).toBe(4);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('replace wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const args = [null, undefined, 1];
+                    for (let key of args) {
+                        for (let value of args) {
+                            if (key === 1 && value === 1) {
+                                continue;
+                            }
+                            try {
+                                await cache.replace(key, value);
+                                done.fail(`cache.replace(${key}, ${value}) is allowed`);
+                            }
+                            catch (err) {
+                                TestingHelper.checkIllegalArgumentError(err, done);
+                            }
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('replaceIfEquals', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let result = await cache.replaceIfEquals(1, 2, 3);
+                    expect(result).toBe(false);
+                    await cache.put(1, 4);
+                    result = await cache.replaceIfEquals(1, 2, 3);
+                    expect(result).toBe(false);
+                    let value = await cache.get(1);
+                    expect(value).toBe(4);
+                    result = await cache.replaceIfEquals(1, 4, 3);
+                    expect(result).toBe(true);
+                    value = await cache.get(1);
+                    expect(value).toBe(3);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('replaceIfEquals wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const args = [null, undefined, 1];
+                    for (let key of args) {
+                        for (let value of args) {
+                            for (let newValue of args) {
+                                if (key === 1 && value === 1 && newValue === 1) {
+                                    continue;
+                                }
+                                try {
+                                    await cache.replaceIfEquals(key, value, newValue);
+                                    done.fail(`cache.replaceIfEquals(${key}, ${value}, ${newValue}) is allowed`);
+                                }
+                                catch (err) {
+                                    TestingHelper.checkIllegalArgumentError(err, done);
+                                }
+                            }
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('clear', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    await cache.clear();
+                    let result = await cache.getSize();
+                    expect(result).toBe(0);
+                    await cache.putAll([new CacheEntry(1, 2), new CacheEntry(2, 4), new CacheEntry(3, 6)]);
+                    result = await cache.getSize();
+                    expect(result).toBe(3);
+                    await cache.clear();
+                    result = await cache.getSize();
+                    expect(result).toBe(0);
+                    let entries = await cache.getAll([1, 2, 3]);
+                    expect(entries.length).toBe(0, 'get all length is incorrect');
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('clearKeys', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    await cache.clearKeys([1, 2, 3]);
+                    let result = await cache.getSize();
+                    expect(result).toBe(0);
+                    await cache.putAll([new CacheEntry(1, 2), new CacheEntry(2, 4), new CacheEntry(3, 6)]);
+                    result = await cache.getSize();
+                    expect(result).toBe(3);
+                    await cache.clearKeys([1, 2, 7, 8]);
+                    result = await cache.getSize();
+                    expect(result).toBe(1);
+                    let value = await cache.get(3);
+                    expect(value).toBe(6);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('clearKeys wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const wrongArgs = [null, undefined, [], 12345, 'abc'];
+                    for (let arg of wrongArgs) {
+                        try {
+                            let value = await cache.clearKeys(arg);
+                            done.fail(`cache.clearKeys(${arg}) is allowed`);
+                        }
+                        catch (err) {
+                            TestingHelper.checkIllegalArgumentError(err, done);
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('clearKey', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    await cache.clearKey(1);
+                    let result = await cache.getSize();
+                    expect(result).toBe(0);
+                    await cache.putAll([new CacheEntry(1, 2), new CacheEntry(2, 4), new CacheEntry(3, 6)]);
+                    result = await cache.getSize();
+                    expect(result).toBe(3);
+                    await cache.clearKey(1);
+                    result = await cache.getSize();
+                    expect(result).toBe(2);
+                    let value = await cache.get(2);
+                    expect(value).toBe(4);
+                    value = await cache.get(3);
+                    expect(value).toBe(6);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('clearKey wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const wrongArgs = [null, undefined];
+                    for (let arg of wrongArgs) {
+                        try {
+                            let value = await cache.clearKey(arg);
+                            done.fail(`cache.clearKey(${arg}) is allowed`);
+                        }
+                        catch (err) {
+                            TestingHelper.checkIllegalArgumentError(err, done);
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('removeKey', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let result = await cache.removeKey(1);
+                    expect(result).toBe(false);
+                    result = await cache.getSize();
+                    expect(result).toBe(0);
+                    await cache.putAll([new CacheEntry(1, 2), new CacheEntry(2, 4), new CacheEntry(3, 6)]);
+                    result = await cache.getSize();
+                    expect(result).toBe(3);
+                    result = await cache.removeKey(1);
+                    expect(result).toBe(true);
+                    result = await cache.removeKey(1);
+                    expect(result).toBe(false);
+                    result = await cache.getSize();
+                    expect(result).toBe(2);
+                    let value = await cache.get(2);
+                    expect(value).toBe(4);
+                    value = await cache.get(3);
+                    expect(value).toBe(6);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('removeKey wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const wrongArgs = [null, undefined];
+                    for (let arg of wrongArgs) {
+                        try {
+                            let value = await cache.removeKey(arg);
+                            done.fail(`cache.removeKey(${arg}) is allowed`);
+                        }
+                        catch (err) {
+                            TestingHelper.checkIllegalArgumentError(err, done);
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('removeIfEquals', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let result = await cache.removeIfEquals(1, 2);
+                    expect(result).toBe(false);
+                    await cache.put(1, 4);
+                    result = await cache.removeIfEquals(1, 2);
+                    expect(result).toBe(false);
+                    result = await cache.removeIfEquals(1, 4);
+                    expect(result).toBe(true);
+                    let value = await cache.get(1);
+                    expect(value).toBe(null);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('removeIfEquals wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const args = [null, undefined, 1];
+                    for (let key of args) {
+                        for (let value of args) {
+                            if (key === 1 && value === 1) {
+                                continue;
+                            }
+                            try {
+                                await cache.removeIfEquals(key, value);
+                                done.fail(`cache.removeIfEquals(${key}, ${value}) is allowed`);
+                            }
+                            catch (err) {
+                                TestingHelper.checkIllegalArgumentError(err, done);
+                            }
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('removeKeys', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    await cache.removeKeys([1, 2, 3]);
+                    let result = await cache.getSize();
+                    expect(result).toBe(0);
+                    await cache.putAll([new CacheEntry(1, 2), new CacheEntry(2, 4), new CacheEntry(3, 6)]);
+                    result = await cache.getSize();
+                    expect(result).toBe(3);
+                    await cache.removeKeys([1, 2, 7, 8]);
+                    result = await cache.getSize();
+                    expect(result).toBe(1);
+                    let value = await cache.get(3);
+                    expect(value).toBe(6);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('removeKeys wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const wrongArgs = [null, undefined, [], 12345, 'abc'];
+                    for (let arg of wrongArgs) {
+                        try {
+                            let value = await cache.removeKeys(arg);
+                            done.fail(`cache.removeKeys(${arg}) is allowed`);
+                        }
+                        catch (err) {
+                            TestingHelper.checkIllegalArgumentError(err, done);
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('removeAll', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    await cache.removeAll();
+                    let result = await cache.getSize();
+                    expect(result).toBe(0);
+                    await cache.putAll([new CacheEntry(1, 2), new CacheEntry(2, 4), new CacheEntry(3, 6)]);
+                    result = await cache.getSize();
+                    expect(result).toBe(3);
+                    await cache.removeAll();
+                    result = await cache.getSize();
+                    expect(result).toBe(0);
+                    let entries = await cache.getAll([1, 2, 3]);
+                    expect(entries.length).toBe(0, 'get all length is incorrect');
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('getSize', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    let result = await cache.getSize();
+                    expect(result).toBe(0);
+                    await cache.putAll([new CacheEntry(1, 2), new CacheEntry(2, 4), new CacheEntry(3, 6)]);
+                    result = await cache.getSize();
+                    expect(result).toBe(3);
+                    result = await cache.getSize(CacheClient.PEEK_MODE.ALL);
+                    expect(result).toBe(3);
+                    result = await cache.getSize(CacheClient.PEEK_MODE.ALL, CacheClient.PEEK_MODE.ALL);
+                    expect(result).toBe(3);
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it ('getSize wrong args', (done) => {
+        Promise.resolve().
+            then(async () => {
+                try {
+                    const wrongArgs = [null, undefined, [], 12345, 'abc', [12345], ['abc', 'def']];
+                    for (let arg of wrongArgs) {
+                        try {
+                            let value = await cache.getSize(arg);
+                            done.fail(`cache.getSize(${arg}) is allowed`);
+                        }
+                        catch (err) {
+                            TestingHelper.checkIllegalArgumentError(err, done);
+                        }
+                    }
+                }
+                finally {
+                    await cache.removeAll();
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    async function testSuiteCleanup(done) {
+        await TestingHelper.destroyCache(CACHE_NAME, done);
+    }
+});

http://git-wip-us.apache.org/repos/asf/ignite/blob/c56d16fb/modules/platforms/nodejs/spec/cache/CachePutGetDiffTypes.spec.js
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/spec/cache/CachePutGetDiffTypes.spec.js b/modules/platforms/nodejs/spec/cache/CachePutGetDiffTypes.spec.js
new file mode 100644
index 0000000..28a9ae3
--- /dev/null
+++ b/modules/platforms/nodejs/spec/cache/CachePutGetDiffTypes.spec.js
@@ -0,0 +1,647 @@
+/*
+ * 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.
+ */
+
+'use strict';
+
+require('jasmine-expect');
+
+const TestingHelper = require('../TestingHelper');
+const IgniteClient = require('apache-ignite-client');
+const ObjectType = IgniteClient.ObjectType;
+const MapObjectType = IgniteClient.MapObjectType;
+const CollectionObjectType = IgniteClient.CollectionObjectType;
+const ObjectArrayType = IgniteClient.ObjectArrayType;
+const ComplexObjectType = IgniteClient.ComplexObjectType;
+const EnumItem = IgniteClient.EnumItem;
+const Timestamp = IgniteClient.Timestamp;
+const Decimal = IgniteClient.Decimal;
+const BinaryObject = IgniteClient.BinaryObject;
+
+const CACHE_NAME = '__test_cache';
+
+describe('cache put get test suite >', () => {
+    let igniteClient = null;
+
+    beforeAll((done) => {
+        Promise.resolve().
+            then(async () => {
+                await TestingHelper.init();
+                igniteClient = TestingHelper.igniteClient;
+                await testSuiteCleanup(done);
+                await igniteClient.getOrCreateCache(CACHE_NAME);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    }, TestingHelper.TIMEOUT);
+
+    afterAll((done) => {
+        Promise.resolve().
+            then(async () => {
+                await testSuiteCleanup(done);
+                await TestingHelper.cleanUp();
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    }, TestingHelper.TIMEOUT);
+
+    it('put get primitive values of different types', (done) => {
+        Promise.resolve().
+            then(async () => {
+                for (let type1 of Object.keys(TestingHelper.primitiveValues)) {
+                    type1 = parseInt(type1);
+                    const typeInfo1 = TestingHelper.primitiveValues[type1];
+                    for (let type2 of Object.keys(TestingHelper.primitiveValues)) {
+                        type2 = parseInt(type2);
+                        const typeInfo2 = TestingHelper.primitiveValues[type2];
+                        const modificator = typeInfo2.modificator;
+                        for (let value1 of typeInfo1.values) {
+                            for (let value2 of typeInfo2.values) {
+                                await putGetPrimitiveValues(type1, type2, value1, value2, modificator);
+                                if (typeInfo1.typeOptional) {
+                                    await putGetPrimitiveValues(null, type2, value1, value2, modificator);
+                                }
+                                if (typeInfo2.typeOptional) {
+                                    await putGetPrimitiveValues(type1, null, value1, value2, modificator);
+                                }
+                            }
+                        }
+                    }
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get arrays of different types', (done) => {
+        Promise.resolve().
+            then(async () => {
+                for (let type of Object.keys(TestingHelper.arrayValues)) {
+                    type = parseInt(type);
+                    const typeInfo = TestingHelper.arrayValues[type];
+                    const primitiveType = typeInfo.elemType;
+                    const values = TestingHelper.primitiveValues[primitiveType].values;
+                    await putGetArrays(primitiveType, type, values[0], values);
+                    await putGetArrays(primitiveType, type, values[0], []);
+                    if (typeInfo.typeOptional) {
+                        await putGetArrays(primitiveType, null, values[0], values);
+                    }
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get maps of different key/value types', (done) => {
+        Promise.resolve().
+            then(async () => {
+                for (let type1 of Object.keys(TestingHelper.primitiveValues)) {
+                    type1 = parseInt(type1);
+                    const typeInfo1 = TestingHelper.primitiveValues[type1];
+                    if (!typeInfo1.isMapKey) {
+                        continue;
+                    }
+                    for (let type2 of Object.keys(TestingHelper.primitiveValues)) {
+                        type2 = parseInt(type2);
+                        const typeInfo2 = TestingHelper.primitiveValues[type2];
+                        const map = new Map();
+                        let index2 = 0;
+                        for (let value1 of typeInfo1.values) {
+                            let value2 = typeInfo2.values[index2];
+                            index2++;
+                            if (index2 >= typeInfo2.values.length) {
+                                index2 = 0;
+                            }
+                            map.set(value1, value2);
+                        }
+                        await putGetMaps(
+                            new MapObjectType(MapObjectType.MAP_SUBTYPE.HASH_MAP, type1, type2),
+                            map);
+                        await putGetMaps(
+                            new MapObjectType(
+                                MapObjectType.MAP_SUBTYPE.LINKED_HASH_MAP, type1, type2), 
+                            map);
+                        if (typeInfo1.typeOptional) {
+                            await putGetMaps(new MapObjectType(MapObjectType.MAP_SUBTYPE.HASH_MAP, null, type2),
+                            map);
+                        }
+                        if (typeInfo2.typeOptional) {
+                            await putGetMaps(new MapObjectType(MapObjectType.MAP_SUBTYPE.HASH_MAP, type1, null),
+                            map);
+                        }
+                    }
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get maps with arrays of different types', (done) => {
+        Promise.resolve().
+            then(async () => {
+                for (let type1 of Object.keys(TestingHelper.primitiveValues)) {
+                    type1 = parseInt(type1);
+                    const typeInfo1 = TestingHelper.primitiveValues[type1];
+                    if (!typeInfo1.isMapKey) {
+                        continue;
+                    }
+                    for (let type2 of Object.keys(TestingHelper.arrayValues)) {
+                        type2 = parseInt(type2);
+                        const typeInfo2 = TestingHelper.arrayValues[type2];
+                        const primitiveType2 = typeInfo2.elemType;
+                        const values2 = TestingHelper.primitiveValues[primitiveType2].values;
+                        const map = new Map();
+                        let index2 = 0;
+                        const arrayValues2 = [values2, null, values2.reverse()];
+                        for (let value1 of typeInfo1.values) {
+                            map.set(value1, arrayValues2[index2]);
+                            index2++;
+                            if (index2 >= arrayValues2.length) {
+                                index2 = 0;
+                            }
+                        }
+                        await putGetMaps(
+                            new MapObjectType(MapObjectType.MAP_SUBTYPE.HASH_MAP, type1, type2),
+                            map);
+                        await putGetMaps(
+                            new MapObjectType(MapObjectType.MAP_SUBTYPE.LINKED_HASH_MAP, type1, type2), 
+                            map);
+                        if (typeInfo1.typeOptional) {
+                            await putGetMaps(new MapObjectType(MapObjectType.MAP_SUBTYPE.HASH_MAP, null, type2),
+                            map);
+                        }
+                        if (typeInfo2.typeOptional) {
+                            await putGetMaps(new MapObjectType(MapObjectType.MAP_SUBTYPE.HASH_MAP, type1, null),
+                            map);
+                        }
+                    }
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get sets of different key/value types', (done) => {
+        Promise.resolve().
+            then(async () => {
+                for (let type of Object.keys(TestingHelper.primitiveValues)) {
+                    type = parseInt(type);
+                    const typeInfo = TestingHelper.primitiveValues[type];
+                    const set = new Set();
+                    for (let value of typeInfo.values) {
+                        set.add(value);
+                    }
+                    await putGetSets(
+                        new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.USER_SET, type),
+                            set);
+                    await putGetSets(
+                        new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.HASH_SET, type),
+                            set);
+                    await putGetSets(
+                        new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.LINKED_HASH_SET, type),
+                            set);
+                    if (typeInfo.typeOptional) {
+                        await putGetSets(new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.LINKED_HASH_SET),
+                            set);
+                        await putGetSets(null, set);
+                    }
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get lists of different key/value types', (done) => {
+        Promise.resolve().
+            then(async () => {
+                for (let type of Object.keys(TestingHelper.primitiveValues)) {
+                    type = parseInt(type);
+                    const typeInfo = TestingHelper.primitiveValues[type];
+                    const list = new Array();
+                    for (let value of typeInfo.values) {
+                        list.push(value);
+                    }
+                    await putGetLists(
+                        new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.USER_COL, type),
+                            list);
+                    await putGetLists(
+                        new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.ARRAY_LIST, type),
+                            list);
+                    await putGetLists(
+                        new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.LINKED_LIST, type),
+                            list);
+                    if (typeInfo.typeOptional) {
+                        await putGetLists(new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.ARRAY_LIST),
+                            list);
+                    }
+                    // const singletonList = [typeInfo.values[0]];
+                    // await putGetLists(
+                    //     new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.SINGLETON_LIST, type),
+                    //         singletonList);
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get object array of maps', (done) => {
+        Promise.resolve().
+            then(async () => {
+                for (let type1 of Object.keys(TestingHelper.primitiveValues)) {
+                    type1 = parseInt(type1);
+                    const typeInfo1 = TestingHelper.primitiveValues[type1];
+                    if (!typeInfo1.isMapKey) {
+                        continue;
+                    }
+                    for (let type2 of Object.keys(TestingHelper.primitiveValues)) {
+                        type2 = parseInt(type2);
+                        const typeInfo2 = TestingHelper.primitiveValues[type2];
+                        let map = new Map();
+                        let index2 = 0;
+                        for (let value1 of typeInfo1.values) {
+                            let value2 = typeInfo2.values[index2];
+                            index2++;
+                            if (index2 >= typeInfo2.values.length) {
+                                index2 = 0;
+                            }
+                            map.set(value1, value2);
+                        }
+                        const array = new Array();
+                        for (let i = 0; i < 10; i++) {
+                            map = new Map([...map.entries()].map(([key, value]) => [typeInfo1.modificator(key), typeInfo2.modificator(value)]));
+                            array.push(map);
+                        }
+                        await putGetObjectArrays(new ObjectArrayType(new MapObjectType(MapObjectType.MAP_SUBTYPE.HASH_MAP, type1, type2)), 
+                            array);
+                        if (typeInfo1.typeOptional) {
+                            await putGetObjectArrays(new ObjectArrayType(new MapObjectType(MapObjectType.MAP_SUBTYPE.LINKED_HASH_MAP, null, type2)), 
+                                array);
+                        }
+                        if (typeInfo2.typeOptional) {
+                            await putGetObjectArrays(new ObjectArrayType(new MapObjectType(MapObjectType.MAP_SUBTYPE.LINKED_HASH_MAP, type1)), 
+                                array);
+                        }
+                        if (typeInfo1.typeOptional && typeInfo2.typeOptional) {
+                            await putGetObjectArrays(new ObjectArrayType(), array);
+                            await putGetObjectArrays(null, array);
+                        }
+                    }
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get object array of primitive types', (done) => {
+        Promise.resolve().
+            then(async () => {
+                for (let type of Object.keys(TestingHelper.primitiveValues)) {
+                    type = parseInt(type);
+                    const typeInfo = TestingHelper.primitiveValues[type];
+                    let value = typeInfo.values[0];
+                    const array = new Array();
+                    for (let i = 0; i < 10; i++) {
+                        value = typeInfo.modificator(value);
+                        array.push(value);
+                    }
+                    await putGetObjectArrays(
+                        new ObjectArrayType(type), 
+                        array);
+                    if (typeInfo.typeOptional) {
+                        await putGetObjectArrays(new ObjectArrayType(), array);
+                    }
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get object array of primitive arrays', (done) => {
+        Promise.resolve().
+            then(async () => {
+                for (let type of Object.keys(TestingHelper.arrayValues)) {
+                    type = parseInt(type);
+                    const typeInfo = TestingHelper.arrayValues[type];
+                    const primitiveType = typeInfo.elemType;
+                    const primitiveTypeInfo = TestingHelper.primitiveValues[primitiveType];
+                    let values = primitiveTypeInfo.values;
+                    
+                    const array = new Array();
+                    for (let i = 0; i < 10; i++) {
+                        values = values.map((value) => primitiveTypeInfo.modificator(value));
+                        array.push(values);
+                    }
+                    await putGetObjectArrays(
+                        new ObjectArrayType(type), 
+                        array);
+                    if (typeInfo.typeOptional) {
+                        await putGetObjectArrays(new ObjectArrayType(), array);
+                    }
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get object array of sets', (done) => {
+        Promise.resolve().
+            then(async () => {
+                for (let type of Object.keys(TestingHelper.primitiveValues)) {
+                    type = parseInt(type);
+                    const typeInfo = TestingHelper.primitiveValues[type];
+                    let set = new Set();
+                    for (let value of typeInfo.values) {
+                        set.add(value);
+                    }
+                    const array = new Array();
+                    for (let i = 0; i < 10; i++) {
+                        set = new Set([...set].map((value) => typeInfo.modificator(value)));
+                        array.push(set);
+                    }
+                    await putGetObjectArrays(
+                        new ObjectArrayType(new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.USER_SET, type)), 
+                        array);
+                    await putGetObjectArrays(
+                        new ObjectArrayType(new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.HASH_SET, type)), 
+                        array);
+                    await putGetObjectArrays(
+                        new ObjectArrayType(new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.LINKED_HASH_SET, type)), 
+                        array);
+                    if (typeInfo.typeOptional) {
+                        await putGetObjectArrays(new ObjectArrayType(), array);
+                        await putGetObjectArrays(null, array);
+                    }
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get object array of lists', (done) => {
+        Promise.resolve().
+            then(async () => {
+                for (let type of Object.keys(TestingHelper.primitiveValues)) {
+                    type = parseInt(type);
+                    const typeInfo = TestingHelper.primitiveValues[type];
+                    let list = new Array();
+                    for (let value of typeInfo.values) {
+                        list.push(value);
+                    }
+                    const array = new Array();
+                    for (let i = 0; i < 10; i++) {
+                        list = list.map((value) => typeInfo.modificator(value));
+                        array.push(list);
+                    }
+                    await putGetObjectArrays(
+                        new ObjectArrayType(new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.USER_COL, type)), 
+                        array);
+                    await putGetObjectArrays(
+                        new ObjectArrayType(new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.ARRAY_LIST, type)), 
+                        array);
+                    await putGetObjectArrays(
+                        new ObjectArrayType(new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.LINKED_LIST, type)), 
+                        array);
+                    if (typeInfo.typeOptional) {
+                        await putGetObjectArrays(
+                            new ObjectArrayType(new CollectionObjectType(CollectionObjectType.COLLECTION_SUBTYPE.ARRAY_LIST)), 
+                            array);
+                    }
+                }
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get object array of complex objects', (done) => {
+        Promise.resolve().
+            then(async () => {
+                let object = {};
+                for (let type of Object.keys(TestingHelper.primitiveValues)) {
+                    type = parseInt(type);
+                    const typeInfo = TestingHelper.primitiveValues[type];
+                    object['field' + type] = typeInfo.values[0];
+                }
+                const objectType = new ComplexObjectType(object);
+                for (let type of Object.keys(TestingHelper.primitiveValues)) {
+                    type = parseInt(type);
+                    objectType.setFieldType('field' + type, type);
+                }
+
+                let array = new Array();
+                for (let i = 0; i < 5; i++) {
+                    for (let field in object) {
+                        const type = parseInt(field.substring(5));
+                        object[field] = TestingHelper.primitiveValues[type].modificator(object[field]);
+                    }
+                    array.push(object);
+                }
+                await putGetObjectArrays(
+                    new ObjectArrayType(objectType), array);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get object array of complex objects with default field types', (done) => {
+        Promise.resolve().
+            then(async () => {
+                let object = {};
+                for (let type of Object.keys(TestingHelper.primitiveValues)) {
+                    type = parseInt(type);
+                    const typeInfo = TestingHelper.primitiveValues[type];
+                    if (typeInfo.typeOptional) {
+                        object['field' + type] = typeInfo.values[0];
+                    }
+                }
+                const objectType = new ComplexObjectType(object, 'tstComplObjectWithDefaultFieldTypes');
+                let array = new Array();
+                for (let i = 0; i < 5; i++) {
+                    for (let field in object) {
+                        const type = parseInt(field.substring(5));
+                        object[field] = TestingHelper.primitiveValues[type].modificator(object[field]);
+                    }
+                    array.push(object);
+                }
+                await putGetObjectArrays(
+                    new ObjectArrayType(objectType), array);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get object array of binary objects', (done) => {
+        Promise.resolve().
+            then(async () => {
+                let binObject = new BinaryObject('tstBinaryObj');
+                for (let type of Object.keys(TestingHelper.primitiveValues)) {
+                    type = parseInt(type);
+                    const typeInfo = TestingHelper.primitiveValues[type];
+                    binObject.setField('field' + type, typeInfo.values[0], type);
+                }
+                let array = new Array();
+                for (let i = 0; i < 5; i++) {
+                    for (let field of binObject.getFieldNames()) {
+                        const type = parseInt(field.substring(5));
+                        binObject.setField(
+                            'field' + type,
+                            TestingHelper.primitiveValues[type].modificator(await binObject.getField('field' + type)),
+                            type);
+                    }
+                    array.push(binObject);
+                }
+                await putGetObjectArrays(new ObjectArrayType(), array);
+                await putGetObjectArrays(null, array);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('put get object array of object arrays', (done) => {
+        Promise.resolve().
+            then(async () => {
+                let object = {};
+                for (let type of Object.keys(TestingHelper.primitiveValues)) {
+                    type = parseInt(type);
+                    const typeInfo = TestingHelper.primitiveValues[type];
+                    object['field' + type] = typeInfo.values[0];
+                }
+                const objectType = new ComplexObjectType(object);
+                for (let type of Object.keys(TestingHelper.primitiveValues)) {
+                    type = parseInt(type);
+                    objectType.setFieldType('field' + type, type);
+                }
+
+                let array = new Array();
+                for (let i = 0; i < 2; i++) {
+                    let innerArray = new Array();
+                    for (let j = 0; j < 2; j++) {
+                        for (let field in object) {
+                            const type = parseInt(field.substring(5));
+                            object[field] = TestingHelper.primitiveValues[type].modificator(object[field]);
+                        }
+                        innerArray.push(object);
+                    }
+                    array.push(innerArray);
+                }
+                await putGetObjectArrays(
+                    new ObjectArrayType(new ObjectArrayType(objectType)), array);
+            }).
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    async function putGetPrimitiveValues(keyType, valueType, key, value, modificator) {
+        const cache = await igniteClient.getCache(CACHE_NAME).
+            setKeyType(keyType).
+            setValueType(valueType);
+        try {
+            await putGetPrimitive(cache, key, keyType, value, valueType);
+            const newValue = modificator(value);
+            await putGetPrimitive(cache, key, keyType, newValue, valueType);
+        }
+        finally {
+            await cache.removeAll();
+        }
+    }
+
+    async function putGetPrimitive(cache, key, keyType, value, valueType) {
+        await cache.put(key, value);
+        let result = await cache.get(key);
+        expect(await TestingHelper.compare(value, result)).toBe(true,
+            `values are not equal: keyType=${keyType}, key=${key}, valueType=${valueType}, put value=${value}, get value=${result}`);
+    }
+
+    async function putGetArrays(keyType, valueType, key, value) {
+        const cache = await igniteClient.getCache(CACHE_NAME).
+            setKeyType(keyType).
+            setValueType(valueType);
+        try {
+            await cache.put(key, value);
+            let result = await cache.get(key);
+            await cache.clearKey(key);
+            expect(result instanceof Array).toBe(true,
+                `result is not Array: arrayType=${valueType}, result=${result}`);
+            expect(await TestingHelper.compare(value, result)).toBe(true, 
+                `Arrays are not equal: arrayType=${valueType}, put array=${TestingHelper.printValue(value)
+                }, get array=${TestingHelper.printValue(result)}`);
+        }
+        finally {
+            await cache.removeAll();
+        }
+    }
+
+    async function putGetMaps(mapType, value) {
+        const key = new Date();
+        const cache = await igniteClient.getCache(CACHE_NAME).
+            setValueType(mapType);
+        await cache.put(key, value);
+        let result = await cache.get(key);
+        expect(result instanceof Map).toBe(true,
+            `result is not Map: mapType=${mapType}, result=${result}`);
+        expect(await TestingHelper.compare(value, result)).toBe(true, 
+            `Maps are not equal: valueType=${mapType._valueType}, put value=${TestingHelper.printValue(value)
+            }, get value=${TestingHelper.printValue(result)}`);
+    }
+
+    async function putGetSets(setType, value) {
+        const key = new Date();
+        const cache = await igniteClient.getCache(CACHE_NAME).
+            setValueType(setType);
+        await cache.put(key, value);
+        let result = await cache.get(key);
+
+        expect(result instanceof Set).toBe(true,
+            `result is not Set: setType=${setType}, result=${result}`);
+        if (!setType || setType._subType !== CollectionObjectType.COLLECTION_SUBTYPE.LINKED_HASH_SET) {
+            const valueArr = [...value].sort();
+            const resultArr = [...result].sort();
+            expect(await TestingHelper.compare(valueArr, resultArr)).toBe(true, `Sets are not equal: valueType=${setType ? setType._elementType : 
+                            null}, put value=${TestingHelper.printValue(valueArr)}, get value=${TestingHelper.printValue(resultArr)}`);
+        }
+        else {
+            expect(await TestingHelper.compare(value, result)).toBe(true, `Sets are not equal: valueType=${setType ? setType._elementType : 
+                            null}, put value=${TestingHelper.printValue(value)}, get value=${TestingHelper.printValue(result)}`);
+        }
+    }
+
+    async function putGetLists(listType, value) {
+        const key = new Date();
+        const cache = await igniteClient.getCache(CACHE_NAME).
+            setValueType(listType);
+        await cache.put(key, value);
+        let result = await cache.get(key);
+        expect(result instanceof Array).toBe(true,
+            `result is not Array: listType=${listType}, result=${result}`);
+        expect(await TestingHelper.compare(value, result)).toBe(true, `Lists are not equal: valueType=${listType ? listType._elementType : 
+                        null}, put value=${TestingHelper.printValue(value)}, get value=${TestingHelper.printValue(result)}`);
+    }
+
+    async function putGetObjectArrays(arrayType, value) {
+        const key = new Date();
+        const cache = await igniteClient.getCache(CACHE_NAME).
+            setValueType(arrayType);
+        await cache.put(key, value);
+        let result = await cache.get(key);
+        expect(result instanceof Array).toBe(true,
+            `result is not Array: arrayType=${arrayType}, result=${result}`);
+        expect(await TestingHelper.compare(value, result)).toBe(true, `Arrays are not equal: valueType=${arrayType ? arrayType._elementType : 
+                        null}, put value=${TestingHelper.printValue(value)}, get value=${TestingHelper.printValue(result)}`);
+    }
+
+    async function testSuiteCleanup(done) {
+        await TestingHelper.destroyCache(CACHE_NAME, done);
+    }
+});


Mime
View raw message