You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/06/08 11:38:25 UTC
incubator-ignite git commit: #nodejs: rename directories nodejs to js.
Repository: incubator-ignite
Updated Branches:
refs/heads/nodejs 628f0a91c -> 0e197f2b3
#nodejs: rename directories nodejs to 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/0e197f2b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/0e197f2b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/0e197f2b
Branch: refs/heads/nodejs
Commit: 0e197f2b3ebb5b1c9ea85bdad0f2e37853722408
Parents: 628f0a9
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jun 8 12:38:14 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jun 8 12:38:14 2015 +0300
----------------------------------------------------------------------
modules/nodejs/src/main/js/cache.js | 73 ++++++++++
modules/nodejs/src/main/js/ignition.js | 67 +++++++++
modules/nodejs/src/main/js/server.js | 113 +++++++++++++++
modules/nodejs/src/main/nodejs/cache.js | 73 ----------
modules/nodejs/src/main/nodejs/ignition.js | 67 ---------
modules/nodejs/src/main/nodejs/server.js | 113 ---------------
.../ignite/internal/NodeJsAbstractTest.java | 2 +-
modules/nodejs/src/test/js/rest-jetty.xml | 71 ++++++++++
modules/nodejs/src/test/js/test-node.xml | 97 +++++++++++++
modules/nodejs/src/test/js/test.js | 116 +++++++++++++++
modules/nodejs/src/test/js/test_ignition.js | 49 +++++++
modules/nodejs/src/test/js/test_put_get.js | 50 +++++++
modules/nodejs/src/test/js/test_utils.js | 142 +++++++++++++++++++
modules/nodejs/src/test/nodejs/rest-jetty.xml | 71 ----------
modules/nodejs/src/test/nodejs/test-node.xml | 97 -------------
modules/nodejs/src/test/nodejs/test.js | 116 ---------------
modules/nodejs/src/test/nodejs/test_ignition.js | 49 -------
modules/nodejs/src/test/nodejs/test_put_get.js | 50 -------
modules/nodejs/src/test/nodejs/test_utils.js | 142 -------------------
19 files changed, 779 insertions(+), 779 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/modules/nodejs/src/main/js/cache.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/cache.js b/modules/nodejs/src/main/js/cache.js
new file mode 100644
index 0000000..9ee6f9c
--- /dev/null
+++ b/modules/nodejs/src/main/js/cache.js
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+/**
+ * Creates an instance of Cache
+ *
+ * @constructor
+ * @this {Cache}
+ * @param {Server} server Server class
+ * @param {string} cacheName Cache name
+ */
+function Cache(server, cacheName) {
+ this._server = server;
+ this._cacheName = cacheName;
+ this._cacheNameParam = _pair("cacheName", this._cacheName);
+}
+
+/**
+ * Get cache value
+ *
+ * @this {Cache}
+ * @param {string} key Key
+ * @param {Cache~onGet} callback Called on finish
+ */
+Cache.prototype.get = function(key, callback) {
+ this._server.runCommand("get", [this._cacheNameParam, _pair("key", key)], callback);
+};
+
+/**
+ * Callback for cache get
+ * @callback Cache~onGet
+ * @param {string} error Error
+ * @param {string} result Result value
+ */
+
+/**
+ * Put cache value
+ *
+ * @this {Cache}
+ * @param {string} key Key
+ * @param {string} value Value
+ * @param {Cache~onPut} callback Called on finish
+ */
+Cache.prototype.put = function(key, value, callback) {
+ this._server.runCommand("put", [this._cacheNameParam, _pair("key", key), _pair("val", value)],
+ callback);
+}
+
+/**
+ * Callback for cache put
+ * @callback Cache~onPut
+ * @param {string} error Error
+ */
+
+function _pair(key, value) {
+ return {key: key, value: value}
+}
+
+exports.Cache = Cache
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/modules/nodejs/src/main/js/ignition.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/ignition.js b/modules/nodejs/src/main/js/ignition.js
new file mode 100644
index 0000000..6cb6e72
--- /dev/null
+++ b/modules/nodejs/src/main/js/ignition.js
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+/**
+ * Creates an instance of Ignition
+ *
+ * @constructor
+ */
+function Ignition() {
+}
+
+/**
+ * Callback for Ignition start
+ *
+ * @callback Ignition~onStart
+ * @param {string} error Error
+ * @param {Server} server Connected server
+ */
+
+/**
+ * Open connection with server node
+ *
+ * @param {string[]} address List of nodes hosts with ports
+ * @param {Ignition~onStart} callback Called on finish
+ */
+Ignition.start = function(address, callback) {
+ var Server = require("./server").Server;
+ var numConn = address.length;
+ for (var addr of address) {
+ var params = addr.split(":");
+ var server = new Server(params[0], params[1]);
+ server.checkConnection(onConnect.bind(null, server));
+ }
+
+ function onConnect(server, error) {
+ if (!callback)
+ return;
+
+ numConn--;
+ if (!error) {
+ callback.call(null, null, server);
+ callback = null;
+ return;
+ }
+
+ console.log(error);
+
+ if (!numConn)
+ callback.call(null, "Cannot connect to servers.", null);
+ }
+}
+
+exports.Ignition = Ignition;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/modules/nodejs/src/main/js/server.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/server.js b/modules/nodejs/src/main/js/server.js
new file mode 100644
index 0000000..7bdb360
--- /dev/null
+++ b/modules/nodejs/src/main/js/server.js
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ */
+
+/**
+ * Creates an instance of Server
+ *
+ * @constructor
+ * @this {Server}
+ * @param {string} host Host address
+ * @param {number} port Port
+ */
+function Server(host, port) {
+ this._host = host;
+ this._port = port;
+}
+
+/**
+ * Host value
+ *
+ * @this {Server}
+ * @returns {string} Host value
+ */
+Server.prototype.host = function()
+{
+ return this._host;
+}
+
+/**
+ * Callback for Server runCommand
+ *
+ * @callback Server~onRunCommand
+ * @param {string} error Error
+ * @param {string} result Result value
+ */
+
+/**
+ * Run http request
+ *
+ * @this {Server}
+ * @param {string} cmdName command name.
+ * @param params Parameters for command.
+ * @param {Server~onRunCommand} Called on finish
+ */
+Server.prototype.runCommand = function(cmdName, params, callback) {
+ var paramsString = "";
+
+ for (var p of params)
+ //TODO: escape value
+ paramsString += "&" + p.key + "=" + p.value;
+
+ var requestQry = "cmd=" + cmdName + paramsString;
+
+ var http = require('http');
+
+ var options = {
+ host: this._host,
+ port: this._port,
+ path: "/ignite?" + requestQry
+ };
+
+ function streamCallback(response) {
+ var fullResponseString = '';
+
+ response.on('data', function (chunk) {
+ fullResponseString += chunk;
+ });
+
+ response.on('end', function () {
+ try {
+ var response = JSON.parse(fullResponseString);
+ if (response.successStatus)
+ callback.call(null, response.error, null)
+ else
+ callback.call(null, null, response.response);
+ } catch (e) {
+ callback.call(null, e, null);
+ }
+ });
+ }
+
+ var request = http.request(options, streamCallback);
+
+ request.setTimeout(5000, callback.bind(null, "Request timeout: >5 sec"));
+
+ request.on('error', callback);
+ request.end();
+}
+
+/**
+ * Check the connection with server node.
+ *
+ * @this {Server}
+ * @param {Server~onRunCommand} callback Called on finish
+ */
+Server.prototype.checkConnection = function(callback) {
+ this.runCommand("version", [], callback);
+}
+
+exports.Server = Server;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/modules/nodejs/src/main/nodejs/cache.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/nodejs/cache.js b/modules/nodejs/src/main/nodejs/cache.js
deleted file mode 100644
index 9ee6f9c..0000000
--- a/modules/nodejs/src/main/nodejs/cache.js
+++ /dev/null
@@ -1,73 +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.
- */
-
-/**
- * Creates an instance of Cache
- *
- * @constructor
- * @this {Cache}
- * @param {Server} server Server class
- * @param {string} cacheName Cache name
- */
-function Cache(server, cacheName) {
- this._server = server;
- this._cacheName = cacheName;
- this._cacheNameParam = _pair("cacheName", this._cacheName);
-}
-
-/**
- * Get cache value
- *
- * @this {Cache}
- * @param {string} key Key
- * @param {Cache~onGet} callback Called on finish
- */
-Cache.prototype.get = function(key, callback) {
- this._server.runCommand("get", [this._cacheNameParam, _pair("key", key)], callback);
-};
-
-/**
- * Callback for cache get
- * @callback Cache~onGet
- * @param {string} error Error
- * @param {string} result Result value
- */
-
-/**
- * Put cache value
- *
- * @this {Cache}
- * @param {string} key Key
- * @param {string} value Value
- * @param {Cache~onPut} callback Called on finish
- */
-Cache.prototype.put = function(key, value, callback) {
- this._server.runCommand("put", [this._cacheNameParam, _pair("key", key), _pair("val", value)],
- callback);
-}
-
-/**
- * Callback for cache put
- * @callback Cache~onPut
- * @param {string} error Error
- */
-
-function _pair(key, value) {
- return {key: key, value: value}
-}
-
-exports.Cache = Cache
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/modules/nodejs/src/main/nodejs/ignition.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/nodejs/ignition.js b/modules/nodejs/src/main/nodejs/ignition.js
deleted file mode 100644
index 6cb6e72..0000000
--- a/modules/nodejs/src/main/nodejs/ignition.js
+++ /dev/null
@@ -1,67 +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.
- */
-
-/**
- * Creates an instance of Ignition
- *
- * @constructor
- */
-function Ignition() {
-}
-
-/**
- * Callback for Ignition start
- *
- * @callback Ignition~onStart
- * @param {string} error Error
- * @param {Server} server Connected server
- */
-
-/**
- * Open connection with server node
- *
- * @param {string[]} address List of nodes hosts with ports
- * @param {Ignition~onStart} callback Called on finish
- */
-Ignition.start = function(address, callback) {
- var Server = require("./server").Server;
- var numConn = address.length;
- for (var addr of address) {
- var params = addr.split(":");
- var server = new Server(params[0], params[1]);
- server.checkConnection(onConnect.bind(null, server));
- }
-
- function onConnect(server, error) {
- if (!callback)
- return;
-
- numConn--;
- if (!error) {
- callback.call(null, null, server);
- callback = null;
- return;
- }
-
- console.log(error);
-
- if (!numConn)
- callback.call(null, "Cannot connect to servers.", null);
- }
-}
-
-exports.Ignition = Ignition;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/modules/nodejs/src/main/nodejs/server.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/nodejs/server.js b/modules/nodejs/src/main/nodejs/server.js
deleted file mode 100644
index 7bdb360..0000000
--- a/modules/nodejs/src/main/nodejs/server.js
+++ /dev/null
@@ -1,113 +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.
- */
-
-/**
- * Creates an instance of Server
- *
- * @constructor
- * @this {Server}
- * @param {string} host Host address
- * @param {number} port Port
- */
-function Server(host, port) {
- this._host = host;
- this._port = port;
-}
-
-/**
- * Host value
- *
- * @this {Server}
- * @returns {string} Host value
- */
-Server.prototype.host = function()
-{
- return this._host;
-}
-
-/**
- * Callback for Server runCommand
- *
- * @callback Server~onRunCommand
- * @param {string} error Error
- * @param {string} result Result value
- */
-
-/**
- * Run http request
- *
- * @this {Server}
- * @param {string} cmdName command name.
- * @param params Parameters for command.
- * @param {Server~onRunCommand} Called on finish
- */
-Server.prototype.runCommand = function(cmdName, params, callback) {
- var paramsString = "";
-
- for (var p of params)
- //TODO: escape value
- paramsString += "&" + p.key + "=" + p.value;
-
- var requestQry = "cmd=" + cmdName + paramsString;
-
- var http = require('http');
-
- var options = {
- host: this._host,
- port: this._port,
- path: "/ignite?" + requestQry
- };
-
- function streamCallback(response) {
- var fullResponseString = '';
-
- response.on('data', function (chunk) {
- fullResponseString += chunk;
- });
-
- response.on('end', function () {
- try {
- var response = JSON.parse(fullResponseString);
- if (response.successStatus)
- callback.call(null, response.error, null)
- else
- callback.call(null, null, response.response);
- } catch (e) {
- callback.call(null, e, null);
- }
- });
- }
-
- var request = http.request(options, streamCallback);
-
- request.setTimeout(5000, callback.bind(null, "Request timeout: >5 sec"));
-
- request.on('error', callback);
- request.end();
-}
-
-/**
- * Check the connection with server node.
- *
- * @this {Server}
- * @param {Server~onRunCommand} callback Called on finish
- */
-Server.prototype.checkConnection = function(callback) {
- this.runCommand("version", [], callback);
-}
-
-exports.Server = Server;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/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 01abc22..b5e96f3 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
@@ -89,7 +89,7 @@ public class NodeJsAbstractTest extends GridCommonAbstractTest {
sep + "nodejs" +
sep + "src" +
sep + "test" +
- sep + "nodejs" + sep;
+ sep + "js" + sep;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/modules/nodejs/src/test/js/rest-jetty.xml
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/rest-jetty.xml b/modules/nodejs/src/test/js/rest-jetty.xml
new file mode 100644
index 0000000..d292d06
--- /dev/null
+++ b/modules/nodejs/src/test/js/rest-jetty.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
+<Configure id="Server" class="org.eclipse.jetty.server.Server">
+ <Arg name="threadPool">
+ <!-- Default queued blocking thread pool -->
+ <New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
+ <Set name="minThreads">20</Set>
+ <Set name="maxThreads">200</Set>
+ </New>
+ </Arg>
+ <New id="httpCfg" class="org.eclipse.jetty.server.HttpConfiguration">
+ <Set name="secureScheme">https</Set>
+ <Set name="securePort">8443</Set>
+ <Set name="sendServerVersion">true</Set>
+ <Set name="sendDateHeader">true</Set>
+ </New>
+ <Call name="addConnector">
+ <Arg>
+ <New class="org.eclipse.jetty.server.ServerConnector">
+ <Arg name="server"><Ref refid="Server"/></Arg>
+ <Arg name="factories">
+ <Array type="org.eclipse.jetty.server.ConnectionFactory">
+ <Item>
+ <New class="org.eclipse.jetty.server.HttpConnectionFactory">
+ <Ref refid="httpCfg"/>
+ </New>
+ </Item>
+ </Array>
+ </Arg>
+ <Set name="host">
+ <SystemProperty name="IGNITE_JETTY_HOST" default="localhost"/>
+ </Set>
+ <Set name="port">
+ <SystemProperty name="IGNITE_JETTY_PORT" default="9090"/>
+ </Set>
+ <Set name="idleTimeout">30000</Set>
+ <Set name="reuseAddress">true</Set>
+ </New>
+ </Arg>
+ </Call>
+ <Set name="handler">
+ <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
+ <Set name="handlers">
+ <Array type="org.eclipse.jetty.server.Handler">
+ <Item>
+ <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
+ </Item>
+ </Array>
+ </Set>
+ </New>
+ </Set>
+ <Set name="stopAtShutdown">false</Set>
+</Configure>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/modules/nodejs/src/test/js/test-node.xml
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-node.xml b/modules/nodejs/src/test/js/test-node.xml
new file mode 100644
index 0000000..a1a17e4
--- /dev/null
+++ b/modules/nodejs/src/test/js/test-node.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<!--
+ Ignite configuration with all defaults and enabled p2p deployment and enabled events.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <!-- Set to true to enable distributed class loading for examples, default is false. -->
+ <property name="peerClassLoadingEnabled" value="true"/>
+
+ <property name="cacheConfiguration">
+ <list>
+ <!-- Partitioned cache example configuration (Atomic mode). -->
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="mycache"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+ </bean>
+ </list>
+ </property>
+
+ <property name="marshaller">
+ <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
+ <!-- Set to false to allow non-serializable objects in examples, default is true. -->
+ <property name="requireSerializable" value="false"/>
+ </bean>
+ </property>
+
+ <property name="connectorConfiguration">
+ <bean class="org.apache.ignite.configuration.ConnectorConfiguration">
+ <property name="jettyPath" value="rest-jetty.xml"/>
+ </bean>
+ </property>
+
+ <!-- Enable task execution events for examples. -->
+ <property name="includeEventTypes">
+ <list>
+ <!--Task execution events-->
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
+
+ <!--Cache events-->
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
+ <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <!--
+ Ignite provides several options for automatic discovery that can be used
+ instead os static IP based discovery. For information on all options refer
+ to our documentation: http://apacheignite.readme.io/docs/cluster-config
+ -->
+ <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
+ <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <constructor-arg>
+ <value>true</value>
+ </constructor-arg>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/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
new file mode 100644
index 0000000..7485072
--- /dev/null
+++ b/modules/nodejs/src/test/js/test.js
@@ -0,0 +1,116 @@
+/*
+ * 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
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/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..e1e18cc
--- /dev/null
+++ b/modules/nodejs/src/test/js/test_ignition.js
@@ -0,0 +1,49 @@
+/*
+ * 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 Ignition = require(TestUtils.scriptPath() + "ignition").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:9090', '127.0.0.1:9090'], 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/0e197f2b/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..af3695b
--- /dev/null
+++ b/modules/nodejs/src/test/js/test_put_get.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 Cache = require(TestUtils.scriptPath() + "cache").Cache;
+var Server = require(TestUtils.scriptPath() + "server").Server;
+
+testPutGet = function() {
+ var server = new Server('127.0.0.1', 9090);
+ var cache = new Cache(server, "mycache");
+ cache.put("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/0e197f2b/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..a37c0ed
--- /dev/null
+++ b/modules/nodejs/src/test/js/test_utils.js
@@ -0,0 +1,142 @@
+/*
+ * 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.")
+}
+
+/**
+ * Test routine.
+ */
+TestUtils.runTest = function() {
+ var fileName = process.argv[2].toString().trim();
+ 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]();
+}
+
+exports.TestUtils = TestUtils;
+
+TestUtils.runTest();
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/modules/nodejs/src/test/nodejs/rest-jetty.xml
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/nodejs/rest-jetty.xml b/modules/nodejs/src/test/nodejs/rest-jetty.xml
deleted file mode 100644
index d292d06..0000000
--- a/modules/nodejs/src/test/nodejs/rest-jetty.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
-<Configure id="Server" class="org.eclipse.jetty.server.Server">
- <Arg name="threadPool">
- <!-- Default queued blocking thread pool -->
- <New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
- <Set name="minThreads">20</Set>
- <Set name="maxThreads">200</Set>
- </New>
- </Arg>
- <New id="httpCfg" class="org.eclipse.jetty.server.HttpConfiguration">
- <Set name="secureScheme">https</Set>
- <Set name="securePort">8443</Set>
- <Set name="sendServerVersion">true</Set>
- <Set name="sendDateHeader">true</Set>
- </New>
- <Call name="addConnector">
- <Arg>
- <New class="org.eclipse.jetty.server.ServerConnector">
- <Arg name="server"><Ref refid="Server"/></Arg>
- <Arg name="factories">
- <Array type="org.eclipse.jetty.server.ConnectionFactory">
- <Item>
- <New class="org.eclipse.jetty.server.HttpConnectionFactory">
- <Ref refid="httpCfg"/>
- </New>
- </Item>
- </Array>
- </Arg>
- <Set name="host">
- <SystemProperty name="IGNITE_JETTY_HOST" default="localhost"/>
- </Set>
- <Set name="port">
- <SystemProperty name="IGNITE_JETTY_PORT" default="9090"/>
- </Set>
- <Set name="idleTimeout">30000</Set>
- <Set name="reuseAddress">true</Set>
- </New>
- </Arg>
- </Call>
- <Set name="handler">
- <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
- <Set name="handlers">
- <Array type="org.eclipse.jetty.server.Handler">
- <Item>
- <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
- </Item>
- </Array>
- </Set>
- </New>
- </Set>
- <Set name="stopAtShutdown">false</Set>
-</Configure>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/modules/nodejs/src/test/nodejs/test-node.xml
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/nodejs/test-node.xml b/modules/nodejs/src/test/nodejs/test-node.xml
deleted file mode 100644
index a1a17e4..0000000
--- a/modules/nodejs/src/test/nodejs/test-node.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<!--
- Ignite configuration with all defaults and enabled p2p deployment and enabled events.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <!-- Set to true to enable distributed class loading for examples, default is false. -->
- <property name="peerClassLoadingEnabled" value="true"/>
-
- <property name="cacheConfiguration">
- <list>
- <!-- Partitioned cache example configuration (Atomic mode). -->
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="mycache"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- </bean>
- </list>
- </property>
-
- <property name="marshaller">
- <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
- <!-- Set to false to allow non-serializable objects in examples, default is true. -->
- <property name="requireSerializable" value="false"/>
- </bean>
- </property>
-
- <property name="connectorConfiguration">
- <bean class="org.apache.ignite.configuration.ConnectorConfiguration">
- <property name="jettyPath" value="rest-jetty.xml"/>
- </bean>
- </property>
-
- <!-- Enable task execution events for examples. -->
- <property name="includeEventTypes">
- <list>
- <!--Task execution events-->
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
-
- <!--Cache events-->
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
- <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <!--
- Ignite provides several options for automatic discovery that can be used
- instead os static IP based discovery. For information on all options refer
- to our documentation: http://apacheignite.readme.io/docs/cluster-config
- -->
- <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
- <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <constructor-arg>
- <value>true</value>
- </constructor-arg>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/modules/nodejs/src/test/nodejs/test.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/nodejs/test.js b/modules/nodejs/src/test/nodejs/test.js
deleted file mode 100644
index 7485072..0000000
--- a/modules/nodejs/src/test/nodejs/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
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e197f2b/modules/nodejs/src/test/nodejs/test_ignition.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/nodejs/test_ignition.js b/modules/nodejs/src/test/nodejs/test_ignition.js
deleted file mode 100644
index e1e18cc..0000000
--- a/modules/nodejs/src/test/nodejs/test_ignition.js
+++ /dev/null
@@ -1,49 +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 Ignition = require(TestUtils.scriptPath() + "ignition").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:9090', '127.0.0.1:9090'], 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/0e197f2b/modules/nodejs/src/test/nodejs/test_put_get.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/nodejs/test_put_get.js b/modules/nodejs/src/test/nodejs/test_put_get.js
deleted file mode 100644
index af3695b..0000000
--- a/modules/nodejs/src/test/nodejs/test_put_get.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 Cache = require(TestUtils.scriptPath() + "cache").Cache;
-var Server = require(TestUtils.scriptPath() + "server").Server;
-
-testPutGet = function() {
- var server = new Server('127.0.0.1', 9090);
- var cache = new Cache(server, "mycache");
- cache.put("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/0e197f2b/modules/nodejs/src/test/nodejs/test_utils.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/nodejs/test_utils.js b/modules/nodejs/src/test/nodejs/test_utils.js
deleted file mode 100644
index 1383a84..0000000
--- a/modules/nodejs/src/test/nodejs/test_utils.js
+++ /dev/null
@@ -1,142 +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() + "nodejs" + 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.")
-}
-
-/**
- * Test routine.
- */
-TestUtils.runTest = function() {
- var fileName = process.argv[2].toString().trim();
- 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]();
-}
-
-exports.TestUtils = TestUtils;
-
-TestUtils.runTest();
\ No newline at end of file