Repository: incubator-ignite Updated Branches: refs/heads/ignite-nodejs f441e4633 -> 5658d35b3
#nodejs: rename files. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/5658d35b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5658d35b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5658d35b Branch: refs/heads/ignite-nodejs Commit: 5658d35b3c8ace4b5e2e7c9dd54748f8eb7b1756 Parents: f441e46 Author: ivasilinets <ivasilin...@gridgain.com> Authored: Mon Jun 8 14:59:36 2015 +0300 Committer: ivasilinets <ivasilin...@gridgain.com> Committed: Mon Jun 8 14:59:36 2015 +0300 ---------------------------------------------------------------------- .../ignite/internal/NodeJsAbstractTest.java | 2 +- .../ignite/internal/NodeJsIgnitionSelfTest.java | 2 +- .../ignite/internal/NodeJsPutGetSelfTest.java | 2 +- modules/nodejs/src/test/js/test-ignition.js | 50 ++++++++ modules/nodejs/src/test/js/test-put-get.js | 52 ++++++++ modules/nodejs/src/test/js/test-runner.js | 45 +++++++ modules/nodejs/src/test/js/test-utils.js | 126 +++++++++++++++++++ modules/nodejs/src/test/js/test_ignition.js | 50 -------- modules/nodejs/src/test/js/test_put_get.js | 52 -------- modules/nodejs/src/test/js/test_runner.js | 45 ------- modules/nodejs/src/test/js/test_utils.js | 126 ------------------- 11 files changed, 276 insertions(+), 276 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5658d35b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsAbstractTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsAbstractTest.java index bf29d11..7d82f61 100644 --- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsAbstractTest.java +++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsAbstractTest.java @@ -119,7 +119,7 @@ public class NodeJsAbstractTest extends GridCommonAbstractTest { cmd.add("node"); - cmd.add(getNodeJsTestDir() + "test_runner.js"); + cmd.add(getNodeJsTestDir() + "test-runner.js"); cmd.add(fileName); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5658d35b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgnitionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgnitionSelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgnitionSelfTest.java index 9bc0d32..6f4a4ea 100644 --- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgnitionSelfTest.java +++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgnitionSelfTest.java @@ -23,7 +23,7 @@ package org.apache.ignite.internal; public class NodeJsIgnitionSelfTest extends NodeJsAbstractTest { /** Constructor. */ public NodeJsIgnitionSelfTest() { - super("test_ignition.js"); + super("test-ignition.js"); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5658d35b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsPutGetSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsPutGetSelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsPutGetSelfTest.java index 3c6a819..92fe258 100644 --- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsPutGetSelfTest.java +++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsPutGetSelfTest.java @@ -23,7 +23,7 @@ package org.apache.ignite.internal; public class NodeJsPutGetSelfTest extends NodeJsAbstractTest { /** Constructor. */ public NodeJsPutGetSelfTest() { - super("test_put_get.js"); + super("test-put-get.js"); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5658d35b/modules/nodejs/src/test/js/test-ignition.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/js/test-ignition.js b/modules/nodejs/src/test/js/test-ignition.js new file mode 100644 index 0000000..ce7c253 --- /dev/null +++ b/modules/nodejs/src/test/js/test-ignition.js @@ -0,0 +1,50 @@ +/* + * 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. + */ + +var TestUtils = require("./test-utils").TestUtils; +var Apache = require(TestUtils.scriptPath()); +var Ignition = Apache.Ignition; + +testIgnitionFail = function () { + Ignition.start(['127.0.0.3:9091', '127.0.0.1:9092'], onConnect); + + function onConnect(error, server) { + if (error) { + if (error.indexOf("Cannot connect to servers.") == -1) + TestUtils.testFails("Incorrect error message: " + error); + else + TestUtils.testDone(); + + return; + } + + TestUtils.testFails("Test should fail."); + } +} + +ignitionStartSuccess = function() { + Ignition.start(['127.0.0.0:9095', '127.0.0.1:9095'], onConnect); + + function onConnect(error, server) { + if (error) { + TestUtils.testFails(error); + + return; + } + TestUtils.testDone(); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5658d35b/modules/nodejs/src/test/js/test-put-get.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/js/test-put-get.js b/modules/nodejs/src/test/js/test-put-get.js new file mode 100644 index 0000000..10205d5 --- /dev/null +++ b/modules/nodejs/src/test/js/test-put-get.js @@ -0,0 +1,52 @@ +/* + * 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. + */ + +var TestUtils = require("./test-utils").TestUtils; + +var Apache = require(TestUtils.scriptPath()); +var Cache = Apache.Cache; +var Server = Apache.Server; + +testPutGet = function() { + var server = new Server('127.0.0.1', 9095); + var cache = new Cache(server, "mycache"); + cache.put("key", "6", onPut.bind(null, cache)); +} + +function onPut(cache, error) { + if (error) { + TestUtils.testFails("Incorrect error message: " + error); + return; + } + + console.log("Put finished"); + cache.get("key", onGet); +} + +function onGet(error, value) { + if (error) { + console.error("Failed to get " + error); + TestUtils.testFails("Incorrect error message: " + error); + return; + } + + var assert = require("assert"); + + assert.equal(value, 6, "Get return incorrect value. + [expected=" + 6 + ", val=" + value + "]."); + + TestUtils.testDone(); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5658d35b/modules/nodejs/src/test/js/test-runner.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/js/test-runner.js b/modules/nodejs/src/test/js/test-runner.js new file mode 100644 index 0000000..471df11 --- /dev/null +++ b/modules/nodejs/src/test/js/test-runner.js @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Create instance of TestRunner + * + * @constructor + */ +function TestRunner() { +} + +/** + * Test routine + */ +TestRunner.runTest = function() { + var fileName = process.argv[2].toString().trim(); + + console.log("FileName " + fileName); + + require("./" + fileName); + + var functionName = process.argv[3].toString().trim(); + + if (!global[functionName]) { + console.log("node js test failed: function with name " + functionName + " not found"); + return; + } + global[functionName](); +} + +TestRunner.runTest(); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5658d35b/modules/nodejs/src/test/js/test-utils.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/js/test-utils.js b/modules/nodejs/src/test/js/test-utils.js new file mode 100644 index 0000000..9534ce6 --- /dev/null +++ b/modules/nodejs/src/test/js/test-utils.js @@ -0,0 +1,126 @@ +/* + * 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. + */ + +/** + * Create instance of TestUtils + * + * @constructor + */ +function TestUtils() { +} + +/** + * @returns {string} Path to script dir + */ +TestUtils.scriptPath = function() { + return TestUtils.igniteHome() + + TestUtils.sep() + "modules" + + TestUtils.sep() + "nodejs" + + TestUtils.sep() + "src" + + TestUtils.sep() + "main" + + TestUtils.sep() + "js" + TestUtils.sep(); +} + +/** + * @returns {string} Ignite home path + */ +TestUtils.igniteHome = function() { + return process.env.IGNITE_HOME; +} + +/** + * @returns {string} Path separator + */ +TestUtils.sep = function() { + return require('path').sep; +} + +/** + * @param {string} dir Directory with all ignite libs + * @returns {string} Classpath for ignite node start + */ +TestUtils.classpath = function(dir) { + var fs = require('fs'); + var path = require('path'); + function walk(dir, done) { + var results = []; + var list = fs.readdirSync(dir) + for (var i = 0; i < list.length; ++i) { + file = path.resolve(dir, list[i]); + var stat = fs.statSync(file); + if (stat && stat.isDirectory()) { + if (list[i] != "optional" && file.indexOf("optional") !== -1 && file.indexOf("rest") == -1 ) + continue; + + var sublist = walk(file); + results = results.concat(sublist); + } else { + if (file.indexOf(".jar") !== -1) { + results.push(file); + } + } + } + return results; + }; + + return walk(dir); +}; + +/** + * @returns Process that starts ignite node + */ +TestUtils.startIgniteNode = function() { + var libs = classpath(igniteHome() + TestUtils.sep() + "target" + + TestUtils.sep() + "bin" + + TestUtils.sep() + "apache-ignite-fabric-1.1.1-SNAPSHOT-bin" + + TestUtils.sep() + "libs"); + + var cp = libs.join(require('path').delimiter); + + var spawn = require('child_process').spawn; + + var child = spawn('java',['-classpath', cp, 'org.apache.ignite.startup.cmdline.CommandLineStartup', + "test-node.xml"]); + + child.stdout.on('data', function (data) { + console.log("" + data); + }); + + child.stderr.on('data', function (data) { + console.log("" + data); + }); + + return child; +} + +/** + * Print error to console + * + * @param {string} error Error + */ +TestUtils.testFails = function(error) { + console.log("Node JS test failed: " + error); +} + +/** + * Print ok message to console + */ +TestUtils.testDone = function() { + console.log("Node JS test finished.") +} + +exports.TestUtils = TestUtils; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5658d35b/modules/nodejs/src/test/js/test_ignition.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/js/test_ignition.js b/modules/nodejs/src/test/js/test_ignition.js deleted file mode 100644 index c17663d..0000000 --- a/modules/nodejs/src/test/js/test_ignition.js +++ /dev/null @@ -1,50 +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. - */ - -var TestUtils = require("./test_utils").TestUtils; -var Apache = require(TestUtils.scriptPath()); -var Ignition = Apache.Ignition; - -testIgnitionFail = function () { - Ignition.start(['127.0.0.3:9091', '127.0.0.1:9092'], onConnect); - - function onConnect(error, server) { - if (error) { - if (error.indexOf("Cannot connect to servers.") == -1) - TestUtils.testFails("Incorrect error message: " + error); - else - TestUtils.testDone(); - - return; - } - - TestUtils.testFails("Test should fail."); - } -} - -ignitionStartSuccess = function() { - Ignition.start(['127.0.0.0:9095', '127.0.0.1:9095'], onConnect); - - function onConnect(error, server) { - if (error) { - TestUtils.testFails(error); - - return; - } - TestUtils.testDone(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5658d35b/modules/nodejs/src/test/js/test_put_get.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/js/test_put_get.js b/modules/nodejs/src/test/js/test_put_get.js deleted file mode 100644 index c21a0b7..0000000 --- a/modules/nodejs/src/test/js/test_put_get.js +++ /dev/null @@ -1,52 +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. - */ - -var TestUtils = require("./test_utils").TestUtils; - -var Apache = require(TestUtils.scriptPath()); -var Cache = Apache.Cache; -var Server = Apache.Server; - -testPutGet = function() { - var server = new Server('127.0.0.1', 9095); - var cache = new Cache(server, "mycache"); - cache.put("key", "6", onPut.bind(null, cache)); -} - -function onPut(cache, error) { - if (error) { - TestUtils.testFails("Incorrect error message: " + error); - return; - } - - console.log("Put finished"); - cache.get("key", onGet); -} - -function onGet(error, value) { - if (error) { - console.error("Failed to get " + error); - TestUtils.testFails("Incorrect error message: " + error); - return; - } - - var assert = require("assert"); - - assert.equal(value, 6, "Get return incorrect value. + [expected=" + 6 + ", val=" + value + "]."); - - TestUtils.testDone(); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5658d35b/modules/nodejs/src/test/js/test_runner.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/js/test_runner.js b/modules/nodejs/src/test/js/test_runner.js deleted file mode 100644 index 471df11..0000000 --- a/modules/nodejs/src/test/js/test_runner.js +++ /dev/null @@ -1,45 +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. - */ - -/** - * Create instance of TestRunner - * - * @constructor - */ -function TestRunner() { -} - -/** - * Test routine - */ -TestRunner.runTest = function() { - var fileName = process.argv[2].toString().trim(); - - console.log("FileName " + fileName); - - require("./" + fileName); - - var functionName = process.argv[3].toString().trim(); - - if (!global[functionName]) { - console.log("node js test failed: function with name " + functionName + " not found"); - return; - } - global[functionName](); -} - -TestRunner.runTest(); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5658d35b/modules/nodejs/src/test/js/test_utils.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/test/js/test_utils.js b/modules/nodejs/src/test/js/test_utils.js deleted file mode 100644 index 9534ce6..0000000 --- a/modules/nodejs/src/test/js/test_utils.js +++ /dev/null @@ -1,126 +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. - */ - -/** - * Create instance of TestUtils - * - * @constructor - */ -function TestUtils() { -} - -/** - * @returns {string} Path to script dir - */ -TestUtils.scriptPath = function() { - return TestUtils.igniteHome() + - TestUtils.sep() + "modules" + - TestUtils.sep() + "nodejs" + - TestUtils.sep() + "src" + - TestUtils.sep() + "main" + - TestUtils.sep() + "js" + TestUtils.sep(); -} - -/** - * @returns {string} Ignite home path - */ -TestUtils.igniteHome = function() { - return process.env.IGNITE_HOME; -} - -/** - * @returns {string} Path separator - */ -TestUtils.sep = function() { - return require('path').sep; -} - -/** - * @param {string} dir Directory with all ignite libs - * @returns {string} Classpath for ignite node start - */ -TestUtils.classpath = function(dir) { - var fs = require('fs'); - var path = require('path'); - function walk(dir, done) { - var results = []; - var list = fs.readdirSync(dir) - for (var i = 0; i < list.length; ++i) { - file = path.resolve(dir, list[i]); - var stat = fs.statSync(file); - if (stat && stat.isDirectory()) { - if (list[i] != "optional" && file.indexOf("optional") !== -1 && file.indexOf("rest") == -1 ) - continue; - - var sublist = walk(file); - results = results.concat(sublist); - } else { - if (file.indexOf(".jar") !== -1) { - results.push(file); - } - } - } - return results; - }; - - return walk(dir); -}; - -/** - * @returns Process that starts ignite node - */ -TestUtils.startIgniteNode = function() { - var libs = classpath(igniteHome() + TestUtils.sep() + "target" + - TestUtils.sep() + "bin" + - TestUtils.sep() + "apache-ignite-fabric-1.1.1-SNAPSHOT-bin" + - TestUtils.sep() + "libs"); - - var cp = libs.join(require('path').delimiter); - - var spawn = require('child_process').spawn; - - var child = spawn('java',['-classpath', cp, 'org.apache.ignite.startup.cmdline.CommandLineStartup', - "test-node.xml"]); - - child.stdout.on('data', function (data) { - console.log("" + data); - }); - - child.stderr.on('data', function (data) { - console.log("" + data); - }); - - return child; -} - -/** - * Print error to console - * - * @param {string} error Error - */ -TestUtils.testFails = function(error) { - console.log("Node JS test failed: " + error); -} - -/** - * Print ok message to console - */ -TestUtils.testDone = function() { - console.log("Node JS test finished.") -} - -exports.TestUtils = TestUtils;