THRIFT-2511 Node.js compact protocol
Client: Node
Patch: Randy Abernethy
Adds Compact Protocol to Node.js, tests in testAll.sh and repairs all
library JSHint warnings.
diff --git a/lib/nodejs/test/client.js b/lib/nodejs/test/client.js
index 8813f91..d57676e 100644
--- a/lib/nodejs/test/client.js
+++ b/lib/nodejs/test/client.js
@@ -41,6 +41,8 @@
var protocol = thrift.TBinaryProtocol;
if (program.protocol === "json") {
protocol = thrift.TJSONProtocol;
+} else if (program.protocol === "compact") {
+ protocol = thrift.TCompactProtocol;
}
var transport = thrift.TBufferedTransport;
diff --git a/lib/nodejs/test/server.js b/lib/nodejs/test/server.js
index 605c700..6afff07 100644
--- a/lib/nodejs/test/server.js
+++ b/lib/nodejs/test/server.js
@@ -41,6 +41,8 @@
var protocol = thrift.TBinaryProtocol;
if (program.protocol === "json") {
protocol = thrift.TJSONProtocol;
+} else if (program.protocol === "compact") {
+ protocol = thrift.TCompactProtocol;
}
var handler = ThriftTestHandler;
diff --git a/lib/nodejs/test/testAll.sh b/lib/nodejs/test/testAll.sh
index 9d1da3f..41c33cf 100755
--- a/lib/nodejs/test/testAll.sh
+++ b/lib/nodejs/test/testAll.sh
@@ -73,6 +73,8 @@
#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
@@ -82,7 +84,7 @@
testMultiplexedClientServer binary buffered || TESTOK=1
testMultiplexedClientServer json buffered || TESTOK=1
testMultiplexedClientServer binary framed || TESTOK=1
-testMultiplexedClientServer json framed || TESTOK=1
+testMultiplexedClientServer compact framed || TESTOK=1
#test ssl connection
testClientServer binary framed --ssl || TESTOK=1
@@ -90,8 +92,11 @@
#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
diff --git a/lib/nodejs/test/thrift_test_driver.js b/lib/nodejs/test/thrift_test_driver.js
index 02613ec..b1d744b 100644
--- a/lib/nodejs/test/thrift_test_driver.js
+++ b/lib/nodejs/test/thrift_test_driver.js
@@ -146,11 +146,21 @@
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);
@@ -192,21 +202,22 @@
var mapTestInput = {
"a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
- "longValue":stringTest, stringTest:"long key"
+ "longValue":stringTest, "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, ":"long key"
};
client.testStringMap(mapTestInput, function(err, response) {
assert( ! err);
assert.deepEqual(mapTestInput, response);
});
-var setTestInput = [1,2,3];
-client.testSet(setTestInput, function(err, response) {
+var setTestSetInput = [1,2,3];
+client.testSet(setTestSetInput, function(err, response) {
assert( ! err);
- assert.deepEqual(setTestInput, response);
+ assert.deepEqual(setTestSetInput, response);
});
-client.testList(setTestInput, function(err, 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(setTestInput, response);
+ assert.deepEqual(setTestListInput, response);
});
client.testEnum(ttypes.Numberz.ONE, function(err, response) {
@@ -223,7 +234,7 @@
"4": {"1":1, "2":2, "3":3, "4":4},
"-4": {"-4":-4, "-3":-3, "-2":-2, "-1":-1}
};
-client.testMapMap(mapMapTest, function(err, response) {
+client.testMapMap(1, function(err, response) {
assert( ! err);
assert.deepEqual(mapMapTest, response);
});
diff --git a/lib/nodejs/test/thrift_test_driver_promise.js b/lib/nodejs/test/thrift_test_driver_promise.js
index 22e2572..22175cb 100644
--- a/lib/nodejs/test/thrift_test_driver_promise.js
+++ b/lib/nodejs/test/thrift_test_driver_promise.js
@@ -289,7 +289,7 @@
"4": {"1":1, "2":2, "3":3, "4":4},
"-4": {"-4":-4, "-3":-3, "-2":-2, "-1":-1}
};
-client.testMapMap(mapMapTest)
+client.testMapMap(1)
.then(function(response) {
assert.deepEqual(mapMapTest, response);
})