#ignite-965: code style test-cache-api.js
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e7375e93 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e7375e93 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e7375e93 Branch: refs/heads/ignite-965 Commit: e7375e936d08eee4c88ecafec2a995a5527075d4 Parents: 094b605 Author: ivasilinets <ivasilin...@gridgain.com> Authored: Tue Jun 23 20:28:00 2015 +0300 Committer: ivasilinets <ivasilin...@gridgain.com> Committed: Tue Jun 23 20:28:00 2015 +0300 ---------------------------------------------------------------------- .../nodejs/src/test/js/simple-compute-task.js | 61 ---------- modules/nodejs/src/test/js/test-cache-api.js | 4 - modules/nodejs/src/test/js/test.js | 116 ------------------- 3 files changed, 181 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7375e93/modules/nodejs/src/test/js/simple-compute-task.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/js/simple-compute-task.js b/modules/nodejs/src/test/js/simple-compute-task.js deleted file mode 100644 index d7eb91d..0000000 --- a/modules/nodejs/src/test/js/simple-compute-task.js +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - */ - -function CharacterCountTask() { -} - -CharacterCountTask.prototype.map = function(nodes, arg) { - var words = arg.split(" "); - - var results = []; - - var nodeId = 0; - - function compute(args) { - println(">>> Printing " + args); - - return args[0].length; - } - - - for (var word of words) { - var node = nodes[nodeId]; - - if (nodeId < nodes.length - 1) { - nodeId++; - } - - var TestUtils = require("./test-utils").TestUtils; - var Apache = require(TestUtils.scriptPath()); - var ComputeJob = Apache.ComputeJob; - results.push(new ComputeJob(compute, [word], node)); - } - - return results; -} - -CharacterCountTask.prototype.reduce = function(results) { - var sum = 0; - - for (var res of results) { - sum += parseInt(res, 10); - } - - return sum; -} - -exports.CharacterCountTask = CharacterCountTask http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7375e93/modules/nodejs/src/test/js/test-cache-api.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/js/test-cache-api.js b/modules/nodejs/src/test/js/test-cache-api.js index 48ff011..1101493 100644 --- a/modules/nodejs/src/test/js/test-cache-api.js +++ b/modules/nodejs/src/test/js/test-cache-api.js @@ -17,10 +17,6 @@ var TestUtils = require("./test-utils").TestUtils; -var Apache = require(TestUtils.scriptPath()); -var Cache = Apache.Cache; -var Server = Apache.Server; - var assert = require("assert"); testPutGet = function() { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e7375e93/modules/nodejs/src/test/js/test.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/js/test.js b/modules/nodejs/src/test/js/test.js deleted file mode 100644 index 7485072..0000000 --- a/modules/nodejs/src/test/js/test.js +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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. - */ - -module.exports = { - 'Test put/get' : function(test) { - test.expect(1); - - var TestUtils = require("./test_utils").TestUtils; - var Cache = require(TestUtils.scriptPath() + "cache").Cache; - var Server = require(TestUtils.scriptPath() + "server").Server; - - var assert = require('assert'); - - var node = startIgniteNode(); - - setTimeout(initCache, 10000); - - function initCache() { - var server = new Server('127.0.0.1', 9090); - var cache = new Cache(server, "mycache"); - cache.put("mykey", "6", onPut.bind(null, cache)); - } - - function onPut(cache, error) { - if (error) { - console.error("Failed to put " + error); - finishTest(test, node); - return; - } - - console.log("Put finished"); - cache.get("mykey", onGet); - } - - function onGet(error, value) { - if (error) { - console.error("Failed to get " + error); - finishTest(test, node); - return; - } - - console.log("Get finished"); - test.ok(value === "6", "This shouldn't fail " + value + "<>6"); - finishTest(test, node); - } - }, - 'Test connection' : function(test) { - test.expect(0); - - var node = startIgniteNode(); - var TestUtils = require("./test_utils").TestUtils; - var Server = require(TestUtils.scriptPath() + "server").Server; - - setTimeout(initServer, 10000); - - function initServer() { - var server = new Server('127.0.0.1', 9090); - - console.log("Try to check connection"); - - server.checkConnection(onConnect); - } - - function onConnect(error) { - if (error) { - finishWithError(test/*, node*/, error); - return; - } - console.log("Successfully connected"); - finishTest(test, node); - } - }, - 'Test ignition' : function(test) { - test.expect(1); - - var node = startIgniteNode('127.0.0.1', 9090); - var TestUtils = require("./test_utils").TestUtils; - var Ignition = require(TestUtils.scriptPath() + "ignition").Ignition; - - setTimeout(Ignition.start.bind(null, 9090, ['127.0.0.0', '127.0.0.1'], onConnect), 5000); - - function onConnect(error, server) { - if (error) { - finishWithError(test, node, error); - return; - } - test.ok(server.host() === '127.0.0.1') - finishTest(test, node); - } - } - }; - -function finishWithError(test, node, error) { - console.log("Error: " + error); - test.ok(false); - finishTest(test, node); -} - -function finishTest(test, node) { - node.kill(); - test.done(); -} \ No newline at end of file