THRIFT-2964: nodejs file breakout
Client: NodeJS
Patch: Andrew de Andrade
Moves protocols and transports (among others) into seperate files.
diff --git a/lib/nodejs/test/binary.test.js b/lib/nodejs/test/binary.test.js
index 58feebf..dacadef 100644
--- a/lib/nodejs/test/binary.test.js
+++ b/lib/nodejs/test/binary.test.js
@@ -24,7 +24,7 @@
"Should read signed byte": function(test){
test.strictEqual(1, binary.readByte(0x01));
test.strictEqual(-1, binary.readByte(0xFF));
-
+
test.strictEqual(127, binary.readByte(0x7F));
test.strictEqual(-128, binary.readByte(0x80));
test.done();
@@ -123,11 +123,11 @@
test.deepEqual([0x3f, 0xd5, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55], binary.writeDouble([], 1/3));
// Min subnormal positive double
- test.deepEqual([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01], binary.writeDouble([], 4.9406564584124654e-324));
+ test.deepEqual([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01], binary.writeDouble([], 4.9406564584124654e-324));
// Min normal positive double
- test.deepEqual([0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], 2.2250738585072014e-308));
+ test.deepEqual([0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], 2.2250738585072014e-308));
// Max positive double
- test.deepEqual([0x7f, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff], binary.writeDouble([], 1.7976931348623157e308));
+ test.deepEqual([0x7f, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff], binary.writeDouble([], 1.7976931348623157e308));
test.done();
}
});
diff --git a/lib/nodejs/test/client.js b/lib/nodejs/test/client.js
index 3b5f1cb..b8de7ce 100755
--- a/lib/nodejs/test/client.js
+++ b/lib/nodejs/test/client.js
@@ -58,7 +58,7 @@
protocol = thrift.TJSONProtocol;
} else if (program.protocol === "compact") {
protocol = thrift.TCompactProtocol;
-}
+}
var transport = thrift.TBufferedTransport;
if (program.transport === "framed") {
@@ -88,7 +88,7 @@
var testDriver = ThriftTestDriver;
if (program.promise) {
testDriver = ThriftTestDriverPromise;
-}
+}
testDriver(client, function (status) {
console.log(status);
connection.end();
diff --git a/lib/nodejs/test/http_client.js b/lib/nodejs/test/http_client.js
index 14c1a29..9ab05d8 100644
--- a/lib/nodejs/test/http_client.js
+++ b/lib/nodejs/test/http_client.js
@@ -41,7 +41,7 @@
var protocol = thrift.TBinaryProtocol;
if (program.protocol === "json") {
protocol = thrift.TJSONProtocol;
-}
+}
var transport = thrift.TBufferedTransport;
if (program.transport === "framed") {
@@ -58,7 +58,7 @@
if (program.ssl) {
options.nodeOptions = { rejectUnauthorized: false };
options.https = true;
-}
+}
var connection = thrift.createHttpConnection("localhost", 9090, options);
@@ -72,7 +72,7 @@
if (program.promise) {
console.log(" --Testing promise style client");
testDriver = ThriftTestDriverPromise;
-}
+}
testDriver(client, function (status) {
console.log(status);
process.exit(0);
diff --git a/lib/nodejs/test/http_server.js b/lib/nodejs/test/http_server.js
index f12e695..3519f4a 100644
--- a/lib/nodejs/test/http_server.js
+++ b/lib/nodejs/test/http_server.js
@@ -36,31 +36,31 @@
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 } };
+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);
+thrift.createWebServer(serverOpt).listen(9090);
diff --git a/lib/nodejs/test/multiplex_client.js b/lib/nodejs/test/multiplex_client.js
index 7b58205..7004f93 100644
--- a/lib/nodejs/test/multiplex_client.js
+++ b/lib/nodejs/test/multiplex_client.js
@@ -40,7 +40,7 @@
var protocol = thrift.TBinaryProtocol;
if (program.protocol === "json") {
protocol = thrift.TJSONProtocol;
-}
+}
var options = {
transport: transport,
diff --git a/lib/nodejs/test/server.js b/lib/nodejs/test/server.js
index 378a6e2..b6d28c7 100755
--- a/lib/nodejs/test/server.js
+++ b/lib/nodejs/test/server.js
@@ -39,14 +39,14 @@
var transport = thrift.TBufferedTransport;
if (program.transport === "framed") {
transport = thrift.TFramedTransport;
-}
+}
var protocol = thrift.TBinaryProtocol;
if (program.protocol === "json") {
protocol = thrift.TJSONProtocol;
} else if (program.protocol === "compact") {
protocol = thrift.TCompactProtocol;
-}
+}
var port = 9090;
if (String(program.port) === "undefined"){
@@ -57,7 +57,7 @@
var handler = ThriftTestHandler;
if (program.promise) {
handler = ThriftTestHandlerPromise;
-}
+}
var options = {
protocol: protocol,
diff --git a/lib/nodejs/test/test_handler.js b/lib/nodejs/test/test_handler.js
index 09ff39f..fd25120 100644
--- a/lib/nodejs/test/test_handler.js
+++ b/lib/nodejs/test/test_handler.js
@@ -17,7 +17,7 @@
* under the License.
*/
-//This is the server side Node test handler for the standard
+//This is the server side Node test handler for the standard
// Apache Thrift test service.
var ttypes = require('./gen-nodejs/ThriftTest_types');
diff --git a/lib/nodejs/test/thrift_test_driver.js b/lib/nodejs/test/thrift_test_driver.js
index 5ddcb21..306f67d 100644
--- a/lib/nodejs/test/thrift_test_driver.js
+++ b/lib/nodejs/test/thrift_test_driver.js
@@ -17,13 +17,13 @@
* 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
+ // 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
+ // supports an optional callback function which is called with
// a status message when the test is complete.
var assert = require('assert');
@@ -31,15 +31,15 @@
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") &&
+ 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());
+ assert.equal(map1, n.toNumber());
} else {
assert.equal(map1, map2);
}
diff --git a/lib/nodejs/test/thrift_test_driver_promise.js b/lib/nodejs/test/thrift_test_driver_promise.js
index 74a91bd..9b991ef 100644
--- a/lib/nodejs/test/thrift_test_driver_promise.js
+++ b/lib/nodejs/test/thrift_test_driver_promise.js
@@ -202,9 +202,9 @@
.fail(function() {
assert(false);
});
-
-// TODO: add testBinary()
-
+
+// TODO: add testBinary()
+
var out = new ttypes.Xtruct({
string_thing: 'Zero',
byte_thing: 1,
diff --git a/lib/nodejs/test/ws_client.js b/lib/nodejs/test/ws_client.js
index 4573246..93b93b7 100644
--- a/lib/nodejs/test/ws_client.js
+++ b/lib/nodejs/test/ws_client.js
@@ -40,7 +40,7 @@
var protocol = thrift.TBinaryProtocol;
if (program.protocol === "json") {
protocol = thrift.TJSONProtocol;
-}
+}
var transport = thrift.TBufferedTransport;
if (program.transport === "framed") {
@@ -56,7 +56,7 @@
if (program.ssl) {
options.wsOptions = { rejectUnauthorized: false };
options.secure = true;
-}
+}
var connection = thrift.createWSConnection("localhost", 9090, options);
connection.open();
@@ -71,7 +71,7 @@
if (program.promise) {
console.log(" --Testing promise style client");
testDriver = ThriftTestDriverPromise;
-}
+}
testDriver(client, function (status) {
console.log(status);
process.exit(0);