You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ra...@apache.org on 2015/02/16 09:53:35 UTC

[2/2] thrift git commit: THRIFT-2969 Client: nodejs Patch: Andrew de Andrade

THRIFT-2969
Client: nodejs
Patch: Andrew de Andrade

General node test cleanup and consolidation.


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/3b9ff4de
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/3b9ff4de
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/3b9ff4de

Branch: refs/heads/master
Commit: 3b9ff4de6e38eb2e0e17eacd22865e4b8ce27e37
Parents: 4702fe6
Author: Randy Abernethy <ra...@apache.org>
Authored: Mon Feb 16 00:51:24 2015 -0800
Committer: Randy Abernethy <ra...@apache.org>
Committed: Mon Feb 16 00:51:24 2015 -0800

----------------------------------------------------------------------
 lib/nodejs/test/client.js                     | 127 ++++---
 lib/nodejs/test/helpers.js                    |  13 +
 lib/nodejs/test/http_client.js                |  82 -----
 lib/nodejs/test/http_server.js                |  66 ----
 lib/nodejs/test/multiplex_client.js           |  80 -----
 lib/nodejs/test/multiplex_server.js           |  78 ----
 lib/nodejs/test/server.js                     |  89 +++--
 lib/nodejs/test/test-cases.js                 | 126 +++++++
 lib/nodejs/test/testAll.sh                    | 139 ++-----
 lib/nodejs/test/test_driver.js                | 240 +++++++++++++
 lib/nodejs/test/test_handler.js               | 388 +++++++++++---------
 lib/nodejs/test/test_handler_promise.js       | 198 ----------
 lib/nodejs/test/thrift_test_driver.js         | 324 -----------------
 lib/nodejs/test/thrift_test_driver_promise.js | 398 ---------------------
 lib/nodejs/test/ws_client.js                  |  81 -----
 test/test.sh                                  | 339 ++++++++++--------
 16 files changed, 939 insertions(+), 1829 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/client.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/client.js b/lib/nodejs/test/client.js
old mode 100755
new mode 100644
index b8de7ce..6d512b4
--- a/lib/nodejs/test/client.js
+++ b/lib/nodejs/test/client.js
@@ -1,4 +1,4 @@
-#!/usr/bin/env nodejs
+#!/usr/bin/env node
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,80 +19,111 @@
  * under the License.
  */
 
-//This is the client side test for the standard Apache Thrift
-//"ThriftTest" suite. This client will test any protocol/transport
-//combination specified on the command line.
-
 var fs = require('fs');
 var assert = require('assert');
 var thrift = require('thrift');
+var helpers = require('./helpers');
 var ThriftTest = require('./gen-nodejs/ThriftTest');
-var ThriftTestDriver = require('./thrift_test_driver').ThriftTestDriver;
-var ThriftTestDriverPromise = require('./thrift_test_driver_promise').ThriftTestDriver;
+var ThriftTestDriver = require('./test_driver').ThriftTestDriver;
+var ThriftTestDriverPromise = require('./test_driver').ThriftTestDriverPromise;
+var SecondService = require('./gen-nodejs/SecondService');
+var ttypes = require('./gen-nodejs/ThriftTest_types');
 
 var program = require('commander');
 
 program
   .option('-p, --protocol <protocol>', 'Set thrift protocol (binary|json) [protocol]')
   .option('-t, --transport <transport>', 'Set thrift transport (buffered|framed) [transport]')
-  .option('--port <port>', 'Set thift server port number to connect')
-  .option('--host <host>', 'Set thift server host to connect')
+  .option('--port <port>', 'Set thift server port number to connect', 9090)
+  .option('--host <host>', 'Set thift server host to connect', 'localhost')
   .option('--ssl', 'use SSL transport')
   .option('--promise', 'test with promise style functions')
+  .option('-t, --type <type>', 'Select server type (tcp|multiplex|http)', 'tcp')
   .parse(process.argv);
 
-var host = "localhost";
-if(String(program.host) === "undefined") {
-}else{
-   host = program.host;
-}
+var host = program.host;
+var port = program.port;
+var type = program.type;
+var ssl = program.ssl;
+var promise = program.promise;
 
-var port = 9090;
-if(String(program.port) === "undefined") {
-}else{
-  port = program.port;
-}
+var options = {
+  transport: helpers.transports[program.transport],
+  protocol: helpers.protocols[program.protocol]
+};
 
