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/23 19:47:45 UTC

[19/20] incubator-ignite git commit: #ignite-965: code style test-ignition.js

#ignite-965: code style test-ignition.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/d7e54650
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/d7e54650
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/d7e54650

Branch: refs/heads/ignite-965
Commit: d7e546502d90922cfe4efb20c236505b4e718106
Parents: e7375e9
Author: ivasilinets <iv...@gridgain.com>
Authored: Tue Jun 23 20:33:37 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Tue Jun 23 20:33:37 2015 +0300

----------------------------------------------------------------------
 modules/nodejs/src/test/js/test-ignition.js | 91 +++++++++++-----------
 modules/nodejs/src/test/js/test-key.js      |  4 -
 modules/nodejs/src/test/js/test-node.xml    | 97 ------------------------
 modules/nodejs/src/test/js/test-runner.js   |  1 +
 modules/nodejs/src/test/js/test-utils.js    |  6 +-
 5 files changed, 52 insertions(+), 147 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7e54650/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
index c43e856..3823109 100644
--- a/modules/nodejs/src/test/js/test-ignition.js
+++ b/modules/nodejs/src/test/js/test-ignition.js
@@ -16,76 +16,77 @@
  */
 
 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'], null, onConnect);
+var Ignite = require(TestUtils.scriptPath());
+var Ignition = Ignite.Ignition;
 
-    function onConnect(error, server) {
-        if (error) {
-            if (error.indexOf("Cannot connect to servers.") == -1)
-                TestUtils.testFails("Incorrect error message: " + error);
-            else
-                TestUtils.testDone();
+var assert = require("assert");
 
-            return;
-        }
+testIgnitionFail = function ()  {
+  Ignition.start(['127.0.0.3:9091', '127.0.0.1:9092'], null, onConnect);
+
+  function onConnect(error, server) {
+    if (error) {
+      if (error.indexOf("Cannot connect to servers.") == -1) {
+        TestUtils.testFails("Incorrect error message: " + error);
+      }
+      else {
+        TestUtils.testDone();
+      }
 
-        TestUtils.testFails("Test should fail.");
+      return;
     }
+
+    TestUtils.testFails("Test should fail.");
+  }
 }
 
 ignitionStartSuccess = function() {
-    Ignition.start(['127.0.0.0:9095', '127.0.0.1:9095'], null, onConnect);
+  Ignition.start(['127.0.0.0:9095', '127.0.0.1:9095'], null, onConnect);
 
-    function onConnect(error, server) {
-        if (error) {
-            TestUtils.testFails(error);
+  function onConnect(error, server) {
+    if (error) {
+      TestUtils.testFails(error);
 
-            return;
-        }
-
-        TestUtils.testDone();
+      return;
     }
+
+    TestUtils.testDone();
+  }
 }
 
 ignitionStartSuccessWithSeveralPorts = function() {
-    Ignition.start(['127.0.0.1:9090..9100'], null, onConnect);
+  Ignition.start(['127.0.0.1:9090..9100'], null, onConnect);
 
-    function onConnect(error, ignite) {
-        if (error) {
-            TestUtils.testFails(error);
+  function onConnect(error, ignite) {
+    if (error) {
+      TestUtils.testFails(error);
 
-            return;
-        }
-
-        var assert = require("assert");
+      return;
+    }
 
-        var server = ignite.server();
+    var server = ignite.server();
 
-        var host = server.host();
+    var host = server.host();
 
-        assert.ok(host.indexOf('127.0.0.1') !== -1, "Incorrect host.");
+    assert.ok(host.indexOf('127.0.0.1') !== -1, "Incorrect host.");
 
-        TestUtils.testDone();
-    }
+    TestUtils.testDone();
+  }
 }
 
 ignitionNotStartWithSeveralPorts = function() {
-    Ignition.start(['127.0.0.1:9090...9100'], null, onConnect);
+  Ignition.start(['127.0.0.1:9090...9100'], null, onConnect);
 
-    function onConnect(error, ignite) {
-        if (error) {
-            var assert = require("assert");
+  function onConnect(error, ignite) {
+    if (error) {
+      assert.ok(error.indexOf("Incorrect address format") !== -1, "Incorrect message.")
 
-            assert.ok(error.indexOf("Incorrect address format") !== -1, "Incorrect message.")
+      TestUtils.testDone();
 
-            TestUtils.testDone();
-
-            return;
-        }
-
-        TestUtils.testFails("Exception should be thrown.");
+      return;
     }
+
+    TestUtils.testFails("Exception should be thrown.");
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7e54650/modules/nodejs/src/test/js/test-key.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-key.js b/modules/nodejs/src/test/js/test-key.js
index b39aa51..b02a6b5 100644
--- a/modules/nodejs/src/test/js/test-key.js
+++ b/modules/nodejs/src/test/js/test-key.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");
 
 testStartWithoutKey = function() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7e54650/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
deleted file mode 100644
index a1a17e4..0000000
--- a/modules/nodejs/src/test/js/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/d7e54650/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
index 471df11..9ee1092 100644
--- a/modules/nodejs/src/test/js/test-runner.js
+++ b/modules/nodejs/src/test/js/test-runner.js
@@ -39,6 +39,7 @@ TestRunner.runTest = function() {
         console.log("node js test failed: function with name " + functionName + " not found");
         return;
     }
+
     global[functionName]();
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7e54650/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
index ee83d7f..ae2f0f0 100644
--- a/modules/nodejs/src/test/js/test-utils.js
+++ b/modules/nodejs/src/test/js/test-utils.js
@@ -59,16 +59,20 @@ TestUtils.classpath = function(dir) {
   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 {
+      }
+      else {
         if (file.indexOf(".jar") !== -1) {
           results.push(file);
         }