-var protocol = thrift.TBinaryProtocol;
-if (program.protocol === "json") {
-  protocol = thrift.TJSONProtocol;
-} else if (program.protocol === "compact") {
-  protocol = thrift.TCompactProtocol;
+if (type === 'http' || type === 'websocket') {
+  options.path = '/test';
 }
 
-var transport =  thrift.TBufferedTransport;
-if (program.transport === "framed") {
-  transport = thrift.TFramedTransport;
+if (type === 'http') {
+  options.headers = {"Connection": "close"};
 }
 
-var options = {
-  transport: transport,
-  protocol: protocol
-};
+if (ssl) {
+  if (type === 'tcp' || type === 'multiplex') {
+    options.rejectUnauthorized = false;
+  } else if (type === 'http') {
+    options.nodeOptions = { rejectUnauthorized: false };
+    options.https = true;
+  } else if (type === 'websocket') {
+    options.wsOptions = { rejectUnauthorized: false };
+    options.secure = true;
+  }
+}
 
 var connection;
-
-if (program.ssl) {
-  options.rejectUnauthorized = false;
-  connection = thrift.createSSLConnection(host, port, options);
-} else {
-  connection = thrift.createConnection(host,port, options);
+var client;
+var testDriver = promise ? ThriftTestDriverPromise : ThriftTestDriver;
+
+if (type === 'tcp' || type === 'multiplex') {
+  connection = ssl ?
+    thrift.createSSLConnection(host, port, options) :
+    thrift.createConnection(host, port, options);
+} else if (type === 'http') {
+  connection = thrift.createHttpConnection(host, port, options);
+} else if (type === 'websocket') {
+  connection = thrift.createWSConnection(host, port, options);
+  connection.open();
 }
 
-var client = thrift.createClient(ThriftTest, connection);
-
 connection.on('error', function(err) {
-  assert(false, err);
+    assert(false, err);
 });
 
-var testDriver = ThriftTestDriver;
-if (program.promise) {
-  testDriver = ThriftTestDriverPromise;
+if (type === 'tcp') {
+  client = thrift.createClient(ThriftTest, connection);
+  runTests();
+} else if (type === 'multiplex') {
+  var mp = new thrift.Multiplexer();
+  client = mp.createClient("ThriftTest", ThriftTest, connection);
+  secondclient = mp.createClient("SecondService", SecondService, connection);
+
+  connection.on('connect', function() {
+    secondclient.secondtestString("Test", function(err, response) {
+      assert(!err);
+      assert.equal("Test", response);
+    });
+
+    runTests();
+  });
+} else if (type === 'http') {
+  client = thrift.createHttpClient(ThriftTest, connection);
+  runTests();
+} else if (type === 'websocket') {
+  client = thrift.createWSClient(ThriftTest, connection);
+  runTests();
+}
+
+function runTests() {
+  testDriver(client, function (status) {
+    console.log(status);
+    if (type === 'http' || type === 'websocket') {
+      process.exit(0);
+    } else {
+      connection.end();
+    }
+  });
 }
-testDriver(client, function (status) {
-  console.log(status);
-  connection.end();
-});
 
-// to make it also run on expresso
 exports.expressoTest = function() {};

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/helpers.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/helpers.js b/lib/nodejs/test/helpers.js
new file mode 100644
index 0000000..c850c46
--- /dev/null
+++ b/lib/nodejs/test/helpers.js
@@ -0,0 +1,13 @@
+'use strict';
+var thrift = require('../lib/thrift');
+
+module.exports.transports = {
+  'buffered': thrift.TBufferedTransport,
+  'framed': thrift.TFramedTransport
+};
+
+module.exports.protocols = {
+  'json': thrift.TJSONProtocol,
+  'binary': thrift.TBinaryProtocol,
+  'compact': thrift.TCompactProtocol
+};

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/http_client.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/http_client.js b/lib/nodejs/test/http_client.js
deleted file mode 100644
index 9ab05d8..0000000
--- a/lib/nodejs/test/http_client.js
+++ /dev/null
@@ -1,82 +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.
- */
-
-//This is the client side test for the standard Apache Thrift
-//"ThriftTest" suite. This client will test any protocol/transport
-//combination specified on the command line.
-
-var fs = require('fs');
-var assert = require('assert');
-var thrift = require('thrift');
-var ThriftTest = require('./gen-nodejs/ThriftTest');
-var ThriftTestDriver = require('./thrift_test_driver').ThriftTestDriver;
-var ThriftTestDriverPromise = require('./thrift_test_driver_promise').ThriftTestDriver;
-
-var program = require('commander');
-
-program
-  .option('-p, --protocol <protocol>', 'Set thrift protocol (binary|json) [protocol]')
-  .option('-t, --transport <transport>', 'Set thrift transport (buffered|framed) [transport]')
-  .option('--ssl', 'use SSL transport')
-  .option('--promise', 'test with promise style functions')
-  .parse(process.argv);
-
-
-var protocol = thrift.TBinaryProtocol;
-if (program.protocol === "json") {
-  protocol = thrift.TJSONProtocol;
-}
-
-var transport =  thrift.TBufferedTransport;
-if (program.transport === "framed") {
-  transport = thrift.TFramedTransport;
-}
-
-var options = {
-   transport: transport,
-   protocol: protocol,
-   headers: {"Connection": "close"},
-   path: "/test"
-};
-
-if (program.ssl) {
-  options.nodeOptions = { rejectUnauthorized: false };
-  options.https = true;
-}
-
-var connection = thrift.createHttpConnection("localhost", 9090, options);
-
-var client = thrift.createHttpClient(ThriftTest, connection);
-
-connection.on('error', function(err) {
-  assert(false, err);
-});
-
-var testDriver = ThriftTestDriver;
-if (program.promise) {
-  console.log("    --Testing promise style client");
-  testDriver = ThriftTestDriverPromise;
-}
-testDriver(client, function (status) {
-  console.log(status);
-  process.exit(0);
-});
-
-// to make it also run on expresso
-exports.expressoTest = function() {};

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/http_server.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/http_server.js b/lib/nodejs/test/http_server.js
deleted file mode 100644
index 3519f4a..0000000
--- a/lib/nodejs/test/http_server.js
+++ /dev/null
@@ -1,66 +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 fs = require('fs');
-var path = require('path');
-var thrift = require('thrift');
-var ThriftTest = require('./gen-nodejs/ThriftTest');
-var ThriftTestHandler = require('./test_handler').ThriftTestHandler;
-var ThriftTestHandlerPromise = require('./test_handler_promise').ThriftTestHandler;
-
-var program = require('commander');
-
-program
-  .option('-p, --protocol <protocol>', 'Set thift protocol (binary|json) [protocol]')
-  .option('-t, --transport <transport>', 'Set thift transport (buffered|framed) [transport]')
-  .option('--ssl', 'use ssl transport')
-  .option('--promise', 'test with promise style functions')
-  .parse(process.argv);
-
-var transport =  thrift.TBufferedTransport;
-if (program.transport === "framed") {
-  transport = thrift.TFramedTransport;
-}
-
-var protocol = thrift.TBinaryProtocol;
-if (program.protocol === "json") {
-  protocol = thrift.TJSONProtocol;
-}
-
-var handler = ThriftTestHandler;
-if (program.promise) {
-  handler = ThriftTestHandlerPromise;
-}
-
-var SvcOpt = {
-    handler: handler,
-    processor: ThriftTest,
-    protocol: protocol,
-    transport: transport
-};
-var serverOpt = { services: { "/test": SvcOpt } };
-if (program.ssl) {
-  serverOpt.tls = {
-    key: fs.readFileSync(path.resolve(__dirname, 'server.key')),
-    cert: fs.readFileSync(path.resolve(__dirname, 'server.crt'))
-  };
-}
-thrift.createWebServer(serverOpt).listen(9090);
-
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/multiplex_client.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/multiplex_client.js b/lib/nodejs/test/multiplex_client.js
deleted file mode 100644
index 7004f93..0000000
--- a/lib/nodejs/test/multiplex_client.js
+++ /dev/null
@@ -1,80 +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 thrift = require('thrift');
-var assert = require('assert');
-
-var ThriftTest = require('./gen-nodejs/ThriftTest'),
-    SecondService = require('./gen-nodejs/SecondService'),
-    ttypes = require('./gen-nodejs/ThriftTest_types');
-var ThriftTestDriver = require('./thrift_test_driver').ThriftTestDriver;
-
-var program = require('commander');
-
-program
-  .option('-p, --protocol <protocol>', 'Set thift protocol (binary|json) [protocol]')
-  .option('-t, --transport <transport>', 'Set thift transport (buffered|framed) [transport]')
-  .option('--ssl', 'use ssl transport')
-  .parse(process.argv);
-
-var transport =  thrift.TBufferedTransport;
-if (program.transport === "framed") {
-  transport = thrift.TFramedTransport;
-}
-
-var protocol = thrift.TBinaryProtocol;
-if (program.protocol === "json") {
-  protocol = thrift.TJSONProtocol;
-}
-
-var options = {
-  transport: transport,
-  protocol: protocol
-};
-
-var connection;
-if (program.ssl) {
-  options.rejectUnauthorized = false;
-  connection = thrift.createSSLConnection('localhost', 9090, options);
-} else {
-  connection = thrift.createConnection('localhost', 9090, options);
-}
-
-var mp = new thrift.Multiplexer();
-
-client = mp.createClient("ThriftTest", ThriftTest, connection);
-secondclient = mp.createClient("SecondService", SecondService, connection);
-
-connection.on('error', function(err) {
-    assert(false, err);
-});
-
-connection.on('connect', function() {
-  secondclient.secondtestString("Test", function(err, response) {
-    assert(!err);
-    assert.equal("Test", response);
-  });
-
-  ThriftTestDriver(client, function (status) {
-    console.log(status);
-    connection.end();
-  });
-});
-
-// to make it also run on expresso
-exports.expressoTest = function() {};

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/multiplex_server.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/multiplex_server.js b/lib/nodejs/test/multiplex_server.js
deleted file mode 100644
index 18f9b0d..0000000
--- a/lib/nodejs/test/multiplex_server.js
+++ /dev/null
@@ -1,78 +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 thrift = require('thrift');
-
-var ThriftTest = require('./gen-nodejs/ThriftTest'),
-  SecondService = require('./gen-nodejs/SecondService'),
-  ttypes = require('./gen-nodejs/ThriftTest_types');
-
-var fs = require("fs");
-var path = require("path");
-
-var program = require('commander');
-
-program
-  .option('-p, --protocol <protocol>', 'Set thift protocol (binary|json) [protocol]')
-  .option('-t, --transport <transport>', 'Set thift transport (buffered|framed) [transport]')
-  .option('--ssl', 'use ssl transport')
-  .parse(process.argv);
-
-var protocol = thrift.TBinaryProtocol;
-if (program.protocol === "json") {
-  protocol = thrift.TJSONProtocol;
-}
-
-var transport =  thrift.TBufferedTransport;
-if (program.transport === "framed") {
-  transport = thrift.TFramedTransport;
-}
-
-var ThriftTestHandler = require("./test_handler").ThriftTestHandler;
-
-var SecondServiceHandler = {
-  secondtestString: function(thing, result) {
-    console.log('testString(\'' + thing + '\')');
-    result(null, thing);
-  }
-};
-
-var processor = new thrift.MultiplexedProcessor();
-
-processor.registerProcessor(
-  "ThriftTest",
-  new ThriftTest.Processor(ThriftTestHandler));
-
-processor.registerProcessor(
-  "SecondService",
-  new SecondService.Processor(SecondServiceHandler));
-
-var options = {
-  transport: transport,
-  protocol: protocol
-};
-
-if (program.ssl) {
-  //ssl options
-  options.tls = {
-    key: fs.readFileSync(path.resolve(__dirname, 'server.key')),
-    cert: fs.readFileSync(path.resolve(__dirname, 'server.crt'))
-  };
-}
-
-thrift.createMultiplexServer(processor, options).listen(9090);

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/server.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/server.js b/lib/nodejs/test/server.js
old mode 100755
new mode 100644
index b6d28c7..2d53e11
--- a/lib/nodejs/test/server.js
+++ b/lib/nodejs/test/server.js
@@ -1,4 +1,4 @@
-#!/usr/bin/env nodejs
+#!/usr/bin/env node
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -21,53 +21,78 @@
 
 var fs = require('fs');
 var path = require('path');
-var thrift = require('thrift');
-var ThriftTest = require('./gen-nodejs/ThriftTest');
-var ThriftTestHandler = require('./test_handler').ThriftTestHandler;
-var ThriftTestHandlerPromise = require('./test_handler_promise').ThriftTestHandler;
-
+var thrift = require('../lib/thrift');
 var program = require('commander');
+var helpers = require('./helpers');
+
+var ThriftTest = require('./gen-nodejs/ThriftTest');
+var SecondService = require('./gen-nodejs/SecondService');
+var ThriftTestHandler = require('./test_handler').AsyncThriftTestHandler;
+var ThriftTestHandlerPromise = require('./test_handler').SyncThriftTestHandler;
+var ttypes = require('./gen-nodejs/ThriftTest_types');
 
 program
-  .option('-p, --protocol <protocol>', 'Set thift protocol (binary|json) [protocol]')
-  .option('-t, --transport <transport>', 'Set thift transport (buffered|framed) [transport]')
-  .option('--port <port>', 'Set thift server port')
+  .option('-p, --protocol <protocol>', 'Set thift protocol (binary|json|compact)', 'binary')
+  .option('-t, --transport <transport>', 'Set thift transport (buffered|framed)', 'buffered')
   .option('--ssl', 'use ssl transport')
+  .option('--port <port>', 'Set thift server port', 9090)
   .option('--promise', 'test with promise style functions')
+  .option('-t, --type <type>', 'Select server type (tcp|multiplex|http)', 'tcp')
   .parse(process.argv);
 
-var transport =  thrift.TBufferedTransport;
-if (program.transport === "framed") {
-  transport = thrift.TFramedTransport;
-}
+var port = program.port;
+var type = program.type;
+var ssl = program.ssl;
+var promise = program.promise;
 
-var protocol = thrift.TBinaryProtocol;
-if (program.protocol === "json") {
-  protocol = thrift.TJSONProtocol;
-} else if (program.protocol === "compact") {
-  protocol = thrift.TCompactProtocol;
-}
+var handler = program.promise ? ThriftTestHandler : ThriftTestHandlerPromise;
+
+var options = {
+  transport: helpers.transports[program.transport],
+  protocol: helpers.protocols[program.protocol]
+};
+
+if (type === 'http' || type ==='websocket') {
+  options.handler = handler;
+  options.processor = ThriftTest;
 
-var port = 9090;
-if (String(program.port) === "undefined"){
-} else {
-  port = program.port;
+  options = {
+    services: { "/test": options }
+  }
 }
 
-var handler = ThriftTestHandler;
-if (program.promise) {
-  handler = ThriftTestHandlerPromise;
+if (type === 'multiplex') {
+  var SecondServiceHandler = {
+    secondtestString: function(thing, result) {
+      console.log('testString(\'' + thing + '\')');
+      result(null, thing);
+    }
+  };
+
+  var processor = new thrift.MultiplexedProcessor();
+
+  processor.registerProcessor("ThriftTest",
+    new ThriftTest.Processor(ThriftTestHandler));
+
+  processor.registerProcessor("SecondService",
+    new SecondService.Processor(SecondServiceHandler));
+
 }
 
-var options = {
-  protocol: protocol,
-  transport: transport
-};
-if (program.ssl) {
+if (ssl) {
   options.tls = {
     key: fs.readFileSync(path.resolve(__dirname, 'server.key')),
     cert: fs.readFileSync(path.resolve(__dirname, 'server.crt'))
   };
 }
-thrift.createServer(ThriftTest, handler, options).listen(port);
 
+var server;
+if (type === 'tcp') {
+  server = thrift.createServer(ThriftTest, handler, options);
+} else if (type === 'multiplex') {
+  server = thrift.createMultiplexServer(processor, options);
+} else if (type === 'http' || type === 'websocket') {
+  server = thrift.createWebServer(options);
+}
+
+server.listen(port);

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/test-cases.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/test-cases.js b/lib/nodejs/test/test-cases.js
new file mode 100644
index 0000000..3386657
--- /dev/null
+++ b/lib/nodejs/test/test-cases.js
@@ -0,0 +1,126 @@
+'use strict';
+
+var assert = require('assert');
+var ttypes = require('./gen-nodejs/ThriftTest_types');
+
+//all Languages in UTF-8
+/*jshint -W100 */
+var stringTest = module.exports.stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, " +
+    "Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, " +
+    "Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, " +
+    "বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, " +
+    "Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, " +
+    "Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, " +
+    "Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, " +
+    "Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, " +
+    "Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, " +
+    "Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, " +
+    "Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, " +
+    "ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, " +
+    "Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, " +
+    "Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa " +
+    "Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, مازِرونی, Bahasa " +
+    "Melayu, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪" +
+    "Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, " +
+    "Occitan, Иронау, Papiamentu, Deitsch, Polski, پنجابی, پښتو, " +
+    "Norfuk / Pitkern, Português, Runa Simi, Rumantsch, Romani, Română, " +
+    "Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple " +
+    "English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, " +
+    "Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, " +
+    "Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, " +
+    "Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, " +
+    "Bân-lâm-gú, 粵語";
+/*jshint +W100 */
+
+var specialCharacters = module.exports.specialCharacters = 'quote: \" backslash:' +
+    ' forwardslash-escaped: \/ ' +
+    ' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
+    ' now-all-of-them-together: "\\\/\b\n\r\t' +
+    ' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><' +
+    ' char-to-test-json-parsing: ]] \"]] \\" }}}{ [[[ ';
+
+var mapTestInput = module.exports.mapTestInput = {
+  "a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
+  "longValue":stringTest, stringTest:"long key"
+};
+
+var simple = [
+  ['testVoid', undefined],
+  ['testString', 'Test'],
+  ['testString', ''],
+  ['testString', stringTest],
+  ['testString', specialCharacters],
+  ['testByte', 1],
+  ['testByte', 0],
+  ['testByte', -1],
+  ['testByte', -127],
+  ['testI32', -1],
+  ['testI64', 5],
+  ['testI64', -5],
+  ['testI64', 734359738368],
+  ['testI64', -34359738368],
+  ['testI64', -734359738368],
+  ['testDouble', -5.2098523],
+  ['testDouble', 7.012052175215044],
+  ['testEnum', ttypes.Numberz.ONE],
+  ['testTypedef', 69]
+];
+
+
+var mapout = {};
+for (var i = 0; i < 5; ++i) {
+  mapout[i] = i-10;
+}
+
+var mapMapTest = {
+  "4": {"1":1, "2":2, "3":3, "4":4},
+  "-4": {"-4":-4, "-3":-3, "-2":-2, "-1":-1}
+};
+
+var deep = [
+  ['testMap', mapout],
+  ['testSet', [1,2,3]],
+  ['testList', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]],
+  ['testMapMap', mapMapTest],
+  ['testStringMap', mapTestInput]
+];
+
+var out = new ttypes.Xtruct({
+  string_thing: 'Zero',
+  byte_thing: 1,
+  i32_thing: -3,
+  i64_thing: 1000000
+});
+
+var out2 = new ttypes.Xtruct2();
+out2.byte_thing = 1;
+out2.struct_thing = out;
+out2.i32_thing = 5;
+
+var crazy = new ttypes.Insanity({
+  "userMap":{ "5":5, "8":8 },
+  "xtructs":[new ttypes.Xtruct({
+      "string_thing":"Goodbye4",
+      "byte_thing":4,
+      "i32_thing":4,
+      "i64_thing":4
+    }), new ttypes.Xtruct({
+      "string_thing":"Hello2",
+      "byte_thing":2,
+      "i32_thing":2,
+      "i64_thing":2
+    })]
+});
+
+var insanity = {
+  "1":{ "2": crazy, "3": crazy },
+  "2":{ "6":{ "userMap":{}, "xtructs":[] } }
+};
+
+module.exports.simple = simple;
+module.exports.deep = deep;
+
+module.exports.out = out;
+module.exports.out2 = out2;
+module.exports.crazy = crazy;
+module.exports.insanity = insanity;

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/testAll.sh
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/testAll.sh b/lib/nodejs/test/testAll.sh
index cf66099..0d10758 100755
--- a/lib/nodejs/test/testAll.sh
+++ b/lib/nodejs/test/testAll.sh
@@ -1,6 +1,5 @@
 #! /bin/sh
 
-
 # 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
@@ -17,7 +16,6 @@
 # KIND, either express or implied. See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
 
 if [ -n "${1}" ]; then
   COVER=${1};
@@ -34,97 +32,28 @@ COUNT=0
 
 export NODE_PATH="${DIR}:${DIR}/../lib:${NODE_PATH}"
 
-testClientServer()
-{
-  echo "   Testing Client/Server with protocol $1 and transport $2 $3";
-  RET=0
-  if [ -n "${COVER}" ]; then
-    ${ISTANBUL} cover ${DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- -p $1 -t $2 $3 &
-    COUNT=$((COUNT+1))
-  else
-    node ${DIR}/server.js -p $1 -t $2 $3 &
-  fi
-  SERVERPID=$!
-  sleep 1
-  if [ -n "${COVER}" ]; then
-    ${ISTANBUL} cover ${DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} -- -p $1 -t $2 $3 || RET=1
-    COUNT=$((COUNT+1))
-  else
-    node ${DIR}/client.js -p $1 -t $2 $3 || RET=1
-  fi
-  kill -2 $SERVERPID || RET=1
-  return $RET
-}
-
-testMultiplexedClientServer()
+testServer()
 {
-  echo "   Testing Multiplexed Client/Server with protocol $1 and transport $2 $3";
+  echo "   Testing $1 Client/Server with protocol $2 and transport $3 $4";
   RET=0
   if [ -n "${COVER}" ]; then
-    ${ISTANBUL} cover ${DIR}/multiplex_server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- -p $1 -t $2 $3 &
+    ${ISTANBUL} cover ${DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- --type $1 -p $2 -t $3 $4 &
     COUNT=$((COUNT+1))
   else
-    node ${DIR}/multiplex_server.js -p $1 -t $2 $3 &
+    node ${DIR}/server.js --type $1 -p $2 -t $3 $4 &
   fi
   SERVERPID=$!
   sleep 1
   if [ -n "${COVER}" ]; then
-    ${ISTANBUL} cover ${DIR}/multiplex_client.js --dir ${REPORT_PREFIX}${COUNT} -- -p $1 -t $2 $3 || RET=1
+    ${ISTANBUL} cover ${DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} -- --type $1 -p $2 -t $3 $4 || RET=1
     COUNT=$((COUNT+1))
   else
-    node ${DIR}/multiplex_client.js -p $1 -t $2 $3 || RET=1
+    node ${DIR}/client.js --type $1 -p $2 -t $3 $4 || RET=1
   fi
   kill -2 $SERVERPID || RET=1
   return $RET
 }
 
-testHttpClientServer()
-{
-  echo "   Testing HTTP Client/Server with protocol $1 and transport $2 $3";
-  RET=0
-  if [ -n "${COVER}" ]; then
-    ${ISTANBUL} cover ${DIR}/http_server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- -p $1 -t $2 $3 &
-    COUNT=$((COUNT+1))
-  else
-    node ${DIR}/http_server.js -p $1 -t $2 $3 &
-  fi
-  SERVERPID=$!
-  sleep 1
-  if [ -n "${COVER}" ]; then
-    ${ISTANBUL} cover ${DIR}/http_client.js --dir ${REPORT_PREFIX}${COUNT} -- -p $1 -t $2 $3 || RET=1
-    COUNT=$((COUNT+1))
-  else
-    node ${DIR}/http_client.js -p $1 -t $2 $3 || RET=1
-  fi
-
-  kill -2 $SERVERPID || RET=1
-  sleep 1
-  return $RET
-}
-
-testWSClientServer()
-{
-  echo "   Testing WebSocket Client/Server with protocol $1 and transport $2 $3";
-  RET=0
-  if [ -n "${COVER}" ]; then
-    ${ISTANBUL} cover ${DIR}/http_server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- -p $1 -t $2 $3 &
-    COUNT=$((COUNT+1))
-  else
-    node ${DIR}/http_server.js -p $1 -t $2 $3 &
-  fi
-  SERVERPID=$!
-  sleep 1
-  if [ -n "${COVER}" ]; then
-    ${ISTANBUL} cover ${DIR}/ws_client.js --dir ${REPORT_PREFIX}${COUNT} -- -p $1 -t $2 $3 || RET=1
-    COUNT=$((COUNT+1))
-  else
-    node ${DIR}/ws_client.js -p $1 -t $2 $3 || RET=1
-  fi
-
-  kill -2 $SERVERPID || RET=1
-  return $RET
-}
-
 TESTOK=0
 
 #generating thrift code
@@ -137,50 +66,22 @@ ${NODEUNIT} ${DIR}/binary.test.js || TESTOK=1
 
 #integration tests
 
-#TCP connection tests
-testClientServer compact buffered || TESTOK=1
-testClientServer compact framed || TESTOK=1
-testClientServer binary buffered || TESTOK=1
-testClientServer json buffered || TESTOK=1
-testClientServer binary framed || TESTOK=1
-testClientServer json framed || TESTOK=1
-
-#tests for multiplexed services
-testMultiplexedClientServer binary buffered || TESTOK=1
-testMultiplexedClientServer json buffered || TESTOK=1
-testMultiplexedClientServer binary framed || TESTOK=1
-testMultiplexedClientServer compact framed || TESTOK=1
-
-#test ssl connection
-testClientServer binary framed --ssl || TESTOK=1
-testMultiplexedClientServer binary framed --ssl || TESTOK=1
-
-#test promise style
-testClientServer binary framed --promise || TESTOK=1
-testClientServer compact buffered --promise || TESTOK=1
-
-#HTTP tests
-testHttpClientServer compact buffered || TESTOK=1
-testHttpClientServer compact framed || TESTOK=1
-testHttpClientServer json buffered || TESTOK=1
-testHttpClientServer json framed || TESTOK=1
-testHttpClientServer binary buffered || TESTOK=1
-testHttpClientServer binary framed || TESTOK=1
-testHttpClientServer json buffered --promise || TESTOK=1
-testHttpClientServer binary framed --ssl || TESTOK=1
-
-#WebSocket tests
-testWSClientServer compact buffered || TESTOK=1
-testWSClientServer compact framed || TESTOK=1
-testWSClientServer json buffered || TESTOK=1
-testWSClientServer json framed || TESTOK=1
-testWSClientServer binary buffered || TESTOK=1
-testWSClientServer binary framed || TESTOK=1
-testWSClientServer json buffered --promise || TESTOK=1
-testWSClientServer binary framed --ssl || TESTOK=1
+for type in tcp multiplex http websocket
+do
+
+  for protocol in compact binary json
+  do
+
+    for transport in buffered framed
+    do
+      testServer $type $protocol $transport || TESTOK=1
+      testServer $type $protocol $transport --ssl || TESTOK=1
+      testServer $type $protocol $transport --promise || TESTOK=1
+    done
+  done
+done
 
 if [ -n "${COVER}" ]; then
-  echo "${DIR}/../coverage/report*/coverage.json"
   ${ISTANBUL} report --dir "${DIR}/../coverage" --include "${DIR}/../coverage/report*/coverage.json" lcov cobertura html
   rm -r ${DIR}/../coverage/report*/*
   rmdir ${DIR}/../coverage/report*

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/test_driver.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/test_driver.js b/lib/nodejs/test/test_driver.js
new file mode 100644
index 0000000..9f2b894
--- /dev/null
+++ b/lib/nodejs/test/test_driver.js
@@ -0,0 +1,240 @@
+/*
+ * 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.
+ */
+
+ // This is the Node.js test driver for the standard Apache Thrift
+ // test service. The driver invokes every function defined in the
+ // Thrift Test service with a representative range of parameters.
+ //
+ // The ThriftTestDriver function requires a client object
+ // connected to a server hosting the Thrift Test service and
+ // supports an optional callback function which is called with
+ // a status message when the test is complete.
+
+var assert = require('assert');
+var ttypes = require('./gen-nodejs/ThriftTest_types');
+var Int64 = require('node-int64');
+var testCases = require('./test-cases');
+
+exports.ThriftTestDriver = function(client, callback) {
+
+  function makeAsserter(assertionFn) {
+    return function(c) {
+      var fnName = c[0];
+      var expected = c[1];
+      client[fnName](expected, function(err, actual) {
+        assert(!err);
+        assertionFn(actual, expected);
+      })
+    };
+  }
+
+  testCases.simple.forEach(makeAsserter(assert.equal));
+  testCases.deep.forEach(makeAsserter(assert.deepEqual));
+
+  client.testStruct(testCases.out, function(err, response) {
+    assert(!err);
+    checkRecursively(testCases.out, response);
+  });
+
+  client.testNest(testCases.out2, function(err, response) {
+    assert(!err);
+    checkRecursively(testCases.out2, response);
+  });
+
+  client.testInsanity(testCases.crazy, function(err, response) {
+    assert(!err);
+    checkRecursively(testCases.insanity, response);
+  });
+
+  client.testException('TException', function(err, response) {
+    assert(!err);
+    assert(!response);
+  });
+
+  client.testException('Xception', function(err, response) {
+    assert(!response);
+    assert.equal(err.errorCode, 1001);
+    assert.equal('Xception', err.message);
+  });
+
+  client.testException('no Exception', function(err, response) {
+    assert(!err);
+    assert.equal(undefined, response); //void
+  });
+
+  client.testOneway(0, function(err, response) {
+    assert(false); //should not answer
+  });
+
+  checkOffByOne(function(done) {
+    client.testI32(-1, function(err, response) {
+      assert(!err);
+      assert.equal(-1, response);
+      done();
+    });
+  }, callback);
+
+};
+
+exports.ThriftTestDriverPromise = function(client, callback) {
+
+  function makeAsserter(assertionFn) {
+    return function(c) {
+      var fnName = c[0];
+      var expected = c[1];
+      client[fnName](expected)
+        .then(function(actual) {
+          assert.equal(actual, expected);
+        })
+        .fail(failTest);
+    };
+  }
+
+  testCases.simple.forEach(makeAsserter(assert.equal));
+  testCases.deep.forEach(makeAsserter(assert.deepEqual));
+
+  client.testStruct(testCases.out)
+    .then(function(response) {
+      checkRecursivelyP(testCases.out, response);
+    })
+    .fail(failTest);
+
+  client.testNest(testCases.out2)
+    .then(function(response) {
+      checkRecursivelyP(testCases.out2, response);
+    })
+    .fail(failTest);
+
+  client.testInsanity(testCases.crazy)
+    .then(function(response) {
+      checkRecursivelyP(testCases.insanity, response);
+    })
+    .fail(failTest);
+
+  client.testException('TException')
+    .then(failTest);
+
+  client.testException('Xception')
+    .then(function(response) {
+      assert.equal(err.errorCode, 1001);
+      assert.equal('Xception', err.message);
+    })
+    .fail(failTest);
+
+  client.testException('no Exception')
+    .then(function(response) {
+      assert.equal(undefined, response); //void
+    })
+    .fail(failTest);
+
+  client.testOneway(0, failTest); //should not answer
+
+  checkOffByOne(function(done) {
+    client.testI32(-1)
+      .then(function(response) {
+          assert.equal(-1, response);
+          done();
+      })
+      .fail(function() {
+        assert(false);
+      });
+  }, callback);
+
+};
+
+
+// Helper Functions
+// =========================================================
+
+function failTest() {
+  assert(false);
+}
+
+// This is the version of checkRecursively that was in the vanilla callback
+// version of test_driver.
+function checkRecursively(map1, map2) {
+  if (typeof map1 !== 'function' && typeof map2 !== 'function') {
+    if (!map1 || typeof map1 !== 'object') {
+      //Handle int64 types (which use node-int64 in Node.js JavaScript)
+      if ((typeof map1 === "number") && (typeof map2 === "object") &&
+          (map2.buffer) && (map2.buffer instanceof Buffer) && (map2.buffer.length === 8)) {
+        var n = new Int64(map2.buffer);
+        assert.equal(map1, n.toNumber());
+      } else {
+        assert.equal(map1, map2);
+      }
+    } else {
+      for (var key in map1) {
+        checkRecursively(map1[key], map2[key]);
+      }
+    }
+  }
+}
+
+// This is the version of checkRecursively that was in the promise version of
+// test_driver.
+// deepEqual doesn't work with fields using node-int64
+function checkRecursivelyP(map1, map2) {
+  if (typeof map1 !== 'function' && typeof map2 !== 'function') {
+    if (!map1 || typeof map1 !== 'object') {
+        assert.equal(map1, map2);
+    } else {
+      for (var key in map1) {
+        checkRecursivelyP(map1[key], map2[key]);
+      }
+    }
+  }
+}
+
+function checkOffByOne(done, callback) {
+
+  var retry_limit = 30;
+  var retry_interval = 100;
+  var test_complete = false;
+  var retrys = 0;
+
+  /**
+   * redo a simple test after the oneway to make sure we aren't "off by one" --
+   * if the server treated oneway void like normal void, this next test will
+   * fail since it will get the void confirmation rather than the correct
+   * result. In this circumstance, the client will throw the exception:
+   *
+   * Because this is the last test against the server, when it completes
+   * the entire suite is complete by definition (the tests run serially).
+   */
+  done(function() {
+    test_complete = true;
+  });
+
+  //We wait up to retry_limit * retry_interval for the test suite to complete
+  function TestForCompletion() {
+    if(test_complete && callback) {
+      callback("Server successfully tested!");
+    } else {
+      if (++retrys < retry_limit) {
+        setTimeout(TestForCompletion, retry_interval);
+      } else if (callback) {
+        callback("Server test failed to complete after " +
+                 (retry_limit * retry_interval / 1000) + " seconds");
+      }
+    }
+  }
+
+  setTimeout(TestForCompletion, retry_interval);
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/test_handler.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/test_handler.js b/lib/nodejs/test/test_handler.js
index fd25120..83b7d41 100644
--- a/lib/nodejs/test/test_handler.js
+++ b/lib/nodejs/test/test_handler.js
@@ -23,177 +23,221 @@
 var ttypes = require('./gen-nodejs/ThriftTest_types');
 var TException = require('thrift').Thrift.TException;
 
-var ThriftTestHandler = exports.ThriftTestHandler = {
-  testVoid: function(result) {
-    console.log('testVoid()');
-    result(null);
-  },
-  testString: function(thing, result) {
-    console.log('testString(\'' + thing + '\')');
-    result(null, thing);
-  },
-  testByte: function(thing, result) {
-    console.log('testByte(' + thing + ')');
-    result(null, thing);
-  },
-  testI32: function(thing, result) {
-    console.log('testI32(' + thing + ')');
-    result(null, thing);
-  },
-  testI64: function(thing, result) {
-    console.log('testI64(' + thing + ')');
-    result(null, thing);
-  },
-  testDouble: function(thing, result) {
-    console.log('testDouble(' + thing + ')');
-    result(null, thing);
-  },
-  testBinary: function(thing, result) {
-    console.log('testBinary(\'' + thing + '\')');
-    result(null, thing);
-  },
-  testStruct: function(thing, result) {
-    console.log('testStruct(');
-    console.log(thing);
-    console.log(')');
-    result(null, thing);
-  },
-  testNest: function(nest, result) {
-    console.log('testNest(');
-    console.log(nest);
-    console.log(')');
-    result(null, nest);
-  },
-  testMap: function(thing, result) {
-    console.log('testMap(');
-    console.log(thing);
-    console.log(')');
-    result(null, thing);
-  },
-  testStringMap: function(thing, result) {
-    console.log('testStringMap(');
-    console.log(thing);
-    console.log(')');
-    result(null, thing);
-  },
-  testSet: function(thing, result) {
-    console.log('testSet(');
-    console.log(thing);
-    console.log(')');
-    result(null, thing);
-  },
-  testList: function(thing, result) {
-    console.log('testList(');
-    console.log(thing);
-    console.log(')');
-    result(null, thing);
-  },
-  testEnum: function(thing, result) {
-    console.log('testEnum(' + thing + ')');
-    result(null, thing);
-  },
-  testTypedef: function(thing, result) {
-    console.log('testTypedef(' + thing + ')');
+function makeSyncHandler(label) {
+  return function(thing) {
+    console.log(label + '(\'' + thing + '\')');
+    return thing;
+  }
+}
+
+var syncHandlers = {
+  testVoid: testVoid,
+  testMapMap: testMapMap,
+  testInsanity: testInsanity,
+  testMulti: testMulti,
+  testException: testException,
+  testMultiException: testMultiException,
+  testOneway: testOneway
+};
+
+function makeAsyncHandler(label) {
+  return function(thing, result) {
+    thing = syncHandlers[label](thing);
     result(null, thing);
-  },
-  testMapMap: function(hello, result) {
-    console.log('testMapMap(' + hello + ')');
-
-    var mapmap = [];
-    var pos = [];
-    var neg = [];
-    for (var i = 1; i < 5; i++) {
-      pos[i] = i;
-      neg[-i] = -i;
-    }
-    mapmap[4] = pos;
-    mapmap[-4] = neg;
-
-    result(null, mapmap);
-  },
-  testInsanity: function(argument, result) {
-    console.log('testInsanity(');
-    console.log(argument);
-    console.log(')');
-
-    var hello = new ttypes.Xtruct();
-    hello.string_thing = 'Hello2';
-    hello.byte_thing = 2;
-    hello.i32_thing = 2;
-    hello.i64_thing = 2;
-
-    var goodbye = new ttypes.Xtruct();
-    goodbye.string_thing = 'Goodbye4';
-    goodbye.byte_thing = 4;
-    goodbye.i32_thing = 4;
-    goodbye.i64_thing = 4;
-
-    var crazy = new ttypes.Insanity();
-    crazy.userMap = [];
-    crazy.userMap[ttypes.Numberz.EIGHT] = 8;
-    crazy.userMap[ttypes.Numberz.FIVE] = 5;
-    crazy.xtructs = [goodbye, hello];
-
-    var first_map = [];
-    var second_map = [];
-
-    first_map[ttypes.Numberz.TWO] = crazy;
-    first_map[ttypes.Numberz.THREE] = crazy;
-
-    var looney = new ttypes.Insanity();
-    second_map[ttypes.Numberz.SIX] = looney;
-
-    var insane = [];
-    insane[1] = first_map;
-    insane[2] = second_map;
-
-    console.log('insane result:');
-    console.log(insane);
-    result(null, insane);
-  },
-  testMulti: function(arg0, arg1, arg2, arg3, arg4, arg5, result) {
-    console.log('testMulti()');
-
-    var hello = new ttypes.Xtruct();
-    hello.string_thing = 'Hello2';
-    hello.byte_thing = arg0;
-    hello.i32_thing = arg1;
-    hello.i64_thing = arg2;
-    result(null, hello);
-  },
-  testException: function(arg, result) {
-    console.log('testException('+arg+')');
-    if (arg === 'Xception') {
-      var x = new ttypes.Xception();
-      x.errorCode = 1001;
-      x.message = arg;
-      result(x);
-    } else if (arg === 'TException') {
-      result(new TException(arg));
-    } else {
-      result(null);
-    }
-  },
-  testMultiException: function(arg0, arg1, result) {
-    console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
-    if (arg0 === ('Xception')) {
-      var x = new ttypes.Xception();
-      x.errorCode = 1001;
-      x.message = 'This is an Xception';
-      result(x);
-    } else if (arg0 === ('Xception2')) {
-      var x2 = new ttypes.Xception2();
-      x2.errorCode = 2002;
-      x2.struct_thing = new ttypes.Xtruct();
-      x2.struct_thing.string_thing = 'This is an Xception2';
-      result(x2);
-    }
-
-    var res = new ttypes.Xtruct();
-    res.string_thing = arg1;
-    result(null, res);
-  },
-  testOneway: function(sleepFor, result) {
-    console.log('testOneway(' + sleepFor + ') => JavaScript (like Rust) never sleeps!');
   }
-};   //ThriftTestSvcHandler
+}
+
+var asyncHandlers = {
+  testVoid: testVoidAsync,
+  testMulti: testMultiAsync,
+  testException: testExceptionAsync,
+  testMultiException: testMultiExceptionAsync,
+  testOneway: testOnewayAsync
+};
+
+var identityHandlers = [
+  'testString',
+  'testByte',
+  'testI32',
+  'testI64',
+  'testDouble',
+  'testStruct',
+  'testNest',
+  'testMap',
+  'testStringMap',
+  'testSet',
+  'testList',
+  'testEnum',
+  'testTypedef'
+];
+
+function testVoid() {
+  console.log('testVoid()');
+}
+
+function testVoidAsync(result) {
+  result(testVoid());
+}
+
+function testMapMap(hello) {
+  console.log('testMapMap(' + hello + ')');
+
+  var mapmap = [];
+  var pos = [];
+  var neg = [];
+  for (var i = 1; i < 5; i++) {
+    pos[i] = i;
+    neg[-i] = -i;
+  }
+  mapmap[4] = pos;
+  mapmap[-4] = neg;
+
+  return mapmap;
+}
+
+function testInsanity(argument) {
+  console.log('testInsanity(');
+  console.log(argument);
+  console.log(')');
+
+  var hello = new ttypes.Xtruct();
+  hello.string_thing = 'Hello2';
+  hello.byte_thing = 2;
+  hello.i32_thing = 2;
+  hello.i64_thing = 2;
+
+  var goodbye = new ttypes.Xtruct();
+  goodbye.string_thing = 'Goodbye4';
+  goodbye.byte_thing = 4;
+  goodbye.i32_thing = 4;
+  goodbye.i64_thing = 4;
+
+  var crazy = new ttypes.Insanity();
+  crazy.userMap = [];
+  crazy.userMap[ttypes.Numberz.EIGHT] = 8;
+  crazy.userMap[ttypes.Numberz.FIVE] = 5;
+  crazy.xtructs = [goodbye, hello];
+
+  var first_map = [];
+  var second_map = [];
+
+  first_map[ttypes.Numberz.TWO] = crazy;
+  first_map[ttypes.Numberz.THREE] = crazy;
+
+  var looney = new ttypes.Insanity();
+  second_map[ttypes.Numberz.SIX] = looney;
+
+  var insane = [];
+  insane[1] = first_map;
+  insane[2] = second_map;
+
+  console.log('insane result:');
+  console.log(insane);
+  return insane;
+}
+
+function testMulti(arg0, arg1, arg2, arg3, arg4, arg5) {
+  console.log('testMulti()');
+
+  var hello = new ttypes.Xtruct();
+  hello.string_thing = 'Hello2';
+  hello.byte_thing = arg0;
+  hello.i32_thing = arg1;
+  hello.i64_thing = arg2;
+  return hello;
+}
+
+function testMultiAsync(arg0, arg1, arg2, arg3, arg4, arg5, result) {
+  var hello = testMulti(arg0, arg1, arg2, arg3, arg4, arg5);
+  result(null, hello);
+}
+
+function testException(arg) {
+  console.log('testException('+arg+')');
+  if (arg === 'Xception') {
+    var x = new ttypes.Xception();
+    x.errorCode = 1001;
+    x.message = arg;
+    throw x;
+  } else if (arg === 'TException') {
+    throw new TException(arg);
+  } else {
+    return;
+  }
+}
+
+function testExceptionAsync(arg, result) {
+  console.log('testException('+arg+')');
+  if (arg === 'Xception') {
+    var x = new ttypes.Xception();
+    x.errorCode = 1001;
+    x.message = arg;
+    result(x);
+  } else if (arg === 'TException') {
+    result(new TException(arg));
+  } else {
+    result(null);
+  }
+}
+
+function testMultiException(arg0, arg1) {
+  console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
+  if (arg0 === ('Xception')) {
+    var x = new ttypes.Xception();
+    x.errorCode = 1001;
+    x.message = 'This is an Xception';
+    throw x;
+  } else if (arg0 === ('Xception2')) {
+    var x2 = new ttypes.Xception2();
+    x2.errorCode = 2002;
+    x2.struct_thing = new ttypes.Xtruct();
+    x2.struct_thing.string_thing = 'This is an Xception2';
+    throw x2;
+  }
+
+  var res = new ttypes.Xtruct();
+  res.string_thing = arg1;
+  return res;
+}
+
+function testMultiExceptionAsync(arg0, arg1, result) {
+  console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
+  if (arg0 === ('Xception')) {
+    var x = new ttypes.Xception();
+    x.errorCode = 1001;
+    x.message = 'This is an Xception';
+    result(x);
+  } else if (arg0 === ('Xception2')) {
+    var x2 = new ttypes.Xception2();
+    x2.errorCode = 2002;
+    x2.struct_thing = new ttypes.Xtruct();
+    x2.struct_thing.string_thing = 'This is an Xception2';
+    result(x2);
+  }
+
+  var res = new ttypes.Xtruct();
+  res.string_thing = arg1;
+  result(null, res);
+}
+
+function testOneway(sleepFor) {
+  console.log('testOneway(' + sleepFor + ') => JavaScript (like Rust) never sleeps!');
+}
+
+function testOnewayAsync(sleepFor, result) {
+  testOneway(sleepFor);
+}
+
+identityHandlers.forEach(function(label) {
+  syncHandlers[label] = makeSyncHandler(label);
+  asyncHandlers[label] = makeAsyncHandler(label);
+});
+
+['testMapMap', 'testInsanity'].forEach(function(label) {
+  asyncHandlers[label] = makeAsyncHandler(label);
+});
+
+exports.ThriftTestHandler = asyncHandlers;
+
+exports.AsyncThriftTestHandler = asyncHandlers;
+exports.SyncThriftTestHandler = asyncHandlers;

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/test_handler_promise.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/test_handler_promise.js b/lib/nodejs/test/test_handler_promise.js
deleted file mode 100644
index cda6558..0000000
--- a/lib/nodejs/test/test_handler_promise.js
+++ /dev/null
@@ -1,198 +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.
- */
-
-//This is the server side Node test handler for the standard
-//  Apache Thrift test service.
-
-var ttypes = require('./gen-nodejs/ThriftTest_types');
-var TException = require('thrift').Thrift.TException;
-
-var ThriftTestHandler = exports.ThriftTestHandler = {
-  testVoid: function() {
-    console.log('testVoid()');
-  },
-  testString: function(thing) {
-    console.log('testString(\'' + thing + '\')');
-    return thing;
-  },
-  testByte: function(thing) {
-    console.log('testByte(' + thing + ')');
-    return thing;
-  },
-  testI32: function(thing) {
-    console.log('testI32(' + thing + ')');
-    return thing;
-  },
-  testI64: function(thing) {
-    console.log('testI64(' + thing + ')');
-    return thing;
-  },
-  testDouble: function(thing) {
-    console.log('testDouble(' + thing + ')');
-    return thing;
-  },
-  testBinary: function(thing) {
-    console.log('testBinary(\'' + thing + '\')');
-    return thing;
-  },
-  testStruct: function(thing) {
-    console.log('testStruct(');
-    console.log(thing);
-    console.log(')');
-    return thing;
-  },
-  testNest: function(nest) {
-    console.log('testNest(');
-    console.log(nest);
-    console.log(')');
-    return nest;
-  },
-  testMap: function(thing) {
-    console.log('testMap(');
-    console.log(thing);
-    console.log(')');
-    return thing;
-  },
-  testStringMap: function(thing) {
-    console.log('testStringMap(');
-    console.log(thing);
-    console.log(')');
-    return thing;
-  },
-  testSet: function(thing, result) {
-    console.log('testSet(');
-    console.log(thing);
-    console.log(')');
-    return thing;
-  },
-  testList: function(thing) {
-    console.log('testList(');
-    console.log(thing);
-    console.log(')');
-    return thing;
-  },
-  testEnum: function(thing) {
-    console.log('testEnum(' + thing + ')');
-    return thing;
-  },
-  testTypedef: function(thing) {
-    console.log('testTypedef(' + thing + ')');
-    return thing;
-  },
-  testMapMap: function(hello) {
-    console.log('testMapMap(' + hello + ')');
-
-    var mapmap = [];
-    var pos = [];
-    var neg = [];
-    for (var i = 1; i < 5; i++) {
-      pos[i] = i;
-      neg[-i] = -i;
-    }
-    mapmap[4] = pos;
-    mapmap[-4] = neg;
-
-    return mapmap;
-  },
-  testInsanity: function(argument) {
-    console.log('testInsanity(');
-    console.log(argument);
-    console.log(')');
-
-    var hello = new ttypes.Xtruct();
-    hello.string_thing = 'Hello2';
-    hello.byte_thing = 2;
-    hello.i32_thing = 2;
-    hello.i64_thing = 2;
-
-    var goodbye = new ttypes.Xtruct();
-    goodbye.string_thing = 'Goodbye4';
-    goodbye.byte_thing = 4;
-    goodbye.i32_thing = 4;
-    goodbye.i64_thing = 4;
-
-    var crazy = new ttypes.Insanity();
-    crazy.userMap = [];
-    crazy.userMap[ttypes.Numberz.EIGHT] = 8;
-    crazy.userMap[ttypes.Numberz.FIVE] = 5;
-    crazy.xtructs = [goodbye, hello];
-
-    var first_map = [];
-    var second_map = [];
-
-    first_map[ttypes.Numberz.TWO] = crazy;
-    first_map[ttypes.Numberz.THREE] = crazy;
-
-    var looney = new ttypes.Insanity();
-    second_map[ttypes.Numberz.SIX] = looney;
-
-    var insane = [];
-    insane[1] = first_map;
-    insane[2] = second_map;
-
-    console.log('insane result:');
-    console.log(insane);
-    return insane;
-  },
-  testMulti: function(arg0, arg1, arg2, arg3, arg4, arg5) {
-    console.log('testMulti()');
-
-    var hello = new ttypes.Xtruct();
-    hello.string_thing = 'Hello2';
-    hello.byte_thing = arg0;
-    hello.i32_thing = arg1;
-    hello.i64_thing = arg2;
-    return hello;
-  },
-  testException: function(arg) {
-    console.log('testException('+arg+')');
-    if (arg === 'Xception') {
-      var x = new ttypes.Xception();
-      x.errorCode = 1001;
-      x.message = arg;
-      throw x;
-    } else if (arg === 'TException') {
-      throw new TException(arg);
-    } else {
-      return;
-    }
-  },
-  testMultiException: function(arg0, arg1) {
-    console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
-    if (arg0 === ('Xception')) {
-      var x = new ttypes.Xception();
-      x.errorCode = 1001;
-      x.message = 'This is an Xception';
-      throw x;
-    } else if (arg0 === ('Xception2')) {
-      var x2 = new ttypes.Xception2();
-      x2.errorCode = 2002;
-      x2.struct_thing = new ttypes.Xtruct();
-      x2.struct_thing.string_thing = 'This is an Xception2';
-      throw x2;
-    }
-
-    var res = new ttypes.Xtruct();
-    res.string_thing = arg1;
-    return res;
-  },
-  testOneway: function(sleepFor) {
-    console.log('testOneway(' + sleepFor + ') => JavaScript (like Rust) never sleeps!');
-  }
-};   //ThriftTestSvcHandler

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/thrift_test_driver.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/thrift_test_driver.js b/lib/nodejs/test/thrift_test_driver.js
deleted file mode 100644
index 306f67d..0000000
--- a/lib/nodejs/test/thrift_test_driver.js
+++ /dev/null
@@ -1,324 +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.
- */
-
- // This is the Node.js test driver for the standard Apache Thrift
- // test service. The driver invokes every function defined in the
- // Thrift Test service with a representative range of parameters.
- //
- // The ThriftTestDriver function requires a client object
- // connected to a server hosting the Thrift Test service and
- // supports an optional callback function which is called with
- // a status message when the test is complete.
-
-var assert = require('assert');
-var ttypes = require('./gen-nodejs/ThriftTest_types');
-var Int64 = require('node-int64');
-
-var ThriftTestDriver = exports.ThriftTestDriver = function(client, callback) {
-
-function checkRecursively(map1, map2) {
-  if (typeof map1 !== 'function' && typeof map2 !== 'function') {
-    if (!map1 || typeof map1 !== 'object') {
-      //Handle int64 types (which use node-int64 in Node.js JavaScript)
-      if ((typeof map1 === "number") && (typeof map2 === "object") &&
-          (map2.buffer) && (map2.buffer instanceof Buffer) && (map2.buffer.length === 8)) {
-        var n = new Int64(map2.buffer);
-        assert.equal(map1, n.toNumber());
-      } else {
-        assert.equal(map1, map2);
-      }
-    } else {
-      for (var key in map1) {
-        checkRecursively(map1[key], map2[key]);
-      }
-    }
-  }
-}
-
-client.testVoid(function(err, response) {
-  assert( ! err);
-  assert.equal(undefined, response); //void
-});
-
-client.testString("Test", function(err, response) {
-  assert( ! err);
-  assert.equal("Test", response);
-});
-
-client.testString("", function(err, response) {
-  assert( ! err);
-  assert.equal("", response);
-});
-
-//all Languages in UTF-8
-/*jshint -W100 */
-var stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, " +
-    "Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, " +
-    "Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, " +
-    "বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, " +
-    "Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, " +
-    "Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, " +
-    "Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, " +
-    "Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, " +
-    "Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, " +
-    "Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, " +
-    "Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, " +
-    "ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, " +
-    "Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, " +
-    "Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa " +
-    "Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, مازِرونی, Bahasa " +
-    "Melayu, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪" +
-    "Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, " +
-    "Occitan, Иронау, Papiamentu, Deitsch, Polski, پنجابی, پښتو, " +
-    "Norfuk / Pitkern, Português, Runa Simi, Rumantsch, Romani, Română, " +
-    "Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple " +
-    "English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, " +
-    "Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, " +
-    "Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, " +
-    "Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, " +
-    "Bân-lâm-gú, 粵語";
-/*jshint +W100 */
-
-client.testString(stringTest, function(err, response) {
-  assert( ! err);
-  assert.equal(stringTest, response);
-});
-
-var specialCharacters = 'quote: \" backslash:' +
-    ' forwardslash-escaped: \/ ' +
-    ' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
-    ' now-all-of-them-together: "\\\/\b\n\r\t' +
-    ' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><' +
-    ' char-to-test-json-parsing: ]] \"]] \\" }}}{ [[[ ';
-client.testString(specialCharacters, function(err, response) {
-  assert( ! err);
-  assert.equal(specialCharacters, response);
-});
-
-client.testByte(1, function(err, response) {
-  assert( ! err);
-  assert.equal(1, response);
-});
-
-client.testByte(0, function(err, response) {
-  assert( ! err);
-  assert.equal(0, response);
-});
-
-client.testByte(-1, function(err, response) {
-  assert( ! err);
-  assert.equal(-1, response);
-});
-
-client.testByte(-127, function(err, response) {
-  assert( ! err);
-  assert.equal(-127, response);
-});
-
-client.testI32(-1, function(err, response) {
-  assert( ! err);
-  assert.equal(-1, response);
-});
-
-client.testI64(5, function(err, response) {
-  assert( ! err);
-  assert.equal(5, response);
-});
-
-client.testI64(-5, function(err, response) {
-  assert( ! err);
-  assert.equal(-5, response);
-});
-
-client.testI64(734359738368, function(err, response) {
-  assert( ! err);
-  assert.equal(734359738368, response);
-});
-
-client.testI64(-34359738368, function(err, response) {
-  assert( ! err);
-  assert.equal(-34359738368, response);
-});
-
-client.testI64(-734359738368, function(err, response) {
-  assert( ! err);
-  assert.equal(-734359738368, response);
-});
-
-client.testDouble(-5.2098523, function(err, response) {
-  assert( ! err);
-  assert.equal(-5.2098523, response);
-});
-
-client.testDouble(7.012052175215044, function(err, response) {
-  assert( ! err);
-  assert.equal(7.012052175215044, response);
-});
-
-var out = new ttypes.Xtruct({
-  string_thing: 'Zero',
-  byte_thing: 1,
-  i32_thing: -3,
-  i64_thing: 1000000
-});
-client.testStruct(out, function(err, response) {
-  assert( ! err);
-  checkRecursively(out, response);
-});
-
-var out2 = new ttypes.Xtruct2();
-out2.byte_thing = 1;
-out2.struct_thing = out;
-out2.i32_thing = 5;
-client.testNest(out2, function(err, response) {
-  assert( ! err);
-  checkRecursively(out2, response);
-});
-
-var mapout = {};
-for (var i = 0; i < 5; ++i) {
-  mapout[i] = i-10;
-}
-client.testMap(mapout, function(err, response) {
-  assert( ! err);
-  assert.deepEqual(mapout, response);
-});
-
-var mapTestInput = {
-  "a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
-  "longValue":stringTest, "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, ":"long key"
-};
-client.testStringMap(mapTestInput, function(err, response) {
-  assert( ! err);
-  assert.deepEqual(mapTestInput, response);
-});
-
-var setTestSetInput = [1,2,3];
-client.testSet(setTestSetInput, function(err, response) {
-  assert( ! err);
-  assert.deepEqual(setTestSetInput, response);
-});
-var setTestListInput = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
-client.testList(setTestListInput, function(err, response) {
-  assert( ! err);
-  assert.deepEqual(setTestListInput, response);
-});
-
-client.testEnum(ttypes.Numberz.ONE, function(err, response) {
-  assert( ! err);
-  assert.equal(ttypes.Numberz.ONE, response);
-});
-
-client.testTypedef(69, function(err, response) {
-  assert( ! err);
-  assert.equal(69, response);
-});
-
-var mapMapTest = {
-  "4": {"1":1, "2":2, "3":3, "4":4},
-  "-4": {"-4":-4, "-3":-3, "-2":-2, "-1":-1}
-};
-client.testMapMap(1, function(err, response) {
-  assert( ! err);
-  assert.deepEqual(mapMapTest, response);
-});
-
-var crazy = new ttypes.Insanity({
-  "userMap":{ "5":5, "8":8 },
-  "xtructs":[new ttypes.Xtruct({
-      "string_thing":"Goodbye4",
-      "byte_thing":4,
-      "i32_thing":4,
-      "i64_thing":4
-    }), new ttypes.Xtruct({
-      "string_thing":"Hello2",
-      "byte_thing":2,
-      "i32_thing":2,
-      "i64_thing":2
-    })]
-});
-var insanity = {
-  "1":{ "2": crazy, "3": crazy },
-  "2":{ "6":{ "userMap":{}, "xtructs":[] } }
-};
-client.testInsanity(crazy, function(err, response) {
-  assert( ! err);
-  checkRecursively(insanity, response);
-});
-
-client.testException('TException', function(err, response) {
-  assert( ! response);
-});
-
-client.testException('Xception', function(err, response) {
-  assert( ! response);
-  assert.equal(err.errorCode, 1001);
-  assert.equal('Xception', err.message);
-});
-
-client.testException('no Exception', function(err, response) {
-  assert( ! err);
-  assert.equal(undefined, response); //void
-});
-
-client.testOneway(0, function(err, response) {
-  assert(false); //should not answer
-});
-
-(function() {
-  var test_complete = false;
-  var retrys = 0;
-  var retry_limit = 30;
-  var retry_interval = 100;
-  /**
-   * redo a simple test after the oneway to make sure we aren't "off by one" --
-   * if the server treated oneway void like normal void, this next test will
-   * fail since it will get the void confirmation rather than the correct
-   * result. In this circumstance, the client will throw the exception:
-   *
-   * Because this is the last test against the server, when it completes
-   * the entire suite is complete by definition (the tests run serially).
-   */
-  client.testI32(-1, function(err, response) {
-    assert( ! err);
-    assert.equal(-1, response);
-    test_complete = true;
-  });
-
-  //We wait up to retry_limit * retry_interval for the test suite to complete
-  function TestForCompletion() {
-    if(test_complete) {
-      if (callback) {
-        callback("Server successfully tested!");
-      }
-    } else {
-      if (++retrys < retry_limit) {
-        setTimeout(TestForCompletion, retry_interval);
-      } else {
-        if (callback) {
-          callback("Server test failed to complete after " +
-                   (retry_limit*retry_interval/1000) + " seconds");
-        }
-      }
-    }
-  }
-
-  setTimeout(TestForCompletion, retry_interval);
-})();
-};

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/thrift_test_driver_promise.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/thrift_test_driver_promise.js b/lib/nodejs/test/thrift_test_driver_promise.js
deleted file mode 100644
index 9b991ef..0000000
--- a/lib/nodejs/test/thrift_test_driver_promise.js
+++ /dev/null
@@ -1,398 +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.
- */
-
- // This is the Node test driver for the standard Apache Thrift
- // test service. The driver invokes every function defined in the
- // Thrift Test service with a representative range of parameters.
- //
- // The ThriftTestDriver function requires a client object
- // connected to a server hosting the Thrift Test service and
- // supports an optional callback function which is called with
- // a status message when the test is complete.
-
-var assert = require('assert');
-var ttypes = require('./gen-nodejs/ThriftTest_types');
-
-var ThriftTestDriver = exports.ThriftTestDriver = function(client, callback) {
-
-// deepEqual doesn't work with fields using node-int64
-function checkRecursively(map1, map2) {
-  if (typeof map1 !== 'function' && typeof map2 !== 'function') {
-    if (!map1 || typeof map1 !== 'object') {
-        assert.equal(map1, map2);
-    } else {
-      for (var key in map1) {
-        checkRecursively(map1[key], map2[key]);
-      }
-    }
-  }
-}
-
-client.testVoid()
-  .then(function(response) {
-    assert.equal(undefined, response); //void
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-
-client.testString("Test")
-  .then(function(response) {
-    assert.equal("Test", response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testString("")
-  .then(function(response) {
-    assert.equal("", response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-//all Languages in UTF-8
-/*jshint -W100 */
-var stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, " +
-    "Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, " +
-    "Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, " +
-    "বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, " +
-    "Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, " +
-    "Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, " +
-    "Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, " +
-    "Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, " +
-    "Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, " +
-    "Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, " +
-    "Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, " +
-    "ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, " +
-    "Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, " +
-    "Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa " +
-    "Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, مازِرونی, Bahasa " +
-    "Melayu, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪" +
-    "Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, " +
-    "Occitan, Иронау, Papiamentu, Deitsch, Polski, پنجابی, پښتو, " +
-    "Norfuk / Pitkern, Português, Runa Simi, Rumantsch, Romani, Română, " +
-    "Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple " +
-    "English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, " +
-    "Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, " +
-    "Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, " +
-    "Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, " +
-    "Bân-lâm-gú, 粵語";
-/*jshint +W100 */
-
-client.testString(stringTest)
-  .then(function(response) {
-    assert.equal(stringTest, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-
-var specialCharacters = 'quote: \" backslash:' +
-    ' forwardslash-escaped: \/ ' +
-    ' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
-    ' now-all-of-them-together: "\\\/\b\n\r\t' +
-    ' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><' +
-    ' char-to-test-json-parsing: ]] \"]] \\" }}}{ [[[ ';
-client.testString(specialCharacters)
-  .then(function(response) {
-    assert.equal(specialCharacters, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-
-client.testByte(1)
-  .then(function(response) {
-    assert.equal(1, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-
-client.testByte(0)
-  .then(function(response) {
-    assert.equal(0, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testByte(-1)
-  .then(function(response) {
-    assert.equal(-1, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testByte(-127)
-  .then(function(response) {
-    assert.equal(-127, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testI32(-1)
-  .then(function(response) {
-    assert.equal(-1, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testI64(5)
-  .then(function(response) {
-    assert.equal(5, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testI64(-5)
-  .then(function(response) {
-    assert.equal(-5, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testI64(-34359738368)
-  .then(function(response) {
-    assert.equal(-34359738368, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testDouble(-5.2098523)
-  .then(function(response) {
-    assert.equal(-5.2098523, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testDouble(7.012052175215044)
-  .then(function(response) {
-    assert.equal(7.012052175215044, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-// TODO: add testBinary()
-
-var out = new ttypes.Xtruct({
-  string_thing: 'Zero',
-  byte_thing: 1,
-  i32_thing: -3,
-  i64_thing: 1000000
-});
-client.testStruct(out)
-  .then(function(response) {
-    checkRecursively(out, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-var out2 = new ttypes.Xtruct2();
-out2.byte_thing = 1;
-out2.struct_thing = out;
-out2.i32_thing = 5;
-client.testNest(out2)
-  .then(function(response) {
-    checkRecursively(out2, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-var mapout = {};
-for (var i = 0; i < 5; ++i) {
-  mapout[i] = i-10;
-}
-client.testMap(mapout)
-  .then(function(response) {
-    assert.deepEqual(mapout, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-var mapTestInput = {
-  "a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
-  "longValue":stringTest, stringTest:"long key"
-};
-client.testStringMap(mapTestInput)
-  .then(function(response) {
-    assert.deepEqual(mapTestInput, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-var setTestInput = [1,2,3];
-client.testSet(setTestInput)
-  .then(function(response) {
-    assert.deepEqual(setTestInput, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-client.testList(setTestInput)
-  .then(function(response) {
-    assert.deepEqual(setTestInput, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testEnum(ttypes.Numberz.ONE)
-  .then(function(response) {
-    assert.equal(ttypes.Numberz.ONE, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testTypedef(69)
-  .then(function(response) {
-    assert.equal(69, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-var mapMapTest = {
-  "4": {"1":1, "2":2, "3":3, "4":4},
-  "-4": {"-4":-4, "-3":-3, "-2":-2, "-1":-1}
-};
-client.testMapMap(1)
-  .then(function(response) {
-    assert.deepEqual(mapMapTest, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-var crazy = new ttypes.Insanity({
-  "userMap":{ "5":5, "8":8 },
-  "xtructs":[new ttypes.Xtruct({
-      "string_thing":"Goodbye4",
-      "byte_thing":4,
-      "i32_thing":4,
-      "i64_thing":4
-    }), new ttypes.Xtruct({
-      "string_thing":"Hello2",
-      "byte_thing":2,
-      "i32_thing":2,
-      "i64_thing":2
-    })]
-});
-
-var insanity = {
-  "1":{ "2": crazy, "3": crazy },
-  "2":{ "6":{ "userMap":null, "xtructs":null } }
-};
-client.testInsanity(crazy)
-  .then(function(response) {
-    checkRecursively(insanity, response);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testException('TException')
-  .then(function() {
-    assert(false);
-  });
-
-client.testException('Xception')
-  .then(function(response) {
-    assert.equal(err.errorCode, 1001);
-    assert.equal('Xception', err.message);
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testException('no Exception')
-  .then(function(response) {
-    assert.equal(undefined, response); //void
-  })
-  .fail(function() {
-    assert(false);
-  });
-
-client.testOneway(0, function(error, response) {
-  assert(false); //should not answer
-});
-
-(function() {
-  var test_complete = false;
-  var retrys = 0;
-  var retry_limit = 30;
-  var retry_interval = 100;
-  /**
-   * redo a simple test after the oneway to make sure we aren't "off by one" --
-   * if the server treated oneway void like normal void, this next test will
-   * fail since it will get the void confirmation rather than the correct
-   * result. In this circumstance, the client will throw the exception:
-   *
-   * Because this is the last test against the server, when it completes
-   * the entire suite is complete by definition (the tests run serially).
-   */
-  client.testI32(-1)
-    .then(function(response) {
-        assert.equal(-1, response);
-        test_complete = true;
-    })
-    .fail(function() {
-      assert(false);
-    });
-
-//We wait up to retry_limit * retry_interval for the test suite to complete
-  function TestForCompletion() {
-    if(test_complete) {
-      if (callback) {
-        callback("Server successfully tested!");
-      }
-    } else {
-      if (++retrys < retry_limit) {
-        setTimeout(TestForCompletion, retry_interval);
-      } else {
-    if (callback) {
-      callback("Server test failed to complete after " +
-        (retry_limit*retry_interval/1000) + " seconds");
-    }
-      }
-    }
-  }
-
-  setTimeout(TestForCompletion, retry_interval);
-})();
-};

http://git-wip-us.apache.org/repos/asf/thrift/blob/3b9ff4de/lib/nodejs/test/ws_client.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/test/ws_client.js b/lib/nodejs/test/ws_client.js
deleted file mode 100644
index 93b93b7..0000000
--- a/lib/nodejs/test/ws_client.js
+++ /dev/null
@@ -1,81 +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.
- */
-
-//This is the client side test for the standard Apache Thrift
-//"ThriftTest" suite. This client will test any protocol/transport
-//combination specified on the command line.
-
-var fs = require('fs');
-var assert = require('assert');
-var thrift = require('thrift');
-var ThriftTest = require('./gen-nodejs/ThriftTest');
-var ThriftTestDriver = require('./thrift_test_driver').ThriftTestDriver;
-var ThriftTestDriverPromise = require('./thrift_test_driver_promise').ThriftTestDriver;
-
-var program = require('commander');
-
-program
-  .option('-p, --protocol <protocol>', 'Set thrift protocol (binary|json) [protocol]')
-  .option('-t, --transport <transport>', 'Set thrift transport (buffered|framed) [transport]')
-  .option('--ssl', 'use wss instead of ws')
-  .option('--promise', 'test with promise style functions')
-  .parse(process.argv);
-
-var protocol = thrift.TBinaryProtocol;
-if (program.protocol === "json") {
-  protocol = thrift.TJSONProtocol;
-}
-
-var transport =  thrift.TBufferedTransport;
-if (program.transport === "framed") {
-  transport = thrift.TFramedTransport;
-}
-
-var options = {
-   transport: transport,
-   protocol: protocol,
-   path: "/test"
-};
-
-if (program.ssl) {
-  options.wsOptions = { rejectUnauthorized: false };
-  options.secure = true;
-}
-
-var connection = thrift.createWSConnection("localhost", 9090, options);
-connection.open();
-
-var client = thrift.createWSClient(ThriftTest, connection);
-
-connection.on('error', function(err) {
-  assert(false, err);
-});
-
-var testDriver = ThriftTestDriver;
-if (program.promise) {
-  console.log("    --Testing promise style client");
-  testDriver = ThriftTestDriverPromise;
-}
-testDriver(client, function (status) {
-  console.log(status);
-  process.exit(0);
-});
-
-// to make it also run on expresso
-exports.expressoTest = function() {};