gorealis v2 refactor (#5)
* Changing default timeout for start maintenance. * Upgrading dependencies to gorealis v2 and thrift 0.12.0 * Refactored to update to gorealis v2.
This commit is contained in:
parent
ad4dd9606e
commit
6ab5c9334d
1335 changed files with 137431 additions and 61530 deletions
8
vendor/git.apache.org/thrift.git/lib/nodejs/Makefile.am
generated
vendored
8
vendor/git.apache.org/thrift.git/lib/nodejs/Makefile.am
generated
vendored
|
@ -15,21 +15,21 @@
|
|||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
THRIFT = $(top_builddir)/compiler/cpp/thrift
|
||||
# We call npm twice to work around npm issues
|
||||
|
||||
stubs: $(top_srcdir)/test/ThriftTest.thrift
|
||||
$(THRIFT) --gen js:node -o test/ $(top_srcdir)/test/ThriftTest.thrift
|
||||
|
||||
deps: $(top_srcdir)/package.json
|
||||
$(NPM) install --no-bin-links $(top_srcdir)/
|
||||
$(NPM) install $(top_srcdir)/ || $(NPM) install $(top_srcdir)/
|
||||
|
||||
all-local: deps
|
||||
|
||||
precross: deps stubs
|
||||
|
||||
# TODO: Lint nodejs lib and gen-code as part of build
|
||||
check: deps
|
||||
cd $(top_srcdir) && $(NPM) test && cd lib/nodejs
|
||||
cd $(top_srcdir) && $(NPM) test && $(NPM) run lint-tests && cd lib/nodejs
|
||||
|
||||
clean-local:
|
||||
$(RM) -r test/gen-nodejs
|
||||
|
|
39
vendor/git.apache.org/thrift.git/lib/nodejs/README.md
generated
vendored
39
vendor/git.apache.org/thrift.git/lib/nodejs/README.md
generated
vendored
|
@ -20,6 +20,9 @@ KIND, either express or implied. See the License for the
|
|||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
## Compatibility
|
||||
|
||||
node version 6 or later is required
|
||||
|
||||
## Install
|
||||
|
||||
|
@ -35,30 +38,32 @@ You can compile IDL sources for Node.js with the following command:
|
|||
|
||||
Here is a Cassandra example:
|
||||
|
||||
var thrift = require('thrift'),
|
||||
Cassandra = require('./gen-nodejs/Cassandra')
|
||||
ttypes = require('./gen-nodejs/cassandra_types');
|
||||
```js
|
||||
var thrift = require('thrift'),
|
||||
Cassandra = require('./gen-nodejs/Cassandra')
|
||||
ttypes = require('./gen-nodejs/cassandra_types');
|
||||
|
||||
var connection = thrift.createConnection("localhost", 9160),
|
||||
client = thrift.createClient(Cassandra, connection);
|
||||
var connection = thrift.createConnection("localhost", 9160),
|
||||
client = thrift.createClient(Cassandra, connection);
|
||||
|
||||
connection.on('error', function(err) {
|
||||
console.error(err);
|
||||
});
|
||||
connection.on('error', function(err) {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
client.get_slice("Keyspace", "key", new ttypes.ColumnParent({column_family: "ExampleCF"}), new ttypes.SlicePredicate({slice_range: new ttypes.SliceRange({start: '', finish: ''})}), ttypes.ConsistencyLevel.ONE, function(err, data) {
|
||||
if (err) {
|
||||
// handle err
|
||||
} else {
|
||||
// data == [ttypes.ColumnOrSuperColumn, ...]
|
||||
}
|
||||
connection.end();
|
||||
});
|
||||
client.get_slice("Keyspace", "key", new ttypes.ColumnParent({column_family: "ExampleCF"}), new ttypes.SlicePredicate({slice_range: new ttypes.SliceRange({start: '', finish: ''})}), ttypes.ConsistencyLevel.ONE, function(err, data) {
|
||||
if (err) {
|
||||
// handle err
|
||||
} else {
|
||||
// data == [ttypes.ColumnOrSuperColumn, ...]
|
||||
}
|
||||
connection.end();
|
||||
});
|
||||
```
|
||||
|
||||
<a name="int64"></a>
|
||||
## Int64
|
||||
|
||||
Since JavaScript represents all numbers as doubles, int64 values cannot be accurately represented naturally. To solve this, int64 values in responses will be wrapped with Thirft.Int64 objects. The Int64 implementation used is [broofa/node-int64](https://github.com/broofa/node-int64).
|
||||
Since JavaScript represents all numbers as doubles, int64 values cannot be accurately represented naturally. To solve this, int64 values in responses will be wrapped with Thrift.Int64 objects. The Int64 implementation used is [broofa/node-int64](https://github.com/broofa/node-int64).
|
||||
|
||||
## Client and server examples
|
||||
|
||||
|
|
3
vendor/git.apache.org/thrift.git/lib/nodejs/examples/httpServer.py
generated
vendored
3
vendor/git.apache.org/thrift.git/lib/nodejs/examples/httpServer.py
generated
vendored
|
@ -7,7 +7,7 @@ from thrift.server import THttpServer
|
|||
|
||||
class HelloSvcHandler:
|
||||
def hello_func(self):
|
||||
print "Hello Called"
|
||||
print("Hello Called")
|
||||
return "hello from Python"
|
||||
|
||||
processor = HelloSvc.Processor(HelloSvcHandler())
|
||||
|
@ -16,4 +16,3 @@ port = 9090
|
|||
server = THttpServer.THttpServer(processor, ("localhost", port), protoFactory)
|
||||
print "Python server running on port " + str(port)
|
||||
server.serve()
|
||||
|
||||
|
|
7
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/binary_protocol.js
generated
vendored
7
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/binary_protocol.js
generated
vendored
|
@ -37,6 +37,7 @@ function TBinaryProtocol(trans, strictRead, strictWrite) {
|
|||
this.trans = trans;
|
||||
this.strictRead = (strictRead !== undefined ? strictRead : false);
|
||||
this.strictWrite = (strictWrite !== undefined ? strictWrite : true);
|
||||
this._seqid = null;
|
||||
};
|
||||
|
||||
TBinaryProtocol.prototype.flush = function() {
|
||||
|
@ -54,8 +55,7 @@ TBinaryProtocol.prototype.writeMessageBegin = function(name, type, seqid) {
|
|||
this.writeI32(seqid);
|
||||
}
|
||||
// Record client seqid to find callback again
|
||||
if (this._seqid) {
|
||||
// TODO better logging log warning
|
||||
if (this._seqid !== null) {
|
||||
log.warning('SeqId already set', { 'name': name });
|
||||
} else {
|
||||
this._seqid = seqid;
|
||||
|
@ -64,7 +64,7 @@ TBinaryProtocol.prototype.writeMessageBegin = function(name, type, seqid) {
|
|||
};
|
||||
|
||||
TBinaryProtocol.prototype.writeMessageEnd = function() {
|
||||
if (this._seqid) {
|
||||
if (this._seqid !== null) {
|
||||
this._seqid = null;
|
||||
} else {
|
||||
log.warning('No seqid to unset');
|
||||
|
@ -177,7 +177,6 @@ TBinaryProtocol.prototype.readMessageBegin = function() {
|
|||
if (sz < 0) {
|
||||
var version = sz & VERSION_MASK;
|
||||
if (version != VERSION_1) {
|
||||
console.log("BAD: " + version);
|
||||
throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.BAD_VERSION, "Bad version in readMessageBegin: " + sz);
|
||||
}
|
||||
type = sz & TYPE_MASK;
|
||||
|
|
2
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/browser.js
generated
vendored
2
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/browser.js
generated
vendored
|
@ -32,3 +32,5 @@ exports.TFramedTransport = require('./framed_transport');
|
|||
exports.Protocol = exports.TJSONProtocol = require('./json_protocol');
|
||||
exports.TBinaryProtocol = require('./binary_protocol');
|
||||
exports.TCompactProtocol = require('./compact_protocol');
|
||||
|
||||
exports.Int64 = require('node-int64');
|
||||
|
|
8
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/buffered_transport.js
generated
vendored
8
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/buffered_transport.js
generated
vendored
|
@ -33,6 +33,14 @@ function TBufferedTransport(buffer, callback) {
|
|||
this.onFlush = callback;
|
||||
};
|
||||
|
||||
TBufferedTransport.prototype.reset = function() {
|
||||
this.inBuf = new Buffer(this.defaultReadBufferSize);
|
||||
this.readCursor = 0;
|
||||
this.writeCursor = 0;
|
||||
this.outBuffers = [];
|
||||
this.outCount = 0;
|
||||
}
|
||||
|
||||
TBufferedTransport.receiver = function(callback, seqid) {
|
||||
var reader = new TBufferedTransport();
|
||||
|
||||
|
|
1
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/compact_protocol.js
generated
vendored
1
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/compact_protocol.js
generated
vendored
|
@ -249,7 +249,6 @@ TCompactProtocol.prototype.writeMessageBegin = function(name, type, seqid) {
|
|||
|
||||
// Record client seqid to find callback again
|
||||
if (this._seqid) {
|
||||
// TODO better logging log warning
|
||||
log.warning('SeqId already set', { 'name': name });
|
||||
} else {
|
||||
this._seqid = seqid;
|
||||
|
|
46
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/connection.js
generated
vendored
46
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/connection.js
generated
vendored
|
@ -17,10 +17,12 @@
|
|||
* under the License.
|
||||
*/
|
||||
var util = require('util');
|
||||
var EventEmitter = require("events").EventEmitter;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var constants = require('constants');
|
||||
var net = require('net');
|
||||
var tls = require('tls');
|
||||
var thrift = require('./thrift');
|
||||
var log = require('./log');
|
||||
|
||||
var TBufferedTransport = require('./buffered_transport');
|
||||
var TBinaryProtocol = require('./binary_protocol');
|
||||
|
@ -121,7 +123,6 @@ var Connection = exports.Connection = function(stream, options) {
|
|||
var service_name = self.seqId2Service[header.rseqid];
|
||||
if (service_name) {
|
||||
client = self.client[service_name];
|
||||
delete self.seqId2Service[header.rseqid];
|
||||
}
|
||||
/*jshint -W083 */
|
||||
client._reqs[dummy_seqid] = function(err, success){
|
||||
|
@ -129,6 +130,9 @@ var Connection = exports.Connection = function(stream, options) {
|
|||
|
||||
var callback = client._reqs[header.rseqid];
|
||||
delete client._reqs[header.rseqid];
|
||||
if (service_name) {
|
||||
delete self.seqId2Service[header.rseqid];
|
||||
}
|
||||
if (callback) {
|
||||
callback(err, success);
|
||||
}
|
||||
|
@ -201,9 +205,7 @@ Connection.prototype.connection_gone = function () {
|
|||
this.retry_delay = Math.floor(this.retry_delay * this.retry_backoff);
|
||||
}
|
||||
|
||||
if (self._debug) {
|
||||
console.log("Retry connection in " + this.retry_delay + " ms");
|
||||
}
|
||||
log.debug("Retry connection in " + this.retry_delay + " ms");
|
||||
|
||||
if (this.max_attempts && this.attempts >= this.max_attempts) {
|
||||
this.retry_timer = null;
|
||||
|
@ -219,9 +221,7 @@ Connection.prototype.connection_gone = function () {
|
|||
});
|
||||
|
||||
this.retry_timer = setTimeout(function () {
|
||||
if (self._debug) {
|
||||
console.log("Retrying connection...");
|
||||
}
|
||||
log.debug("Retrying connection...");
|
||||
|
||||
self.retry_totaltime += self.retry_delay;
|
||||
|
||||
|
@ -232,7 +232,11 @@ Connection.prototype.connection_gone = function () {
|
|||
return;
|
||||
}
|
||||
|
||||
self.connection.connect(self.port, self.host);
|
||||
if (self.path !== undefined) {
|
||||
self.connection.connect(self.path);
|
||||
} else {
|
||||
self.connection.connect(self.port, self.host);
|
||||
}
|
||||
self.retry_timer = null;
|
||||
}, this.retry_delay);
|
||||
};
|
||||
|
@ -246,7 +250,20 @@ exports.createConnection = function(host, port, options) {
|
|||
return connection;
|
||||
};
|
||||
|
||||
exports.createUDSConnection = function(path, options) {
|
||||
var stream = net.createConnection(path);
|
||||
var connection = new Connection(stream, options);
|
||||
connection.path = path;
|
||||
|
||||
return connection;
|
||||
};
|
||||
|
||||
exports.createSSLConnection = function(host, port, options) {
|
||||
if (!('secureProtocol' in options) && !('secureOptions' in options)) {
|
||||
options.secureProtocol = "SSLv23_method";
|
||||
options.secureOptions = constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3;
|
||||
}
|
||||
|
||||
var stream = tls.connect(port, host, options);
|
||||
var connection = new Connection(stream, options);
|
||||
connection.host = host;
|
||||
|
@ -268,20 +285,19 @@ var StdIOConnection = exports.StdIOConnection = function(command, options) {
|
|||
var self = this;
|
||||
EventEmitter.call(this);
|
||||
|
||||
this._debug = options.debug || false;
|
||||
this.connection = child.stdin;
|
||||
this.options = options || {};
|
||||
this.transport = this.options.transport || TBufferedTransport;
|
||||
this.protocol = this.options.protocol || TBinaryProtocol;
|
||||
this.offline_queue = [];
|
||||
|
||||
if(this._debug === true){
|
||||
this.child.stderr.on('data',function(err){
|
||||
console.log(err.toString(),'CHILD ERROR');
|
||||
if (log.getLogLevel() === 'debug') {
|
||||
this.child.stderr.on('data', function (err) {
|
||||
log.debug(err.toString(), 'CHILD ERROR');
|
||||
});
|
||||
|
||||
this.child.on('exit',function(code,signal){
|
||||
console.log(code+':'+signal,'CHILD EXITED');
|
||||
this.child.on('exit', function (code,signal) {
|
||||
log.debug(code + ':' + signal, 'CHILD EXITED');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
45
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/http_connection.js
generated
vendored
45
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/http_connection.js
generated
vendored
|
@ -59,8 +59,6 @@ var createClient = require('./create_client');
|
|||
* Initializes a Thrift HttpConnection instance (use createHttpConnection() rather than
|
||||
* instantiating directly).
|
||||
* @constructor
|
||||
* @param {string} host - The host name or IP to connect to.
|
||||
* @param {number} port - The TCP port to connect to.
|
||||
* @param {ConnectOptions} options - The configuration options to use.
|
||||
* @throws {error} Exceptions other than InputBufferUnderrunError are rethrown
|
||||
* @event {error} The "error" event is fired when a Node.js error event occurs during
|
||||
|
@ -71,15 +69,16 @@ var createClient = require('./create_client');
|
|||
* semantics implemented over the Node.js http.request() method.
|
||||
* @see {@link createHttpConnection}
|
||||
*/
|
||||
var HttpConnection = exports.HttpConnection = function(host, port, options) {
|
||||
var HttpConnection = exports.HttpConnection = function(options) {
|
||||
//Initialize the emitter base object
|
||||
EventEmitter.call(this);
|
||||
|
||||
//Set configuration
|
||||
var self = this;
|
||||
this.options = options || {};
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.host = this.options.host;
|
||||
this.port = this.options.port;
|
||||
this.socketPath = this.options.socketPath;
|
||||
this.https = this.options.https || false;
|
||||
this.transport = this.options.transport || TBufferedTransport;
|
||||
this.protocol = this.options.protocol || TBinaryProtocol;
|
||||
|
@ -87,7 +86,8 @@ var HttpConnection = exports.HttpConnection = function(host, port, options) {
|
|||
//Prepare Node.js options
|
||||
this.nodeOptions = {
|
||||
host: this.host,
|
||||
port: this.port || 80,
|
||||
port: this.port,
|
||||
socketPath: this.socketPath,
|
||||
path: this.options.path || '/',
|
||||
method: 'POST',
|
||||
headers: this.options.headers || {},
|
||||
|
@ -169,6 +169,10 @@ var HttpConnection = exports.HttpConnection = function(host, port, options) {
|
|||
var data = [];
|
||||
var dataLen = 0;
|
||||
|
||||
if (response.statusCode !== 200) {
|
||||
this.emit("error", new THTTPException(response));
|
||||
}
|
||||
|
||||
response.on('error', function (e) {
|
||||
self.emit("error", e);
|
||||
});
|
||||
|
@ -210,10 +214,13 @@ util.inherits(HttpConnection, EventEmitter);
|
|||
*/
|
||||
HttpConnection.prototype.write = function(data) {
|
||||
var self = this;
|
||||
self.nodeOptions.headers["Content-length"] = data.length;
|
||||
var opts = self.nodeOptions;
|
||||
opts.headers["Content-length"] = data.length;
|
||||
if (!opts.headers["Content-Type"])
|
||||
opts.headers["Content-Type"] = "application/x-thrift";
|
||||
var req = (self.https) ?
|
||||
https.request(self.nodeOptions, self.responseCallback) :
|
||||
http.request(self.nodeOptions, self.responseCallback);
|
||||
https.request(opts, self.responseCallback) :
|
||||
http.request(opts, self.responseCallback);
|
||||
req.on('error', function(err) {
|
||||
self.emit("error", err);
|
||||
});
|
||||
|
@ -231,8 +238,26 @@ HttpConnection.prototype.write = function(data) {
|
|||
* @see {@link ConnectOptions}
|
||||
*/
|
||||
exports.createHttpConnection = function(host, port, options) {
|
||||
return new HttpConnection(host, port, options);
|
||||
options.host = host;
|
||||
options.port = port || 80;
|
||||
return new HttpConnection(options);
|
||||
};
|
||||
|
||||
exports.createHttpUDSConnection = function(path, options) {
|
||||
options.socketPath = path;
|
||||
return new HttpConnection(options);
|
||||
};
|
||||
|
||||
exports.createHttpClient = createClient
|
||||
|
||||
|
||||
function THTTPException(response) {
|
||||
thrift.TApplicationException.call(this);
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
this.name = this.constructor.name;
|
||||
this.statusCode = response.statusCode;
|
||||
this.response = response;
|
||||
this.type = thrift.TApplicationExceptionType.PROTOCOL_ERROR;
|
||||
this.message = "Received a response with a bad HTTP status code: " + response.statusCode;
|
||||
}
|
||||
util.inherits(THTTPException, thrift.TApplicationException);
|
||||
|
|
7
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/index.js
generated
vendored
7
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/index.js
generated
vendored
|
@ -18,10 +18,16 @@
|
|||
*/
|
||||
exports.Thrift = require('./thrift');
|
||||
|
||||
var log = require('./log');
|
||||
exports.setLogFunc = log.setLogFunc;
|
||||
exports.setLogLevel = log.setLogLevel;
|
||||
exports.getLogLevel = log.getLogLevel;
|
||||
|
||||
var connection = require('./connection');
|
||||
exports.Connection = connection.Connection;
|
||||
exports.createClient = connection.createClient;
|
||||
exports.createConnection = connection.createConnection;
|
||||
exports.createUDSConnection = connection.createUDSConnection;
|
||||
exports.createSSLConnection = connection.createSSLConnection;
|
||||
exports.createStdIOClient = connection.createStdIOClient;
|
||||
exports.createStdIOConnection = connection.createStdIOConnection;
|
||||
|
@ -29,6 +35,7 @@ exports.createStdIOConnection = connection.createStdIOConnection;
|
|||
var httpConnection = require('./http_connection');
|
||||
exports.HttpConnection = httpConnection.HttpConnection;
|
||||
exports.createHttpConnection = httpConnection.createHttpConnection;
|
||||
exports.createHttpUDSConnection = httpConnection.createHttpUDSConnection;
|
||||
exports.createHttpClient = httpConnection.createHttpClient;
|
||||
|
||||
var wsConnection = require('./ws_connection');
|
||||
|
|
64
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/json_protocol.js
generated
vendored
64
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/json_protocol.js
generated
vendored
|
@ -17,9 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
var log = require('./log');
|
||||
var Int64 = require('node-int64');
|
||||
var InputBufferUnderrunError = require('./transport').InputBufferUnderrunError;
|
||||
var Thrift = require('./thrift');
|
||||
var Type = Thrift.Type;
|
||||
var util = require("util");
|
||||
|
@ -739,5 +737,65 @@ TJSONProtocol.prototype.getTransport = function() {
|
|||
* Method to arbitrarily skip over data
|
||||
*/
|
||||
TJSONProtocol.prototype.skip = function(type) {
|
||||
throw new Error('skip not supported yet');
|
||||
switch (type) {
|
||||
case Type.STOP:
|
||||
return;
|
||||
case Type.BOOL:
|
||||
this.readBool();
|
||||
break;
|
||||
case Type.BYTE:
|
||||
this.readByte();
|
||||
break;
|
||||
case Type.I16:
|
||||
this.readI16();
|
||||
break;
|
||||
case Type.I32:
|
||||
this.readI32();
|
||||
break;
|
||||
case Type.I64:
|
||||
this.readI64();
|
||||
break;
|
||||
case Type.DOUBLE:
|
||||
this.readDouble();
|
||||
break;
|
||||
case Type.STRING:
|
||||
this.readString();
|
||||
break;
|
||||
case Type.STRUCT:
|
||||
this.readStructBegin();
|
||||
while (true) {
|
||||
var r = this.readFieldBegin();
|
||||
if (r.ftype === Type.STOP) {
|
||||
break;
|
||||
}
|
||||
this.skip(r.ftype);
|
||||
this.readFieldEnd();
|
||||
}
|
||||
this.readStructEnd();
|
||||
break;
|
||||
case Type.MAP:
|
||||
var mapBegin = this.readMapBegin();
|
||||
for (var i = 0; i < mapBegin.size; ++i) {
|
||||
this.skip(mapBegin.ktype);
|
||||
this.skip(mapBegin.vtype);
|
||||
}
|
||||
this.readMapEnd();
|
||||
break;
|
||||
case Type.SET:
|
||||
var setBegin = this.readSetBegin();
|
||||
for (var i2 = 0; i2 < setBegin.size; ++i2) {
|
||||
this.skip(setBegin.etype);
|
||||
}
|
||||
this.readSetEnd();
|
||||
break;
|
||||
case Type.LIST:
|
||||
var listBegin = this.readListBegin();
|
||||
for (var i3 = 0; i3 < listBegin.size; ++i3) {
|
||||
this.skip(listBegin.etype);
|
||||
}
|
||||
this.readListEnd();
|
||||
break;
|
||||
default:
|
||||
throw new Error("Invalid type: " + type);
|
||||
}
|
||||
};
|
||||
|
|
73
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/log.js
generated
vendored
73
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/log.js
generated
vendored
|
@ -17,10 +17,71 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
'info' : function logInfo() {},
|
||||
'warning' : function logWarning() {},
|
||||
'error' : function logError() {},
|
||||
'debug' : function logDebug() {},
|
||||
'trace' : function logTrace() {}
|
||||
var util = require('util');
|
||||
|
||||
var disabled = function () {};
|
||||
var logFunc = console.log;
|
||||
var logLevel = 'error'; // default level
|
||||
|
||||
function factory(level) {
|
||||
return function () {
|
||||
// better use spread syntax, but due to compatibility,
|
||||
// use legacy method here.
|
||||
var args = ['thrift: [' + level + '] '].concat(Array.from(arguments));
|
||||
return logFunc(util.format.apply(null, args));
|
||||
};
|
||||
}
|
||||
|
||||
var trace = disabled;
|
||||
var debug = disabled;
|
||||
var error = disabled;
|
||||
var warning = disabled;
|
||||
var info = disabled;
|
||||
|
||||
exports.setLogFunc = function (func) {
|
||||
logFunc = func;
|
||||
};
|
||||
|
||||
var setLogLevel = exports.setLogLevel = function (level) {
|
||||
trace = debug = error = warning = info = disabled;
|
||||
logLevel = level;
|
||||
switch (logLevel) {
|
||||
case 'trace':
|
||||
trace = factory('TRACE');
|
||||
case 'debug':
|
||||
debug = factory('DEBUG');
|
||||
case 'error':
|
||||
error = factory('ERROR');
|
||||
case 'warning':
|
||||
warning = factory('WARN');
|
||||
case 'info':
|
||||
info = factory('INFO');
|
||||
}
|
||||
};
|
||||
|
||||
// set default
|
||||
setLogLevel(logLevel);
|
||||
|
||||
exports.getLogLevel = function () {
|
||||
return logLevel;
|
||||
};
|
||||
|
||||
exports.trace = function () {
|
||||
return trace.apply(null, arguments);
|
||||
};
|
||||
|
||||
exports.debug = function () {
|
||||
return debug.apply(null, arguments);
|
||||
};
|
||||
|
||||
exports.error = function () {
|
||||
return error.apply(null, arguments);
|
||||
};
|
||||
|
||||
exports.warning = function () {
|
||||
return warning.apply(null, arguments);
|
||||
};
|
||||
|
||||
exports.info = function () {
|
||||
return info.apply(null, arguments);
|
||||
};
|
||||
|
|
10
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/multiplexed_protocol.js
generated
vendored
10
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/multiplexed_protocol.js
generated
vendored
|
@ -52,17 +52,17 @@ Multiplexer.prototype.createClient = function(serviceName, ServiceClient, connec
|
|||
if (ServiceClient.Client) {
|
||||
ServiceClient = ServiceClient.Client;
|
||||
}
|
||||
var self = this;
|
||||
ServiceClient.prototype.new_seqid = function() {
|
||||
self.seqid += 1;
|
||||
return self.seqid;
|
||||
};
|
||||
var writeCb = function(buf, seqid) {
|
||||
connection.write(buf,seqid);
|
||||
};
|
||||
var transport = new connection.transport(undefined, writeCb);
|
||||
var protocolWrapper = new Wrapper(serviceName, connection.protocol, connection);
|
||||
var client = new ServiceClient(transport, protocolWrapper);
|
||||
var self = this;
|
||||
client.new_seqid = function() {
|
||||
self.seqid += 1;
|
||||
return self.seqid;
|
||||
};
|
||||
|
||||
if (typeof connection.client !== 'object') {
|
||||
connection.client = {};
|
||||
|
|
6
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/server.js
generated
vendored
6
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/server.js
generated
vendored
|
@ -16,6 +16,8 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
var constants = require('constants');
|
||||
var net = require('net');
|
||||
var tls = require('tls');
|
||||
|
||||
|
@ -87,6 +89,10 @@ exports.createMultiplexServer = function(processor, options) {
|
|||
}
|
||||
|
||||
if (options && options.tls) {
|
||||
if (!('secureProtocol' in options.tls) && !('secureOptions' in options.tls)) {
|
||||
options.tls.secureProtocol = "SSLv23_method";
|
||||
options.tls.secureOptions = constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3;
|
||||
}
|
||||
return tls.createServer(options.tls, serverImpl);
|
||||
} else {
|
||||
return net.createServer(serverImpl);
|
||||
|
|
21
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/web_server.js
generated
vendored
21
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/web_server.js
generated
vendored
|
@ -22,6 +22,7 @@ var url = require("url");
|
|||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
var crypto = require("crypto");
|
||||
var log = require('./log');
|
||||
|
||||
var MultiplexedProcessor = require('./multiplexed_processor').MultiplexedProcessor;
|
||||
|
||||
|
@ -284,7 +285,7 @@ exports.createWebServer = function(options) {
|
|||
'.jpeg': 'image/jpeg',
|
||||
'.gif': 'image/gif',
|
||||
'.png': 'image/png',
|
||||
'.svg': 'image/svg+xml'
|
||||
'.svg': 'image/svg+xml'
|
||||
};
|
||||
|
||||
//Setup all of the services
|
||||
|
@ -414,7 +415,15 @@ exports.createWebServer = function(options) {
|
|||
|
||||
//Locate the file requested and send it
|
||||
var uri = url.parse(request.url).pathname;
|
||||
var filename = path.join(baseDir, uri);
|
||||
var filename = path.resolve(path.join(baseDir, uri));
|
||||
|
||||
//Ensure the basedir path is not able to be escaped
|
||||
if (filename.indexOf(baseDir) != 0) {
|
||||
response.writeHead(400, "Invalid request path", {});
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
|
||||
fs.exists(filename, function(exists) {
|
||||
if(!exists) {
|
||||
response.writeHead(404);
|
||||
|
@ -547,7 +556,7 @@ exports.createWebServer = function(options) {
|
|||
frame = result.nextFrame;
|
||||
}
|
||||
} catch(e) {
|
||||
console.log("TWebSocketTransport Exception: " + e);
|
||||
log.error('TWebSocketTransport Exception: ' + e);
|
||||
socket.destroy();
|
||||
}
|
||||
});
|
||||
|
@ -556,9 +565,3 @@ exports.createWebServer = function(options) {
|
|||
//Return the server
|
||||
return server;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
4
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/ws_transport.js
generated
vendored
4
vendor/git.apache.org/thrift.git/lib/nodejs/lib/thrift/ws_transport.js
generated
vendored
|
@ -17,6 +17,8 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
var log = require('./log');
|
||||
|
||||
module.exports = TWebSocketTransport;
|
||||
|
||||
/**
|
||||
|
@ -105,7 +107,7 @@ TWebSocketTransport.prototype.__onMessage = function(evt) {
|
|||
};
|
||||
|
||||
TWebSocketTransport.prototype.__onError = function(evt) {
|
||||
console.log("Thrift WebSocket Error: " + evt.toString());
|
||||
log.error('websocket: ' + evt.toString());
|
||||
this.socket.close();
|
||||
};
|
||||
|
||||
|
|
143
vendor/git.apache.org/thrift.git/lib/nodejs/test/binary.test.js
generated
vendored
143
vendor/git.apache.org/thrift.git/lib/nodejs/test/binary.test.js
generated
vendored
|
@ -17,19 +17,19 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
var test = require('tape');
|
||||
var binary = require('thrift/binary');
|
||||
const test = require("tape");
|
||||
const binary = require("thrift/binary");
|
||||
|
||||
var cases = {
|
||||
"Should read signed byte": function(assert){
|
||||
const cases = {
|
||||
"Should read signed byte": function(assert) {
|
||||
assert.equal(1, binary.readByte(0x01));
|
||||
assert.equal(-1, binary.readByte(0xFF));
|
||||
assert.equal(-1, binary.readByte(0xff));
|
||||
|
||||
assert.equal(127, binary.readByte(0x7F));
|
||||
assert.equal(127, binary.readByte(0x7f));
|
||||
assert.equal(-128, binary.readByte(0x80));
|
||||
assert.end();
|
||||
},
|
||||
"Should write byte": function(assert){
|
||||
"Should write byte": function(assert) {
|
||||
//Protocol simply writes to the buffer. Nothing to test.. yet.
|
||||
assert.ok(true);
|
||||
assert.end();
|
||||
|
@ -76,58 +76,135 @@ var cases = {
|
|||
assert.deepEqual([0xff, 0xff, 0xff, 0xff], binary.writeI32([], -1));
|
||||
|
||||
// Min I32
|
||||
assert.deepEqual([0x80, 0x00, 0x00, 0x00], binary.writeI32([], -2147483648));
|
||||
assert.deepEqual(
|
||||
[0x80, 0x00, 0x00, 0x00],
|
||||
binary.writeI32([], -2147483648)
|
||||
);
|
||||
// Max I32
|
||||
assert.deepEqual([0x7f, 0xff, 0xff, 0xff], binary.writeI32([], 2147483647));
|
||||
assert.end();
|
||||
},
|
||||
|
||||
"Should read doubles": function(assert) {
|
||||
assert.equal(0, binary.readDouble([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(0, binary.readDouble([0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(1, binary.readDouble([0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(2, binary.readDouble([0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(-2, binary.readDouble([0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(
|
||||
0,
|
||||
binary.readDouble([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
assert.equal(
|
||||
0,
|
||||
binary.readDouble([0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
assert.equal(
|
||||
1,
|
||||
binary.readDouble([0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
assert.equal(
|
||||
2,
|
||||
binary.readDouble([0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
assert.equal(
|
||||
-2,
|
||||
binary.readDouble([0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
|
||||
assert.equal(Math.PI, binary.readDouble([0x40, 0x9, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18]))
|
||||
assert.equal(
|
||||
Math.PI,
|
||||
binary.readDouble([0x40, 0x9, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18])
|
||||
);
|
||||
|
||||
assert.equal(Infinity, binary.readDouble([0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(-Infinity, binary.readDouble([0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(
|
||||
Infinity,
|
||||
binary.readDouble([0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
assert.equal(
|
||||
-Infinity,
|
||||
binary.readDouble([0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
|
||||
assert.ok(isNaN(binary.readDouble([0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])))
|
||||
assert.ok(
|
||||
isNaN(binary.readDouble([0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
);
|
||||
|
||||
assert.equal(1/3, binary.readDouble([0x3f, 0xd5, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55]))
|
||||
assert.equal(
|
||||
1 / 3,
|
||||
binary.readDouble([0x3f, 0xd5, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55])
|
||||
);
|
||||
|
||||
// Min subnormal positive double
|
||||
assert.equal(4.9406564584124654e-324, binary.readDouble([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]))
|
||||
assert.equal(
|
||||
4.9406564584124654e-324,
|
||||
binary.readDouble([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01])
|
||||
);
|
||||
// Min normal positive double
|
||||
assert.equal(2.2250738585072014e-308, binary.readDouble([0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||
assert.equal(
|
||||
2.2250738585072014e-308,
|
||||
binary.readDouble([0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
);
|
||||
// Max positive double
|
||||
assert.equal(1.7976931348623157e308, binary.readDouble([0x7f, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
|
||||
assert.equal(
|
||||
1.7976931348623157e308,
|
||||
binary.readDouble([0x7f, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff])
|
||||
);
|
||||
assert.end();
|
||||
},
|
||||
|
||||
"Should write doubles": function(assert) {
|
||||
assert.deepEqual([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], 0));
|
||||
assert.deepEqual([0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], 1));
|
||||
assert.deepEqual([0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], 2));
|
||||
assert.deepEqual([0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], -2));
|
||||
assert.deepEqual(
|
||||
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], 0)
|
||||
);
|
||||
assert.deepEqual(
|
||||
[0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], 1)
|
||||
);
|
||||
assert.deepEqual(
|
||||
[0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], 2)
|
||||
);
|
||||
assert.deepEqual(
|
||||
[0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], -2)
|
||||
);
|
||||
|
||||
assert.deepEqual([0x40, 0x9, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18], binary.writeDouble([], Math.PI));
|
||||
assert.deepEqual(
|
||||
[0x40, 0x9, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18],
|
||||
binary.writeDouble([], Math.PI)
|
||||
);
|
||||
|
||||
assert.deepEqual([0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], Infinity));
|
||||
assert.deepEqual([0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], -Infinity));
|
||||
assert.deepEqual(
|
||||
[0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], Infinity)
|
||||
);
|
||||
assert.deepEqual(
|
||||
[0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], -Infinity)
|
||||
);
|
||||
|
||||
assert.deepEqual([0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], NaN));
|
||||
assert.deepEqual(
|
||||
[0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], NaN)
|
||||
);
|
||||
|
||||
assert.deepEqual([0x3f, 0xd5, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55], binary.writeDouble([], 1/3));
|
||||
assert.deepEqual(
|
||||
[0x3f, 0xd5, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55],
|
||||
binary.writeDouble([], 1 / 3)
|
||||
);
|
||||
|
||||
// Min subnormal positive double
|
||||
assert.deepEqual([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01], binary.writeDouble([], 4.9406564584124654e-324));
|
||||
assert.deepEqual(
|
||||
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01],
|
||||
binary.writeDouble([], 4.9406564584124654e-324)
|
||||
);
|
||||
// Min normal positive double
|
||||
assert.deepEqual([0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], binary.writeDouble([], 2.2250738585072014e-308));
|
||||
assert.deepEqual(
|
||||
[0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||
binary.writeDouble([], 2.2250738585072014e-308)
|
||||
);
|
||||
// Max positive double
|
||||
assert.deepEqual([0x7f, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff], binary.writeDouble([], 1.7976931348623157e308));
|
||||
assert.deepEqual(
|
||||
[0x7f, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff],
|
||||
binary.writeDouble([], 1.7976931348623157e308)
|
||||
);
|
||||
assert.end();
|
||||
}
|
||||
};
|
||||
|
|
27
vendor/git.apache.org/thrift.git/lib/nodejs/test/browser_client.js
generated
vendored
27
vendor/git.apache.org/thrift.git/lib/nodejs/test/browser_client.js
generated
vendored
|
@ -1,27 +0,0 @@
|
|||
|
||||
var assert = require('assert');
|
||||
var thrift = require('thrift');
|
||||
var helpers = require('./helpers');
|
||||
var ThriftTest = require('./gen-nodejs/ThriftTest');
|
||||
var ThriftTestDriver = require('./test_driver').ThriftTestDriver;
|
||||
|
||||
// createXHRConnection createWSConnection
|
||||
var connection = thrift.createXHRConnection("localhost", 9090, {
|
||||
transport: helpers.transports['buffered'],
|
||||
protocol: helpers.protocols['json'],
|
||||
path: '/test'
|
||||
});
|
||||
|
||||
connection.on('error', function(err) {
|
||||
assert(false, err);
|
||||
});
|
||||
|
||||
// Uncomment the following line to start a websockets connection
|
||||
// connection.open();
|
||||
|
||||
// createWSClient createXHRClient
|
||||
var client = thrift.createXHRClient(ThriftTest, connection);
|
||||
|
||||
ThriftTestDriver(client, function (status) {
|
||||
console.log('Browser:', status);
|
||||
});
|
146
vendor/git.apache.org/thrift.git/lib/nodejs/test/client.js
generated
vendored
146
vendor/git.apache.org/thrift.git/lib/nodejs/test/client.js
generated
vendored
|
@ -19,109 +19,149 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
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('./test_driver').ThriftTestDriver;
|
||||
var ThriftTestDriverPromise = require('./test_driver').ThriftTestDriverPromise;
|
||||
var SecondService = require('./gen-nodejs/SecondService');
|
||||
var ttypes = require('./gen-nodejs/ThriftTest_types');
|
||||
const assert = require("assert");
|
||||
const thrift = require("thrift");
|
||||
const helpers = require("./helpers");
|
||||
|
||||
var program = require('commander');
|
||||
const ThriftTest = require(`./${helpers.genPath}/ThriftTest`);
|
||||
const ThriftTestDriver = require("./test_driver").ThriftTestDriver;
|
||||
const ThriftTestDriverPromise = require("./test_driver")
|
||||
.ThriftTestDriverPromise;
|
||||
const SecondService = require(`./${helpers.genPath}/SecondService`);
|
||||
|
||||
const 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 thrift server port number to connect', 9090)
|
||||
.option('--host <host>', 'Set thrift 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')
|
||||
.option(
|
||||
"-p, --protocol <protocol>",
|
||||
"Set thrift protocol (binary|compact|json) [protocol]"
|
||||
)
|
||||
.option(
|
||||
"-t, --transport <transport>",
|
||||
"Set thrift transport (buffered|framed|http) [transport]"
|
||||
)
|
||||
.option("--port <port>", "Set thrift server port number to connect", 9090)
|
||||
.option("--host <host>", "Set thrift server host to connect", "localhost")
|
||||
.option(
|
||||
"--domain-socket <path>",
|
||||
"Set thrift server unix domain socket to connect"
|
||||
)
|
||||
.option("--ssl", "use SSL transport")
|
||||
.option("--callback", "test with callback style functions")
|
||||
.option(
|
||||
"-t, --type <type>",
|
||||
"Select server type (http|multiplex|tcp|websocket)",
|
||||
"tcp"
|
||||
)
|
||||
.option("--es6", "Use es6 code")
|
||||
.option("--es5", "Use es5 code")
|
||||
.parse(process.argv);
|
||||
|
||||
var host = program.host;
|
||||
var port = program.port;
|
||||
var type = program.type;
|
||||
var ssl = program.ssl;
|
||||
var promise = program.promise;
|
||||
const host = program.host;
|
||||
const port = program.port;
|
||||
const domainSocket = program.domainSocket;
|
||||
const ssl = program.ssl;
|
||||
let type = program.type;
|
||||
|
||||
var options = {
|
||||
/* for compatibility with cross test invocation for http transport testing */
|
||||
if (program.transport === "http") {
|
||||
program.transport = "buffered";
|
||||
type = "http";
|
||||
}
|
||||
|
||||
const options = {
|
||||
transport: helpers.transports[program.transport],
|
||||
protocol: helpers.protocols[program.protocol]
|
||||
};
|
||||
|
||||
if (type === 'http' || type === 'websocket') {
|
||||
options.path = '/test';
|
||||
if (type === "http" || type === "websocket") {
|
||||
options.path = "/test";
|
||||
}
|
||||
|
||||
if (type === 'http') {
|
||||
options.headers = {"Connection": "close"};
|
||||
if (type === "http") {
|
||||
options.headers = { Connection: "close" };
|
||||
}
|
||||
|
||||
if (ssl) {
|
||||
if (type === 'tcp' || type === 'multiplex') {
|
||||
if (type === "tcp" || type === "multiplex") {
|
||||
options.rejectUnauthorized = false;
|
||||
} else if (type === 'http') {
|
||||
} else if (type === "http") {
|
||||
options.nodeOptions = { rejectUnauthorized: false };
|
||||
options.https = true;
|
||||
} else if (type === 'websocket') {
|
||||
} else if (type === "websocket") {
|
||||
options.wsOptions = { rejectUnauthorized: false };
|
||||
options.secure = true;
|
||||
}
|
||||
}
|
||||
|
||||
var connection;
|
||||
var client;
|
||||
var testDriver = promise ? ThriftTestDriverPromise : ThriftTestDriver;
|
||||
let connection;
|
||||
let client;
|
||||
const testDriver = program.callback
|
||||
? ThriftTestDriver
|
||||
: ThriftTestDriverPromise;
|
||||
if (helpers.ecmaMode === "es6" && program.callback) {
|
||||
console.log("ES6 does not support callback style");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
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') {
|
||||
if (type === "tcp" || type === "multiplex") {
|
||||
if (domainSocket) {
|
||||
connection = thrift.createUDSConnection(domainSocket, options);
|
||||
} else {
|
||||
connection = ssl
|
||||
? thrift.createSSLConnection(host, port, options)
|
||||
: thrift.createConnection(host, port, options);
|
||||
}
|
||||
} else if (type === "http") {
|
||||
if (domainSocket) {
|
||||
connection = thrift.createHttpUDSConnection(domainSocket, options);
|
||||
} else {
|
||||
connection = thrift.createHttpConnection(host, port, options);
|
||||
}
|
||||
} else if (type === "websocket") {
|
||||
connection = thrift.createWSConnection(host, port, options);
|
||||
connection.open();
|
||||
}
|
||||
|
||||
connection.on('error', function(err) {
|
||||
assert(false, err);
|
||||
connection.on("error", function(err) {
|
||||
assert(false, err);
|
||||
});
|
||||
|
||||
if (type === 'tcp') {
|
||||
if (type === "tcp") {
|
||||
client = thrift.createClient(ThriftTest, connection);
|
||||
runTests();
|
||||
} else if (type === 'multiplex') {
|
||||
var mp = new thrift.Multiplexer();
|
||||
} else if (type === "multiplex") {
|
||||
const mp = new thrift.Multiplexer();
|
||||
client = mp.createClient("ThriftTest", ThriftTest, connection);
|
||||
secondclient = mp.createClient("SecondService", SecondService, connection);
|
||||
const secondclient = mp.createClient(
|
||||
"SecondService",
|
||||
SecondService,
|
||||
connection
|
||||
);
|
||||
|
||||
connection.on('connect', function() {
|
||||
connection.on("connect", function() {
|
||||
secondclient.secondtestString("Test", function(err, response) {
|
||||
assert(!err);
|
||||
assert.equal("Test", response);
|
||||
assert.equal('testString("Test")', response);
|
||||
});
|
||||
|
||||
runTests();
|
||||
});
|
||||
} else if (type === 'http') {
|
||||
} else if (type === "http") {
|
||||
client = thrift.createHttpClient(ThriftTest, connection);
|
||||
runTests();
|
||||
} else if (type === 'websocket') {
|
||||
} else if (type === "websocket") {
|
||||
client = thrift.createWSClient(ThriftTest, connection);
|
||||
runTests();
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
testDriver(client, function (status) {
|
||||
testDriver(client, function(status) {
|
||||
console.log(status);
|
||||
if (type !== 'http' && type !== 'websocket') {
|
||||
if (type !== "http" && type !== "websocket") {
|
||||
connection.end();
|
||||
}
|
||||
if (type !== 'multiplex') {
|
||||
if (type !== "multiplex") {
|
||||
process.exit(0);
|
||||
}
|
||||
});
|
||||
|
|
335
vendor/git.apache.org/thrift.git/lib/nodejs/test/deep-constructor.test.js
generated
vendored
335
vendor/git.apache.org/thrift.git/lib/nodejs/test/deep-constructor.test.js
generated
vendored
|
@ -1,36 +1,52 @@
|
|||
var ttypes = require('./gen-nodejs/JsDeepConstructorTest_types');
|
||||
var thrift = require('thrift');
|
||||
var test = require('tape');
|
||||
var bufferEquals = require('buffer-equals');
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const ttypes = require("./gen-nodejs/JsDeepConstructorTest_types");
|
||||
const thrift = require("thrift");
|
||||
const test = require("tape");
|
||||
const bufferEquals = require("buffer-equals");
|
||||
|
||||
function serializeBinary(data) {
|
||||
var buff;
|
||||
var transport = new thrift.TBufferedTransport(null, function(msg){
|
||||
let buff;
|
||||
const transport = new thrift.TBufferedTransport(null, function(msg) {
|
||||
buff = msg;
|
||||
});
|
||||
var prot = new thrift.TBinaryProtocol(transport);
|
||||
const prot = new thrift.TBinaryProtocol(transport);
|
||||
data.write(prot);
|
||||
prot.flush();
|
||||
return buff;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function deserializeBinary(serialized, type) {
|
||||
var t = new thrift.TFramedTransport(serialized);
|
||||
var p = new thrift.TBinaryProtocol(t);
|
||||
var data = new type();
|
||||
const t = new thrift.TFramedTransport(serialized);
|
||||
const p = new thrift.TBinaryProtocol(t);
|
||||
const data = new type();
|
||||
data.read(p);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
function serializeJSON(data) {
|
||||
var buff;
|
||||
var transport = new thrift.TBufferedTransport(null, function(msg){
|
||||
let buff;
|
||||
const transport = new thrift.TBufferedTransport(null, function(msg) {
|
||||
buff = msg;
|
||||
});
|
||||
var protocol = new thrift.TJSONProtocol(transport);
|
||||
const protocol = new thrift.TJSONProtocol(transport);
|
||||
protocol.writeMessageBegin("", 0, 0);
|
||||
data.write(protocol);
|
||||
protocol.writeMessageEnd();
|
||||
|
@ -38,45 +54,41 @@ function serializeJSON(data) {
|
|||
return buff;
|
||||
}
|
||||
|
||||
|
||||
function deserializeJSON(serialized, type) {
|
||||
var transport = new thrift.TFramedTransport(serialized);
|
||||
var protocol = new thrift.TJSONProtocol(transport);
|
||||
const transport = new thrift.TFramedTransport(serialized);
|
||||
const protocol = new thrift.TJSONProtocol(transport);
|
||||
protocol.readMessageBegin();
|
||||
var data = new type();
|
||||
const data = new type();
|
||||
data.read(protocol);
|
||||
protocol.readMessageEnd();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
function createThriftObj() {
|
||||
|
||||
return new ttypes.Complex({
|
||||
|
||||
struct_field: new ttypes.Simple({value: 'a'}),
|
||||
struct_field: new ttypes.Simple({ value: "a" }),
|
||||
|
||||
struct_list_field: [
|
||||
new ttypes.Simple({value: 'b'}),
|
||||
new ttypes.Simple({value: 'c'}),
|
||||
new ttypes.Simple({ value: "b" }),
|
||||
new ttypes.Simple({ value: "c" })
|
||||
],
|
||||
|
||||
struct_set_field: [
|
||||
new ttypes.Simple({value: 'd'}),
|
||||
new ttypes.Simple({value: 'e'}),
|
||||
new ttypes.Simple({ value: "d" }),
|
||||
new ttypes.Simple({ value: "e" })
|
||||
],
|
||||
|
||||
struct_map_field: {
|
||||
A: new ttypes.Simple({value: 'f'}),
|
||||
B: new ttypes.Simple({value: 'g'})
|
||||
A: new ttypes.Simple({ value: "f" }),
|
||||
B: new ttypes.Simple({ value: "g" })
|
||||
},
|
||||
|
||||
struct_nested_containers_field: [
|
||||
[
|
||||
{
|
||||
C: [
|
||||
new ttypes.Simple({value: 'h'}),
|
||||
new ttypes.Simple({value: 'i'})
|
||||
new ttypes.Simple({ value: "h" }),
|
||||
new ttypes.Simple({ value: "i" })
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -85,59 +97,57 @@ function createThriftObj() {
|
|||
struct_nested_containers_field2: {
|
||||
D: [
|
||||
{
|
||||
DA: new ttypes.Simple({value: 'j'})
|
||||
DA: new ttypes.Simple({ value: "j" })
|
||||
},
|
||||
{
|
||||
DB: new ttypes.Simple({value: 'k'})
|
||||
DB: new ttypes.Simple({ value: "k" })
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
list_of_list_field: [
|
||||
['l00', 'l01', 'l02'],
|
||||
['l10', 'l11', 'l12'],
|
||||
['l20', 'l21', 'l22'],
|
||||
["l00", "l01", "l02"],
|
||||
["l10", "l11", "l12"],
|
||||
["l20", "l21", "l22"]
|
||||
],
|
||||
|
||||
list_of_list_of_list_field: [
|
||||
[['m000', 'm001', 'm002'], ['m010', 'm011', 'm012'], ['m020', 'm021', 'm022']],
|
||||
[['m100', 'm101', 'm102'], ['m110', 'm111', 'm112'], ['m120', 'm121', 'm122']],
|
||||
[['m200', 'm201', 'm202'], ['m210', 'm211', 'm212'], ['m220', 'm221', 'm222']],
|
||||
],
|
||||
|
||||
|
||||
[
|
||||
["m000", "m001", "m002"],
|
||||
["m010", "m011", "m012"],
|
||||
["m020", "m021", "m022"]
|
||||
],
|
||||
[
|
||||
["m100", "m101", "m102"],
|
||||
["m110", "m111", "m112"],
|
||||
["m120", "m121", "m122"]
|
||||
],
|
||||
[
|
||||
["m200", "m201", "m202"],
|
||||
["m210", "m211", "m212"],
|
||||
["m220", "m221", "m222"]
|
||||
]
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function createJsObj() {
|
||||
|
||||
return {
|
||||
struct_field: { value: "a" },
|
||||
|
||||
struct_field: {value: 'a'},
|
||||
struct_list_field: [{ value: "b" }, { value: "c" }],
|
||||
|
||||
struct_list_field: [
|
||||
{value: 'b'},
|
||||
{value: 'c'},
|
||||
],
|
||||
|
||||
struct_set_field: [
|
||||
{value: 'd'},
|
||||
{value: 'e'},
|
||||
],
|
||||
struct_set_field: [{ value: "d" }, { value: "e" }],
|
||||
|
||||
struct_map_field: {
|
||||
A: {value: 'f'},
|
||||
B: {value: 'g'}
|
||||
A: { value: "f" },
|
||||
B: { value: "g" }
|
||||
},
|
||||
|
||||
struct_nested_containers_field: [
|
||||
[
|
||||
{
|
||||
C: [
|
||||
{value: 'h'},
|
||||
{value: 'i'}
|
||||
]
|
||||
C: [{ value: "h" }, { value: "i" }]
|
||||
}
|
||||
]
|
||||
],
|
||||
|
@ -145,131 +155,142 @@ function createJsObj() {
|
|||
struct_nested_containers_field2: {
|
||||
D: [
|
||||
{
|
||||
DA: {value: 'j'}
|
||||
DA: { value: "j" }
|
||||
},
|
||||
{
|
||||
DB: {value: 'k'}
|
||||
DB: { value: "k" }
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
list_of_list_field: [
|
||||
['l00', 'l01', 'l02'],
|
||||
['l10', 'l11', 'l12'],
|
||||
['l20', 'l21', 'l22'],
|
||||
["l00", "l01", "l02"],
|
||||
["l10", "l11", "l12"],
|
||||
["l20", "l21", "l22"]
|
||||
],
|
||||
|
||||
list_of_list_of_list_field: [
|
||||
[['m000', 'm001', 'm002'], ['m010', 'm011', 'm012'], ['m020', 'm021', 'm022']],
|
||||
[['m100', 'm101', 'm102'], ['m110', 'm111', 'm112'], ['m120', 'm121', 'm122']],
|
||||
[['m200', 'm201', 'm202'], ['m210', 'm211', 'm212'], ['m220', 'm221', 'm222']],
|
||||
],
|
||||
|
||||
[
|
||||
["m000", "m001", "m002"],
|
||||
["m010", "m011", "m012"],
|
||||
["m020", "m021", "m022"]
|
||||
],
|
||||
[
|
||||
["m100", "m101", "m102"],
|
||||
["m110", "m111", "m112"],
|
||||
["m120", "m121", "m122"]
|
||||
],
|
||||
[
|
||||
["m200", "m201", "m202"],
|
||||
["m210", "m211", "m212"],
|
||||
["m220", "m221", "m222"]
|
||||
]
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function assertValues(obj, assert) {
|
||||
assert.equals(obj.struct_field.value, 'a');
|
||||
assert.equals(obj.struct_list_field[0].value, 'b');
|
||||
assert.equals(obj.struct_list_field[1].value, 'c');
|
||||
assert.equals(obj.struct_set_field[0].value, 'd');
|
||||
assert.equals(obj.struct_set_field[1].value, 'e');
|
||||
assert.equals(obj.struct_map_field.A.value, 'f');
|
||||
assert.equals(obj.struct_map_field.B.value, 'g');
|
||||
assert.equals(obj.struct_nested_containers_field[0][0].C[0].value, 'h');
|
||||
assert.equals(obj.struct_nested_containers_field[0][0].C[1].value, 'i');
|
||||
assert.equals(obj.struct_nested_containers_field2.D[0].DA.value, 'j');
|
||||
assert.equals(obj.struct_nested_containers_field2.D[1].DB.value, 'k');
|
||||
assert.equals(obj.list_of_list_field[0][0], 'l00');
|
||||
assert.equals(obj.list_of_list_field[0][1], 'l01');
|
||||
assert.equals(obj.list_of_list_field[0][2], 'l02');
|
||||
assert.equals(obj.list_of_list_field[1][0], 'l10');
|
||||
assert.equals(obj.list_of_list_field[1][1], 'l11');
|
||||
assert.equals(obj.list_of_list_field[1][2], 'l12');
|
||||
assert.equals(obj.list_of_list_field[2][0], 'l20');
|
||||
assert.equals(obj.list_of_list_field[2][1], 'l21');
|
||||
assert.equals(obj.list_of_list_field[2][2], 'l22');
|
||||
assert.equals(obj.struct_field.value, "a");
|
||||
assert.equals(obj.struct_list_field[0].value, "b");
|
||||
assert.equals(obj.struct_list_field[1].value, "c");
|
||||
assert.equals(obj.struct_set_field[0].value, "d");
|
||||
assert.equals(obj.struct_set_field[1].value, "e");
|
||||
assert.equals(obj.struct_map_field.A.value, "f");
|
||||
assert.equals(obj.struct_map_field.B.value, "g");
|
||||
assert.equals(obj.struct_nested_containers_field[0][0].C[0].value, "h");
|
||||
assert.equals(obj.struct_nested_containers_field[0][0].C[1].value, "i");
|
||||
assert.equals(obj.struct_nested_containers_field2.D[0].DA.value, "j");
|
||||
assert.equals(obj.struct_nested_containers_field2.D[1].DB.value, "k");
|
||||
assert.equals(obj.list_of_list_field[0][0], "l00");
|
||||
assert.equals(obj.list_of_list_field[0][1], "l01");
|
||||
assert.equals(obj.list_of_list_field[0][2], "l02");
|
||||
assert.equals(obj.list_of_list_field[1][0], "l10");
|
||||
assert.equals(obj.list_of_list_field[1][1], "l11");
|
||||
assert.equals(obj.list_of_list_field[1][2], "l12");
|
||||
assert.equals(obj.list_of_list_field[2][0], "l20");
|
||||
assert.equals(obj.list_of_list_field[2][1], "l21");
|
||||
assert.equals(obj.list_of_list_field[2][2], "l22");
|
||||
|
||||
assert.equals(obj.list_of_list_of_list_field[0][0][0], 'm000');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][0][1], 'm001');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][0][2], 'm002');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][1][0], 'm010');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][1][1], 'm011');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][1][2], 'm012');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][2][0], 'm020');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][2][1], 'm021');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][2][2], 'm022');
|
||||
assert.equals(obj.list_of_list_of_list_field[0][0][0], "m000");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][0][1], "m001");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][0][2], "m002");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][1][0], "m010");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][1][1], "m011");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][1][2], "m012");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][2][0], "m020");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][2][1], "m021");
|
||||
assert.equals(obj.list_of_list_of_list_field[0][2][2], "m022");
|
||||
|
||||
assert.equals(obj.list_of_list_of_list_field[1][0][0], 'm100');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][0][1], 'm101');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][0][2], 'm102');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][1][0], 'm110');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][1][1], 'm111');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][1][2], 'm112');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][2][0], 'm120');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][2][1], 'm121');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][2][2], 'm122');
|
||||
assert.equals(obj.list_of_list_of_list_field[1][0][0], "m100");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][0][1], "m101");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][0][2], "m102");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][1][0], "m110");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][1][1], "m111");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][1][2], "m112");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][2][0], "m120");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][2][1], "m121");
|
||||
assert.equals(obj.list_of_list_of_list_field[1][2][2], "m122");
|
||||
|
||||
assert.equals(obj.list_of_list_of_list_field[2][0][0], 'm200');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][0][1], 'm201');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][0][2], 'm202');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][1][0], 'm210');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][1][1], 'm211');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][1][2], 'm212');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][2][0], 'm220');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][2][1], 'm221');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][2][2], 'm222');
|
||||
assert.equals(obj.list_of_list_of_list_field[2][0][0], "m200");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][0][1], "m201");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][0][2], "m202");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][1][0], "m210");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][1][1], "m211");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][1][2], "m212");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][2][0], "m220");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][2][1], "m221");
|
||||
assert.equals(obj.list_of_list_of_list_field[2][2][2], "m222");
|
||||
}
|
||||
|
||||
function createTestCases(serialize, deserialize) {
|
||||
|
||||
var cases = {
|
||||
|
||||
"Serialize/deserialize should return equal object": function(assert){
|
||||
var tObj = createThriftObj();
|
||||
var received = deserialize(serialize(tObj), ttypes.Complex);
|
||||
assert.ok(tObj !== received, 'not the same object');
|
||||
const cases = {
|
||||
"Serialize/deserialize should return equal object": function(assert) {
|
||||
const tObj = createThriftObj();
|
||||
const received = deserialize(serialize(tObj), ttypes.Complex);
|
||||
assert.ok(tObj !== received, "not the same object");
|
||||
assert.deepEqual(tObj, received);
|
||||
assert.end();
|
||||
},
|
||||
|
||||
"Nested structs and containers initialized from plain js objects should serialize same as if initialized from thrift objects": function(assert) {
|
||||
var tObj1 = createThriftObj();
|
||||
var tObj2 = new ttypes.Complex(createJsObj());
|
||||
"Nested structs and containers initialized from plain js objects should serialize same as if initialized from thrift objects": function(
|
||||
assert
|
||||
) {
|
||||
const tObj1 = createThriftObj();
|
||||
const tObj2 = new ttypes.Complex(createJsObj());
|
||||
assertValues(tObj2, assert);
|
||||
var s1 = serialize(tObj1);
|
||||
var s2 = serialize(tObj2);
|
||||
const s1 = serialize(tObj1);
|
||||
const s2 = serialize(tObj2);
|
||||
assert.ok(bufferEquals(s1, s2));
|
||||
assert.end();
|
||||
},
|
||||
|
||||
"Modifications to args object should not affect constructed Thrift object": function (assert) {
|
||||
|
||||
var args = createJsObj();
|
||||
"Modifications to args object should not affect constructed Thrift object": function(
|
||||
assert
|
||||
) {
|
||||
const args = createJsObj();
|
||||
assertValues(args, assert);
|
||||
|
||||
var tObj = new ttypes.Complex(args);
|
||||
const tObj = new ttypes.Complex(args);
|
||||
assertValues(tObj, assert);
|
||||
|
||||
args.struct_field.value = 'ZZZ';
|
||||
args.struct_list_field[0].value = 'ZZZ';
|
||||
args.struct_list_field[1].value = 'ZZZ';
|
||||
args.struct_set_field[0].value = 'ZZZ';
|
||||
args.struct_set_field[1].value = 'ZZZ';
|
||||
args.struct_map_field.A.value = 'ZZZ';
|
||||
args.struct_map_field.B.value = 'ZZZ';
|
||||
args.struct_nested_containers_field[0][0].C[0] = 'ZZZ';
|
||||
args.struct_nested_containers_field[0][0].C[1] = 'ZZZ';
|
||||
args.struct_nested_containers_field2.D[0].DA = 'ZZZ';
|
||||
args.struct_nested_containers_field2.D[0].DB = 'ZZZ';
|
||||
args.struct_field.value = "ZZZ";
|
||||
args.struct_list_field[0].value = "ZZZ";
|
||||
args.struct_list_field[1].value = "ZZZ";
|
||||
args.struct_set_field[0].value = "ZZZ";
|
||||
args.struct_set_field[1].value = "ZZZ";
|
||||
args.struct_map_field.A.value = "ZZZ";
|
||||
args.struct_map_field.B.value = "ZZZ";
|
||||
args.struct_nested_containers_field[0][0].C[0] = "ZZZ";
|
||||
args.struct_nested_containers_field[0][0].C[1] = "ZZZ";
|
||||
args.struct_nested_containers_field2.D[0].DA = "ZZZ";
|
||||
args.struct_nested_containers_field2.D[0].DB = "ZZZ";
|
||||
|
||||
assertValues(tObj, assert);
|
||||
assert.end();
|
||||
},
|
||||
|
||||
"nulls are ok": function(assert) {
|
||||
var tObj = new ttypes.Complex({
|
||||
const tObj = new ttypes.Complex({
|
||||
struct_field: null,
|
||||
struct_list_field: null,
|
||||
struct_set_field: null,
|
||||
|
@ -277,7 +298,7 @@ function createTestCases(serialize, deserialize) {
|
|||
struct_nested_containers_field: null,
|
||||
struct_nested_containers_field2: null
|
||||
});
|
||||
var received = deserialize(serialize(tObj), ttypes.Complex);
|
||||
const received = deserialize(serialize(tObj), ttypes.Complex);
|
||||
assert.strictEqual(tObj.struct_field, null);
|
||||
assert.ok(tObj !== received);
|
||||
assert.deepEqual(tObj, received);
|
||||
|
@ -285,11 +306,11 @@ function createTestCases(serialize, deserialize) {
|
|||
},
|
||||
|
||||
"Can make list with objects": function(assert) {
|
||||
var tObj = new ttypes.ComplexList({
|
||||
"struct_list_field": [new ttypes.Complex({})]
|
||||
const tObj = new ttypes.ComplexList({
|
||||
struct_list_field: [new ttypes.Complex({})]
|
||||
});
|
||||
var innerObj = tObj.struct_list_field[0];
|
||||
assert.ok(innerObj instanceof ttypes.Complex)
|
||||
const innerObj = tObj.struct_list_field[0];
|
||||
assert.ok(innerObj instanceof ttypes.Complex);
|
||||
assert.strictEqual(innerObj.struct_field, null);
|
||||
assert.strictEqual(innerObj.struct_list_field, null);
|
||||
assert.strictEqual(innerObj.struct_set_field, null);
|
||||
|
@ -298,17 +319,15 @@ function createTestCases(serialize, deserialize) {
|
|||
assert.strictEqual(innerObj.struct_nested_containers_field2, null);
|
||||
assert.end();
|
||||
}
|
||||
|
||||
};
|
||||
return cases;
|
||||
}
|
||||
|
||||
|
||||
function run(name, cases){
|
||||
function run(name, cases) {
|
||||
Object.keys(cases).forEach(function(caseName) {
|
||||
test(name + ': ' + caseName, cases[caseName]);
|
||||
test(name + ": " + caseName, cases[caseName]);
|
||||
});
|
||||
}
|
||||
|
||||
run('binary', createTestCases(serializeBinary, deserializeBinary));
|
||||
run('json', createTestCases(serializeJSON, deserializeJSON));
|
||||
run("binary", createTestCases(serializeBinary, deserializeBinary));
|
||||
run("json", createTestCases(serializeJSON, deserializeJSON));
|
||||
|
|
177
vendor/git.apache.org/thrift.git/lib/nodejs/test/exceptions.js
generated
vendored
177
vendor/git.apache.org/thrift.git/lib/nodejs/test/exceptions.js
generated
vendored
|
@ -1,55 +1,146 @@
|
|||
'use strict';
|
||||
var test = require('tape');
|
||||
var thrift = require('../lib/thrift/thrift.js');
|
||||
var InputBufferUnderrunError = require('../lib/thrift/input_buffer_underrun_error');
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
test('TApplicationException', function t(assert) {
|
||||
var e = new thrift.TApplicationException(1, 'foo');
|
||||
assert.ok(e instanceof thrift.TApplicationException, 'is instanceof TApplicationException');
|
||||
assert.ok(e instanceof thrift.TException, 'is instanceof TException');
|
||||
assert.ok(e instanceof Error, 'is instanceof Error');
|
||||
assert.equal(typeof e.stack, 'string', 'has stack trace');
|
||||
assert.ok(/^TApplicationException: foo/.test(e.stack), 'Stack trace has correct error name and message');
|
||||
assert.ok(e.stack.indexOf('test/exceptions.js:7:11') !== -1, 'stack trace starts on correct line and column');
|
||||
assert.equal(e.name, 'TApplicationException', 'has function name TApplicationException');
|
||||
assert.equal(e.message, 'foo', 'has error message "foo"');
|
||||
assert.equal(e.type, 1, 'has type 1');
|
||||
"use strict";
|
||||
const test = require("tape");
|
||||
const thrift = require("../lib/thrift/thrift.js");
|
||||
const InputBufferUnderrunError = require("../lib/thrift/input_buffer_underrun_error");
|
||||
|
||||
test("TApplicationException", function t(assert) {
|
||||
const e = new thrift.TApplicationException(1, "foo");
|
||||
assert.ok(
|
||||
e instanceof thrift.TApplicationException,
|
||||
"is instanceof TApplicationException"
|
||||
);
|
||||
assert.ok(e instanceof thrift.TException, "is instanceof TException");
|
||||
assert.ok(e instanceof Error, "is instanceof Error");
|
||||
assert.equal(typeof e.stack, "string", "has stack trace");
|
||||
assert.ok(
|
||||
/^TApplicationException: foo/.test(e.stack),
|
||||
"Stack trace has correct error name and message"
|
||||
);
|
||||
assert.ok(
|
||||
e.stack.indexOf("test/exceptions.js:7:11") !== -1,
|
||||
"stack trace starts on correct line and column"
|
||||
);
|
||||
assert.equal(
|
||||
e.name,
|
||||
"TApplicationException",
|
||||
"has function name TApplicationException"
|
||||
);
|
||||
assert.equal(e.message, "foo", 'has error message "foo"');
|
||||
assert.equal(e.type, 1, "has type 1");
|
||||
assert.end();
|
||||
});
|
||||
|
||||
test('TException', function t(assert) {
|
||||
var e = new thrift.TException('foo');
|
||||
assert.ok(e instanceof thrift.TException, 'is instanceof TException');
|
||||
assert.ok(e instanceof Error, 'is instanceof Error');
|
||||
assert.equal(typeof e.stack, 'string', 'has stack trace');
|
||||
assert.ok(/^TException: foo/.test(e.stack), 'Stack trace has correct error name and message');
|
||||
assert.ok(e.stack.indexOf('test/exceptions.js:21:11') !== -1, 'stack trace starts on correct line and column');
|
||||
assert.equal(e.name, 'TException', 'has function name TException');
|
||||
assert.equal(e.message, 'foo', 'has error message "foo"');
|
||||
test("unexpected TApplicationException ", function t(assert) {
|
||||
const e = new thrift.TApplicationException(1, 100);
|
||||
assert.ok(
|
||||
e instanceof thrift.TApplicationException,
|
||||
"is instanceof TApplicationException"
|
||||
);
|
||||
assert.ok(e instanceof thrift.TException, "is instanceof TException");
|
||||
assert.ok(e instanceof Error, "is instanceof Error");
|
||||
assert.equal(typeof e.stack, "string", "has stack trace");
|
||||
assert.ok(
|
||||
/^TApplicationException: 100/.test(e.stack),
|
||||
"Stack trace has correct error name and message"
|
||||
);
|
||||
assert.ok(
|
||||
e.stack.indexOf("test/exceptions.js:7:11") !== -1,
|
||||
"stack trace starts on correct line and column"
|
||||
);
|
||||
assert.equal(
|
||||
e.name,
|
||||
"TApplicationException",
|
||||
"has function name TApplicationException"
|
||||
);
|
||||
assert.equal(e.message, 100, "has error message 100");
|
||||
assert.equal(e.type, 1, "has type 1");
|
||||
assert.end();
|
||||
});
|
||||
|
||||
test('TProtocolException', function t(assert) {
|
||||
var e = new thrift.TProtocolException(1, 'foo');
|
||||
assert.ok(e instanceof thrift.TProtocolException, 'is instanceof TProtocolException');
|
||||
assert.ok(e instanceof Error, 'is instanceof Error');
|
||||
assert.equal(typeof e.stack, 'string', 'has stack trace');
|
||||
assert.ok(/^TProtocolException: foo/.test(e.stack), 'Stack trace has correct error name and message');
|
||||
assert.ok(e.stack.indexOf('test/exceptions.js:33:11') !== -1, 'stack trace starts on correct line and column');
|
||||
assert.equal(e.name, 'TProtocolException', 'has function name TProtocolException');
|
||||
assert.equal(e.message, 'foo', 'has error message "foo"');
|
||||
assert.equal(e.type, 1, 'has type 1');
|
||||
test("TException", function t(assert) {
|
||||
const e = new thrift.TException("foo");
|
||||
assert.ok(e instanceof thrift.TException, "is instanceof TException");
|
||||
assert.ok(e instanceof Error, "is instanceof Error");
|
||||
assert.equal(typeof e.stack, "string", "has stack trace");
|
||||
assert.ok(
|
||||
/^TException: foo/.test(e.stack),
|
||||
"Stack trace has correct error name and message"
|
||||
);
|
||||
assert.ok(
|
||||
e.stack.indexOf("test/exceptions.js:21:11") !== -1,
|
||||
"stack trace starts on correct line and column"
|
||||
);
|
||||
assert.equal(e.name, "TException", "has function name TException");
|
||||
assert.equal(e.message, "foo", 'has error message "foo"');
|
||||
assert.end();
|
||||
});
|
||||
|
||||
test('InputBufferUnderrunError', function t(assert) {
|
||||
var e = new InputBufferUnderrunError('foo');
|
||||
assert.ok(e instanceof InputBufferUnderrunError, 'is instanceof InputBufferUnderrunError');
|
||||
assert.ok(e instanceof Error, 'is instanceof Error');
|
||||
assert.equal(typeof e.stack, 'string', 'has stack trace');
|
||||
assert.ok(/^InputBufferUnderrunError: foo/.test(e.stack), 'Stack trace has correct error name and message');
|
||||
assert.ok(e.stack.indexOf('test/exceptions.js:46:11') !== -1, 'stack trace starts on correct line and column');
|
||||
assert.equal(e.name, 'InputBufferUnderrunError', 'has function name InputBufferUnderrunError');
|
||||
assert.equal(e.message, 'foo', 'has error message "foo"');
|
||||
test("TProtocolException", function t(assert) {
|
||||
const e = new thrift.TProtocolException(1, "foo");
|
||||
assert.ok(
|
||||
e instanceof thrift.TProtocolException,
|
||||
"is instanceof TProtocolException"
|
||||
);
|
||||
assert.ok(e instanceof Error, "is instanceof Error");
|
||||
assert.equal(typeof e.stack, "string", "has stack trace");
|
||||
assert.ok(
|
||||
/^TProtocolException: foo/.test(e.stack),
|
||||
"Stack trace has correct error name and message"
|
||||
);
|
||||
assert.ok(
|
||||
e.stack.indexOf("test/exceptions.js:33:11") !== -1,
|
||||
"stack trace starts on correct line and column"
|
||||
);
|
||||
assert.equal(
|
||||
e.name,
|
||||
"TProtocolException",
|
||||
"has function name TProtocolException"
|
||||
);
|
||||
assert.equal(e.message, "foo", 'has error message "foo"');
|
||||
assert.equal(e.type, 1, "has type 1");
|
||||
assert.end();
|
||||
});
|
||||
|
||||
test("InputBufferUnderrunError", function t(assert) {
|
||||
const e = new InputBufferUnderrunError("foo");
|
||||
assert.ok(
|
||||
e instanceof InputBufferUnderrunError,
|
||||
"is instanceof InputBufferUnderrunError"
|
||||
);
|
||||
assert.ok(e instanceof Error, "is instanceof Error");
|
||||
assert.equal(typeof e.stack, "string", "has stack trace");
|
||||
assert.ok(
|
||||
/^InputBufferUnderrunError: foo/.test(e.stack),
|
||||
"Stack trace has correct error name and message"
|
||||
);
|
||||
assert.ok(
|
||||
e.stack.indexOf("test/exceptions.js:46:11") !== -1,
|
||||
"stack trace starts on correct line and column"
|
||||
);
|
||||
assert.equal(
|
||||
e.name,
|
||||
"InputBufferUnderrunError",
|
||||
"has function name InputBufferUnderrunError"
|
||||
);
|
||||
assert.equal(e.message, "foo", 'has error message "foo"');
|
||||
assert.end();
|
||||
});
|
||||
|
|
38
vendor/git.apache.org/thrift.git/lib/nodejs/test/helpers.js
generated
vendored
38
vendor/git.apache.org/thrift.git/lib/nodejs/test/helpers.js
generated
vendored
|
@ -1,13 +1,37 @@
|
|||
'use strict';
|
||||
var thrift = require('../lib/thrift');
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
const thrift = require("../lib/thrift");
|
||||
|
||||
module.exports.transports = {
|
||||
'buffered': thrift.TBufferedTransport,
|
||||
'framed': thrift.TFramedTransport
|
||||
buffered: thrift.TBufferedTransport,
|
||||
framed: thrift.TFramedTransport
|
||||
};
|
||||
|
||||
module.exports.protocols = {
|
||||
'json': thrift.TJSONProtocol,
|
||||
'binary': thrift.TBinaryProtocol,
|
||||
'compact': thrift.TCompactProtocol
|
||||
json: thrift.TJSONProtocol,
|
||||
binary: thrift.TBinaryProtocol,
|
||||
compact: thrift.TCompactProtocol
|
||||
};
|
||||
|
||||
module.exports.ecmaMode = process.argv.includes("--es6") ? "es6" : "es5";
|
||||
module.exports.genPath = process.argv.includes("--es6")
|
||||
? "gen-nodejs-es6"
|
||||
: "gen-nodejs";
|
||||
|
|
130
vendor/git.apache.org/thrift.git/lib/nodejs/test/server.js
generated
vendored
130
vendor/git.apache.org/thrift.git/lib/nodejs/test/server.js
generated
vendored
|
@ -19,83 +19,119 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
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');
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const thrift = require("../lib/thrift");
|
||||
const program = require("commander");
|
||||
const helpers = require("./helpers");
|
||||
|
||||
program
|
||||
.option('-p, --protocol <protocol>', 'Set thrift protocol (binary|json|compact)', 'binary')
|
||||
.option('-t, --transport <transport>', 'Set thrift transport (buffered|framed)', 'buffered')
|
||||
.option('--ssl', 'use ssl transport')
|
||||
.option('--port <port>', 'Set thrift server port', 9090)
|
||||
.option('--promise', 'test with promise style functions')
|
||||
.option('-t, --type <type>', 'Select server type (tcp|multiplex|http)', 'tcp')
|
||||
.option(
|
||||
"-p, --protocol <protocol>",
|
||||
"Set thrift protocol (binary|compact|json)",
|
||||
"binary"
|
||||
)
|
||||
.option(
|
||||
"-t, --transport <transport>",
|
||||
"Set thrift transport (buffered|framed|http)",
|
||||
"buffered"
|
||||
)
|
||||
.option("--ssl", "use ssl transport")
|
||||
.option("--port <port>", "Set thrift server port", 9090)
|
||||
.option("--domain-socket <path>", "Set thift server unix domain socket")
|
||||
.option(
|
||||
"-t, --type <type>",
|
||||
"Select server type (http|multiplex|tcp|websocket)",
|
||||
"tcp"
|
||||
)
|
||||
.option("--callback", "test with callback style functions")
|
||||
.option("--es6", "Use es6 code")
|
||||
.option("--es5", "Use es5 code")
|
||||
.parse(process.argv);
|
||||
|
||||
var port = program.port;
|
||||
var type = program.type;
|
||||
var ssl = program.ssl;
|
||||
var promise = program.promise;
|
||||
const ThriftTest = require(`./${helpers.genPath}/ThriftTest`);
|
||||
const SecondService = require(`./${helpers.genPath}/SecondService`);
|
||||
const { ThriftTestHandler } = require("./test_handler");
|
||||
|
||||
var handler = program.promise ? ThriftTestHandler : ThriftTestHandlerPromise;
|
||||
const port = program.port;
|
||||
const domainSocket = program.domainSocket;
|
||||
const ssl = program.ssl;
|
||||
|
||||
var options = {
|
||||
let type = program.type;
|
||||
if (program.transport === "http") {
|
||||
program.transport = "buffered";
|
||||
type = "http";
|
||||
}
|
||||
|
||||
let options = {
|
||||
transport: helpers.transports[program.transport],
|
||||
protocol: helpers.protocols[program.protocol]
|
||||
};
|
||||
|
||||
if (type === 'http' || type ==='websocket') {
|
||||
options.handler = handler;
|
||||
if (type === "http" || type === "websocket") {
|
||||
options.handler = ThriftTestHandler;
|
||||
options.processor = ThriftTest;
|
||||
|
||||
options = {
|
||||
services: { "/test": options },
|
||||
cors: {
|
||||
'*': true
|
||||
"*": true
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (type === 'multiplex') {
|
||||
var SecondServiceHandler = {
|
||||
let processor;
|
||||
if (type === "multiplex") {
|
||||
const SecondServiceHandler = {
|
||||
secondtestString: function(thing, result) {
|
||||
console.log('testString(\'' + thing + '\')');
|
||||
result(null, thing);
|
||||
console.log('testString("' + thing + '")');
|
||||
result(null, 'testString("' + thing + '")');
|
||||
}
|
||||
};
|
||||
|
||||
var processor = new thrift.MultiplexedProcessor();
|
||||
processor = new thrift.MultiplexedProcessor();
|
||||
|
||||
processor.registerProcessor("ThriftTest",
|
||||
new ThriftTest.Processor(ThriftTestHandler));
|
||||
|
||||
processor.registerProcessor("SecondService",
|
||||
new SecondService.Processor(SecondServiceHandler));
|
||||
processor.registerProcessor(
|
||||
"ThriftTest",
|
||||
new ThriftTest.Processor(ThriftTestHandler)
|
||||
);
|
||||
|
||||
processor.registerProcessor(
|
||||
"SecondService",
|
||||
new SecondService.Processor(SecondServiceHandler)
|
||||
);
|
||||
}
|
||||
|
||||
if (ssl) {
|
||||
options.tls = {
|
||||
key: fs.readFileSync(path.resolve(__dirname, 'server.key')),
|
||||
cert: fs.readFileSync(path.resolve(__dirname, 'server.crt'))
|
||||
};
|
||||
if (
|
||||
type === "tcp" ||
|
||||
type === "multiplex" ||
|
||||
type === "http" ||
|
||||
type === "websocket"
|
||||
) {
|
||||
options.tls = {
|
||||
key: fs.readFileSync(path.resolve(__dirname, "server.key")),
|
||||
cert: fs.readFileSync(path.resolve(__dirname, "server.crt"))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var server;
|
||||
if (type === 'tcp') {
|
||||
server = thrift.createServer(ThriftTest, handler, options);
|
||||
} else if (type === 'multiplex') {
|
||||
let server;
|
||||
if (type === "tcp") {
|
||||
server = thrift.createServer(ThriftTest, ThriftTestHandler, options);
|
||||
} else if (type === "multiplex") {
|
||||
server = thrift.createMultiplexServer(processor, options);
|
||||
} else if (type === 'http' || type === 'websocket') {
|
||||
} else if (type === "http" || type === "websocket") {
|
||||
server = thrift.createWebServer(options);
|
||||
}
|
||||
|
||||
server.listen(port);
|
||||
if (domainSocket) {
|
||||
server.listen(domainSocket);
|
||||
} else if (
|
||||
type === "tcp" ||
|
||||
type === "multiplex" ||
|
||||
type === "http" ||
|
||||
type === "websocket"
|
||||
) {
|
||||
server.listen(port);
|
||||
}
|
||||
|
|
246
vendor/git.apache.org/thrift.git/lib/nodejs/test/test-cases.js
generated
vendored
246
vendor/git.apache.org/thrift.git/lib/nodejs/test/test-cases.js
generated
vendored
|
@ -1,136 +1,172 @@
|
|||
'use strict';
|
||||
/*
|
||||
* 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 ttypes = require('./gen-nodejs/ThriftTest_types');
|
||||
var Int64 = require('node-int64');
|
||||
"use strict";
|
||||
|
||||
const helpers = require("./helpers");
|
||||
const ttypes = require(`./${helpers.genPath}/ThriftTest_types`);
|
||||
const Int64 = require("node-int64");
|
||||
|
||||
//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ú, 粵語";
|
||||
const 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: ]] \"]] \\" }}}{ [[[ ';
|
||||
const 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"
|
||||
};
|
||||
const 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],
|
||||
['testBool', true],
|
||||
['testBool', false],
|
||||
['testByte', 1],
|
||||
['testByte', 0],
|
||||
['testByte', -1],
|
||||
['testByte', -127],
|
||||
['testI32', -1],
|
||||
['testDouble', -5.2098523],
|
||||
['testDouble', 7.012052175215044],
|
||||
['testEnum', ttypes.Numberz.ONE],
|
||||
['testI64', 5],
|
||||
['testI64', -5],
|
||||
['testI64', 734359738368],
|
||||
['testI64', -734359738368],
|
||||
['testI64', new Int64(new Buffer([0, 0x20, 0, 0, 0, 0, 0, 1]))], // 2^53+1
|
||||
['testI64', new Int64(
|
||||
new Buffer([0xff, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))], // -2^53-1
|
||||
['testTypedef', 69]
|
||||
]
|
||||
const simple = [
|
||||
["testVoid", undefined],
|
||||
["testString", "Test"],
|
||||
["testString", ""],
|
||||
["testString", stringTest],
|
||||
["testString", specialCharacters],
|
||||
["testBool", true],
|
||||
["testBool", false],
|
||||
["testByte", 1],
|
||||
["testByte", 0],
|
||||
["testByte", -1],
|
||||
["testByte", -127],
|
||||
["testI32", -1],
|
||||
["testDouble", -5.2098523],
|
||||
["testDouble", 7.012052175215044],
|
||||
["testEnum", ttypes.Numberz.ONE],
|
||||
["testI64", 5],
|
||||
["testI64", -5],
|
||||
["testI64", 734359738368],
|
||||
["testI64", -734359738368],
|
||||
["testI64", new Int64(new Buffer([0, 0x20, 0, 0, 0, 0, 0, 1]))], // 2^53+1
|
||||
[
|
||||
"testI64",
|
||||
new Int64(new Buffer([0xff, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
|
||||
], // -2^53-1
|
||||
["testTypedef", 69]
|
||||
];
|
||||
|
||||
var mapout = {};
|
||||
for (var i = 0; i < 5; ++i) {
|
||||
mapout[i] = i-10;
|
||||
const mapout = {};
|
||||
for (let i = 0; i < 5; ++i) {
|
||||
mapout[i] = i - 10;
|
||||
}
|
||||
|
||||
var deep = [
|
||||
['testList', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]],
|
||||
const deep = [
|
||||
[
|
||||
"testList",
|
||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
|
||||
]
|
||||
];
|
||||
|
||||
var deepUnordered = [
|
||||
['testMap', mapout],
|
||||
['testSet', [1,2,3]],
|
||||
['testStringMap', mapTestInput]
|
||||
const deepUnordered = [
|
||||
["testMap", mapout],
|
||||
["testSet", [1, 2, 3]],
|
||||
["testStringMap", mapTestInput]
|
||||
];
|
||||
|
||||
var out = new ttypes.Xtruct({
|
||||
string_thing: 'Zero',
|
||||
const out = new ttypes.Xtruct({
|
||||
string_thing: "Zero",
|
||||
byte_thing: 1,
|
||||
i32_thing: -3,
|
||||
i64_thing: 1000000
|
||||
});
|
||||
|
||||
var out2 = new ttypes.Xtruct2();
|
||||
const 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
|
||||
})]
|
||||
const 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 crazy2 = new ttypes.Insanity({
|
||||
"userMap":{ "5":5, "8":8 },
|
||||
"xtructs":[{
|
||||
"string_thing":"Goodbye4",
|
||||
"byte_thing":4,
|
||||
"i32_thing":4,
|
||||
"i64_thing":4
|
||||
}, {
|
||||
"string_thing":"Hello2",
|
||||
"byte_thing":2,
|
||||
"i32_thing":2,
|
||||
"i64_thing":2
|
||||
}]
|
||||
const crazy2 = new ttypes.Insanity({
|
||||
userMap: { "5": 5, "8": 8 },
|
||||
xtructs: [
|
||||
{
|
||||
string_thing: "Goodbye4",
|
||||
byte_thing: 4,
|
||||
i32_thing: 4,
|
||||
i64_thing: 4
|
||||
},
|
||||
{
|
||||
string_thing: "Hello2",
|
||||
byte_thing: 2,
|
||||
i32_thing: 2,
|
||||
i64_thing: 2
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
var insanity = {
|
||||
"1":{ "2": crazy, "3": crazy },
|
||||
"2":{ "6":{ "userMap":{}, "xtructs":[] } }
|
||||
const insanity = {
|
||||
"1": { "2": crazy, "3": crazy },
|
||||
"2": { "6": { userMap: {}, xtructs: [] } }
|
||||
};
|
||||
|
||||
module.exports.simple = simple;
|
||||
|
|
41
vendor/git.apache.org/thrift.git/lib/nodejs/test/testAll.sh
generated
vendored
41
vendor/git.apache.org/thrift.git/lib/nodejs/test/testAll.sh
generated
vendored
|
@ -24,7 +24,6 @@ fi
|
|||
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
|
||||
ISTANBUL="$DIR/../../../node_modules/istanbul/lib/cli.js"
|
||||
RUNBROWSER="$DIR/../../../node_modules/run-browser/bin/cli.js"
|
||||
|
||||
REPORT_PREFIX="${DIR}/../coverage/report"
|
||||
|
||||
|
@ -34,37 +33,27 @@ export NODE_PATH="${DIR}:${DIR}/../lib:${NODE_PATH}"
|
|||
|
||||
testServer()
|
||||
{
|
||||
echo " Testing $1 Client/Server with protocol $2 and transport $3 $4";
|
||||
echo " [ECMA $1] Testing $2 Client/Server with protocol $3 and transport $4 $5";
|
||||
RET=0
|
||||
if [ -n "${COVER}" ]; then
|
||||
${ISTANBUL} cover ${DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- --type $1 -p $2 -t $3 $4 &
|
||||
${ISTANBUL} cover ${DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- --type $2 -p $3 -t $4 $5 &
|
||||
COUNT=$((COUNT+1))
|
||||
else
|
||||
node ${DIR}/server.js --type $1 -p $2 -t $3 $4 &
|
||||
node ${DIR}/server.js --${1} --type $2 -p $3 -t $4 $5 &
|
||||
fi
|
||||
SERVERPID=$!
|
||||
sleep 1
|
||||
sleep 0.1
|
||||
if [ -n "${COVER}" ]; then
|
||||
${ISTANBUL} cover ${DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} -- --type $1 -p $2 -t $3 $4 || RET=1
|
||||
${ISTANBUL} cover ${DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} -- --${1} --type $2 -p $3 -t $4 $5 || RET=1
|
||||
COUNT=$((COUNT+1))
|
||||
else
|
||||
node ${DIR}/client.js --type $1 -p $2 -t $3 $4 || RET=1
|
||||
node ${DIR}/client.js --${1} --type $2 -p $3 -t $4 $5 || RET=1
|
||||
fi
|
||||
kill -2 $SERVERPID || RET=1
|
||||
wait $SERVERPID
|
||||
return $RET
|
||||
}
|
||||
|
||||
testBrowser()
|
||||
{
|
||||
echo " Testing browser client with http server with json protocol and buffered transport";
|
||||
RET=0
|
||||
node ${DIR}/server.js --type http -p json -t buffered &
|
||||
SERVERPID=$!
|
||||
sleep 1
|
||||
${RUNBROWSER} ${DIR}/browser_client.js --phantom || RET=1
|
||||
kill -2 $SERVERPID || RET=1
|
||||
return $RET
|
||||
}
|
||||
|
||||
TESTOK=0
|
||||
|
||||
|
@ -72,6 +61,9 @@ TESTOK=0
|
|||
|
||||
${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/ThriftTest.thrift
|
||||
${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/JsDeepConstructorTest.thrift
|
||||
mkdir ${DIR}/gen-nodejs-es6
|
||||
${DIR}/../../../compiler/cpp/thrift -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${DIR}/../../../test/ThriftTest.thrift
|
||||
${DIR}/../../../compiler/cpp/thrift -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${DIR}/../../../test/JsDeepConstructorTest.thrift
|
||||
|
||||
#unit tests
|
||||
|
||||
|
@ -82,21 +74,20 @@ node ${DIR}/deep-constructor.test.js || TESTOK=1
|
|||
|
||||
for type in tcp multiplex websocket http
|
||||
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
|
||||
for ecma_version in es5 es6
|
||||
do
|
||||
testServer $ecma_version $type $protocol $transport || TESTOK=1
|
||||
testServer $ecma_version $type $protocol $transport --ssl || TESTOK=1
|
||||
testServer $ecma_version $type $protocol $transport --callback || TESTOK=1
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
# XHR only until phantomjs 2 is released.
|
||||
testBrowser
|
||||
|
||||
if [ -n "${COVER}" ]; then
|
||||
${ISTANBUL} report --dir "${DIR}/../coverage" --include "${DIR}/../coverage/report*/coverage.json" lcov cobertura html
|
||||
|
|
408
vendor/git.apache.org/thrift.git/lib/nodejs/test/test_driver.js
generated
vendored
408
vendor/git.apache.org/thrift.git/lib/nodejs/test/test_driver.js
generated
vendored
|
@ -17,247 +17,279 @@
|
|||
* 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.
|
||||
// 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 test = require('tape');
|
||||
//var assert = require('assert');
|
||||
var ttypes = require('./gen-nodejs/ThriftTest_types');
|
||||
var TException = require('thrift').Thrift.TException;
|
||||
var Int64 = require('node-int64');
|
||||
var testCases = require('./test-cases');
|
||||
const test = require("tape");
|
||||
|
||||
const helpers = require("./helpers");
|
||||
const ttypes = require(`./${helpers.genPath}/ThriftTest_types`);
|
||||
const TException = require("thrift").Thrift.TException;
|
||||
const Int64 = require("node-int64");
|
||||
const testCases = require("./test-cases");
|
||||
|
||||
exports.ThriftTestDriver = function(client, callback) {
|
||||
test(
|
||||
"NodeJS Style Callback Client Tests",
|
||||
{ skip: helpers.ecmaMode === "es6" },
|
||||
function(assert) {
|
||||
const checkRecursively = makeRecursiveCheck(assert);
|
||||
|
||||
test('NodeJS Style Callback Client Tests', function(assert) {
|
||||
|
||||
var checkRecursively = makeRecursiveCheck(assert);
|
||||
|
||||
function makeAsserter(assertionFn) {
|
||||
return function(c) {
|
||||
var fnName = c[0];
|
||||
var expected = c[1];
|
||||
client[fnName](expected, function(err, actual) {
|
||||
assert.error(err, fnName + ': no callback error');
|
||||
assertionFn(actual, expected, fnName);
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
testCases.simple.forEach(makeAsserter(function(a, e, m){
|
||||
if (a instanceof Int64) {
|
||||
var e64 = e instanceof Int64 ? e : new Int64(e);
|
||||
assert.deepEqual(a.buffer, e64.buffer, m);
|
||||
} else {
|
||||
assert.equal(a, e, m);
|
||||
function makeAsserter(assertionFn) {
|
||||
return function(c) {
|
||||
const fnName = c[0];
|
||||
const expected = c[1];
|
||||
client[fnName](expected, function(err, actual) {
|
||||
assert.error(err, fnName + ": no callback error");
|
||||
assertionFn(actual, expected, fnName);
|
||||
});
|
||||
};
|
||||
}
|
||||
}));
|
||||
testCases.deep.forEach(makeAsserter(assert.deepEqual));
|
||||
testCases.deepUnordered.forEach(makeAsserter(makeUnorderedDeepEqual(assert)));
|
||||
|
||||
var arr = [];
|
||||
for (var i = 0; i < 256; ++i) {
|
||||
arr[i] = 255 - i;
|
||||
}
|
||||
var buf = new Buffer(arr);
|
||||
client.testBinary(buf, function(err, response) {
|
||||
assert.error(err, 'testBinary: no callback error');
|
||||
assert.equal(response.length, 256, 'testBinary');
|
||||
assert.deepEqual(response, buf, 'testBinary(Buffer)');
|
||||
});
|
||||
var buf = new Buffer(arr);
|
||||
client.testBinary(buf.toString('binary'), function(err, response) {
|
||||
assert.error(err, 'testBinary: no callback error');
|
||||
assert.equal(response.length, 256, 'testBinary');
|
||||
assert.deepEqual(response, buf, 'testBinary(string)');
|
||||
});
|
||||
testCases.simple.forEach(
|
||||
makeAsserter(function(a, e, m) {
|
||||
if (a instanceof Int64) {
|
||||
const e64 = e instanceof Int64 ? e : new Int64(e);
|
||||
assert.deepEqual(a.buffer, e64.buffer, m);
|
||||
} else {
|
||||
assert.equal(a, e, m);
|
||||
}
|
||||
})
|
||||
);
|
||||
testCases.deep.forEach(makeAsserter(assert.deepEqual));
|
||||
testCases.deepUnordered.forEach(
|
||||
makeAsserter(makeUnorderedDeepEqual(assert))
|
||||
);
|
||||
|
||||
client.testMapMap(42, function(err, response) {
|
||||
var expected = {
|
||||
"4": {"1":1, "2":2, "3":3, "4":4},
|
||||
"-4": {"-4":-4, "-3":-3, "-2":-2, "-1":-1}
|
||||
};
|
||||
assert.error(err, 'testMapMap: no callback error');
|
||||
assert.deepEqual(expected, response, 'testMapMap');
|
||||
});
|
||||
|
||||
client.testStruct(testCases.out, function(err, response) {
|
||||
assert.error(err, 'testStruct: no callback error');
|
||||
checkRecursively(testCases.out, response, 'testStruct');
|
||||
});
|
||||
|
||||
client.testNest(testCases.out2, function(err, response) {
|
||||
assert.error(err, 'testNest: no callback error');
|
||||
checkRecursively(testCases.out2, response, 'testNest');
|
||||
});
|
||||
|
||||
client.testInsanity(testCases.crazy, function(err, response) {
|
||||
assert.error(err, 'testInsanity: no callback error');
|
||||
checkRecursively(testCases.insanity, response, 'testInsanity');
|
||||
});
|
||||
|
||||
client.testInsanity(testCases.crazy2, function(err, response) {
|
||||
assert.error(err, 'testInsanity2: no callback error');
|
||||
checkRecursively(testCases.insanity, response, 'testInsanity2');
|
||||
});
|
||||
|
||||
client.testException('TException', function(err, response) {
|
||||
assert.ok(err instanceof TException, 'testException: correct error type');
|
||||
assert.ok(!response, 'testException: no response');
|
||||
});
|
||||
|
||||
client.testException('Xception', function(err, response) {
|
||||
assert.ok(err instanceof ttypes.Xception, 'testException: correct error type');
|
||||
assert.ok(!response, 'testException: no response');
|
||||
assert.equal(err.errorCode, 1001, 'testException: correct error code');
|
||||
assert.equal('Xception', err.message, 'testException: correct error message');
|
||||
});
|
||||
|
||||
client.testException('no Exception', function(err, response) {
|
||||
assert.error(err, 'testException: no callback error');
|
||||
assert.ok(!response, 'testException: no response');
|
||||
});
|
||||
|
||||
client.testOneway(0, function(err, response) {
|
||||
assert.fail('testOneway should not answer');
|
||||
});
|
||||
|
||||
checkOffByOne(function(done) {
|
||||
client.testI32(-1, function(err, response) {
|
||||
assert.error(err, 'checkOffByOne: no callback error');
|
||||
assert.equal(-1, response);
|
||||
assert.end();
|
||||
done();
|
||||
const arr = [];
|
||||
for (let i = 0; i < 256; ++i) {
|
||||
arr[i] = 255 - i;
|
||||
}
|
||||
let buf = new Buffer(arr);
|
||||
client.testBinary(buf, function(err, response) {
|
||||
assert.error(err, "testBinary: no callback error");
|
||||
assert.equal(response.length, 256, "testBinary");
|
||||
assert.deepEqual(response, buf, "testBinary(Buffer)");
|
||||
});
|
||||
buf = new Buffer(arr);
|
||||
client.testBinary(buf.toString("binary"), function(err, response) {
|
||||
assert.error(err, "testBinary: no callback error");
|
||||
assert.equal(response.length, 256, "testBinary");
|
||||
assert.deepEqual(response, buf, "testBinary(string)");
|
||||
});
|
||||
}, callback);
|
||||
|
||||
});
|
||||
client.testMapMap(42, function(err, response) {
|
||||
const expected = {
|
||||
"4": { "1": 1, "2": 2, "3": 3, "4": 4 },
|
||||
"-4": { "-4": -4, "-3": -3, "-2": -2, "-1": -1 }
|
||||
};
|
||||
assert.error(err, "testMapMap: no callback error");
|
||||
assert.deepEqual(expected, response, "testMapMap");
|
||||
});
|
||||
|
||||
client.testStruct(testCases.out, function(err, response) {
|
||||
assert.error(err, "testStruct: no callback error");
|
||||
checkRecursively(testCases.out, response, "testStruct");
|
||||
});
|
||||
|
||||
client.testNest(testCases.out2, function(err, response) {
|
||||
assert.error(err, "testNest: no callback error");
|
||||
checkRecursively(testCases.out2, response, "testNest");
|
||||
});
|
||||
|
||||
client.testInsanity(testCases.crazy, function(err, response) {
|
||||
assert.error(err, "testInsanity: no callback error");
|
||||
checkRecursively(testCases.insanity, response, "testInsanity");
|
||||
});
|
||||
|
||||
client.testInsanity(testCases.crazy2, function(err, response) {
|
||||
assert.error(err, "testInsanity2: no callback error");
|
||||
checkRecursively(testCases.insanity, response, "testInsanity2");
|
||||
});
|
||||
|
||||
client.testException("TException", function(err, response) {
|
||||
assert.ok(
|
||||
err instanceof TException,
|
||||
"testException: correct error type"
|
||||
);
|
||||
assert.ok(!response, "testException: no response");
|
||||
});
|
||||
|
||||
client.testException("Xception", function(err, response) {
|
||||
assert.ok(
|
||||
err instanceof ttypes.Xception,
|
||||
"testException: correct error type"
|
||||
);
|
||||
assert.ok(!response, "testException: no response");
|
||||
assert.equal(err.errorCode, 1001, "testException: correct error code");
|
||||
assert.equal(
|
||||
"Xception",
|
||||
err.message,
|
||||
"testException: correct error message"
|
||||
);
|
||||
});
|
||||
|
||||
client.testException("no Exception", function(err, response) {
|
||||
assert.error(err, "testException: no callback error");
|
||||
assert.ok(!response, "testException: no response");
|
||||
});
|
||||
|
||||
client.testOneway(0, function(err, response) {
|
||||
assert.error(err, "testOneway: no callback error");
|
||||
assert.strictEqual(response, undefined, "testOneway: void response");
|
||||
});
|
||||
|
||||
checkOffByOne(function(done) {
|
||||
client.testI32(-1, function(err, response) {
|
||||
assert.error(err, "checkOffByOne: no callback error");
|
||||
assert.equal(-1, response);
|
||||
assert.end();
|
||||
done();
|
||||
});
|
||||
}, callback);
|
||||
}
|
||||
);
|
||||
|
||||
// ES6 does not support callback style
|
||||
if (helpers.ecmaMode === "es6") {
|
||||
checkOffByOne(done => done(), callback);
|
||||
}
|
||||
};
|
||||
|
||||
exports.ThriftTestDriverPromise = function(client, callback) {
|
||||
|
||||
test('Q Promise Client Tests', function(assert) {
|
||||
|
||||
var checkRecursively = makeRecursiveCheck(assert);
|
||||
|
||||
function fail(msg) {
|
||||
return function() {
|
||||
assert.fail(msg);
|
||||
}
|
||||
}
|
||||
test("Promise Client Tests", function(assert) {
|
||||
const checkRecursively = makeRecursiveCheck(assert);
|
||||
|
||||
function makeAsserter(assertionFn) {
|
||||
return function(c) {
|
||||
var fnName = c[0];
|
||||
var expected = c[1];
|
||||
const fnName = c[0];
|
||||
const expected = c[1];
|
||||
client[fnName](expected)
|
||||
.then(function(actual) {
|
||||
assertionFn(actual, expected, fnName);
|
||||
})
|
||||
.fail(fail('fnName'));
|
||||
.catch(() => assert.fail("fnName"));
|
||||
};
|
||||
}
|
||||
|
||||
testCases.simple.forEach(makeAsserter(function(a, e, m){
|
||||
if (a instanceof Int64) {
|
||||
var e64 = e instanceof Int64 ? e : new Int64(e);
|
||||
assert.deepEqual(a.buffer, e64.buffer, m);
|
||||
} else {
|
||||
assert.equal(a, e, m);
|
||||
}
|
||||
}));
|
||||
testCases.simple.forEach(
|
||||
makeAsserter(function(a, e, m) {
|
||||
if (a instanceof Int64) {
|
||||
const e64 = e instanceof Int64 ? e : new Int64(e);
|
||||
assert.deepEqual(a.buffer, e64.buffer, m);
|
||||
} else {
|
||||
assert.equal(a, e, m);
|
||||
}
|
||||
})
|
||||
);
|
||||
testCases.deep.forEach(makeAsserter(assert.deepEqual));
|
||||
testCases.deepUnordered.forEach(makeAsserter(makeUnorderedDeepEqual(assert)));
|
||||
testCases.deepUnordered.forEach(
|
||||
makeAsserter(makeUnorderedDeepEqual(assert))
|
||||
);
|
||||
|
||||
client.testStruct(testCases.out)
|
||||
client
|
||||
.testStruct(testCases.out)
|
||||
.then(function(response) {
|
||||
checkRecursively(testCases.out, response, 'testStruct');
|
||||
checkRecursively(testCases.out, response, "testStruct");
|
||||
})
|
||||
.fail(fail('testStruct'));
|
||||
.catch(() => assert.fail("testStruct"));
|
||||
|
||||
client.testNest(testCases.out2)
|
||||
client
|
||||
.testNest(testCases.out2)
|
||||
.then(function(response) {
|
||||
checkRecursively(testCases.out2, response, 'testNest');
|
||||
checkRecursively(testCases.out2, response, "testNest");
|
||||
})
|
||||
.fail(fail('testNest'));
|
||||
.catch(() => assert.fail("testNest"));
|
||||
|
||||
client.testInsanity(testCases.crazy)
|
||||
client
|
||||
.testInsanity(testCases.crazy)
|
||||
.then(function(response) {
|
||||
checkRecursively(testCases.insanity, response, 'testInsanity');
|
||||
checkRecursively(testCases.insanity, response, "testInsanity");
|
||||
})
|
||||
.fail(fail('testInsanity'));
|
||||
.catch(() => assert.fail("testInsanity"));
|
||||
|
||||
client.testInsanity(testCases.crazy2)
|
||||
client
|
||||
.testInsanity(testCases.crazy2)
|
||||
.then(function(response) {
|
||||
checkRecursively(testCases.insanity, response, 'testInsanity2');
|
||||
checkRecursively(testCases.insanity, response, "testInsanity2");
|
||||
})
|
||||
.fail(fail('testInsanity2'));
|
||||
.catch(() => assert.fail("testInsanity2"));
|
||||
|
||||
client.testException('TException')
|
||||
.then(function(response) {
|
||||
fail('testException: TException');
|
||||
client
|
||||
.testException("TException")
|
||||
.then(function() {
|
||||
assert.fail("testException: TException");
|
||||
})
|
||||
.fail(function(err) {
|
||||
.catch(function(err) {
|
||||
assert.ok(err instanceof TException);
|
||||
});
|
||||
|
||||
client.testException('Xception')
|
||||
.then(function(response) {
|
||||
fail('testException: Xception');
|
||||
client
|
||||
.testException("Xception")
|
||||
.then(function() {
|
||||
assert.fail("testException: Xception");
|
||||
})
|
||||
.fail(function(err) {
|
||||
.catch(function(err) {
|
||||
assert.ok(err instanceof ttypes.Xception);
|
||||
assert.equal(err.errorCode, 1001);
|
||||
assert.equal('Xception', err.message);
|
||||
assert.equal("Xception", err.message);
|
||||
});
|
||||
|
||||
client.testException('no Exception')
|
||||
client
|
||||
.testException("no Exception")
|
||||
.then(function(response) {
|
||||
assert.equal(undefined, response); //void
|
||||
})
|
||||
.fail(fail('testException'));
|
||||
.catch(() => assert.fail("testException"));
|
||||
|
||||
client.testOneway(0, fail('testOneway: should not answer'));
|
||||
client
|
||||
.testOneway(0)
|
||||
.then(function(response) {
|
||||
assert.strictEqual(response, undefined, "testOneway: void response");
|
||||
})
|
||||
.catch(() => assert.fail("testOneway: should not reject"));
|
||||
|
||||
checkOffByOne(function(done) {
|
||||
client.testI32(-1)
|
||||
client
|
||||
.testI32(-1)
|
||||
.then(function(response) {
|
||||
assert.equal(-1, response);
|
||||
assert.end();
|
||||
done();
|
||||
assert.equal(-1, response);
|
||||
assert.end();
|
||||
done();
|
||||
})
|
||||
.fail(fail('checkOffByOne'));
|
||||
.catch(() => assert.fail("checkOffByOne"));
|
||||
}, callback);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// Helper Functions
|
||||
// =========================================================
|
||||
|
||||
function makeRecursiveCheck(assert) {
|
||||
|
||||
return function (map1, map2, msg) {
|
||||
var equal = true;
|
||||
|
||||
var equal = checkRecursively(map1, map2);
|
||||
return function(map1, map2, msg) {
|
||||
const equal = checkRecursively(map1, map2);
|
||||
|
||||
assert.ok(equal, msg);
|
||||
|
||||
// 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') {
|
||||
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);
|
||||
if (
|
||||
typeof map1 === "number" &&
|
||||
typeof map2 === "object" &&
|
||||
map2.buffer &&
|
||||
map2.buffer instanceof Buffer &&
|
||||
map2.buffer.length === 8
|
||||
) {
|
||||
const n = new Int64(map2.buffer);
|
||||
return map1 === n.toNumber();
|
||||
} else {
|
||||
return map1 == map2;
|
||||
|
@ -269,15 +301,14 @@ function makeRecursiveCheck(assert) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function checkOffByOne(done, callback) {
|
||||
|
||||
var retry_limit = 30;
|
||||
var retry_interval = 100;
|
||||
var test_complete = false;
|
||||
var retrys = 0;
|
||||
const retry_limit = 30;
|
||||
const retry_interval = 100;
|
||||
let test_complete = false;
|
||||
let retrys = 0;
|
||||
|
||||
/**
|
||||
* redo a simple test after the oneway to make sure we aren't "off by one" --
|
||||
|
@ -294,14 +325,17 @@ function checkOffByOne(done, callback) {
|
|||
|
||||
//We wait up to retry_limit * retry_interval for the test suite to complete
|
||||
function TestForCompletion() {
|
||||
if(test_complete && callback) {
|
||||
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");
|
||||
callback(
|
||||
"Server test failed to complete after " +
|
||||
(retry_limit * retry_interval) / 1000 +
|
||||
" seconds"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -312,15 +346,15 @@ function checkOffByOne(done, callback) {
|
|||
function makeUnorderedDeepEqual(assert) {
|
||||
return function(actual, expected, name) {
|
||||
assert.equal(actual.length, expected.length, name);
|
||||
for (var k in actual) {
|
||||
var found = false;
|
||||
for (var k2 in expected) {
|
||||
for (const k in actual) {
|
||||
let found = false;
|
||||
for (const k2 in expected) {
|
||||
if (actual[k] === expected[k2]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
assert.fail('Unexpected value ' + actual[k] + ' with key ' + k);
|
||||
assert.fail("Unexpected value " + actual[k] + " with key " + k);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
129
vendor/git.apache.org/thrift.git/lib/nodejs/test/test_handler.js
generated
vendored
129
vendor/git.apache.org/thrift.git/lib/nodejs/test/test_handler.js
generated
vendored
|
@ -19,18 +19,17 @@
|
|||
|
||||
//This is the server side Node test handler for the standard
|
||||
// Apache Thrift test service.
|
||||
const helpers = require("./helpers");
|
||||
const ttypes = require(`./${helpers.genPath}/ThriftTest_types`);
|
||||
const TException = require("thrift").Thrift.TException;
|
||||
|
||||
var ttypes = require('./gen-nodejs/ThriftTest_types');
|
||||
var TException = require('thrift').Thrift.TException;
|
||||
|
||||
function makeSyncHandler(label) {
|
||||
function makeSyncHandler() {
|
||||
return function(thing) {
|
||||
//console.log(label + '(\'' + thing + '\')');
|
||||
return thing;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var syncHandlers = {
|
||||
const syncHandlers = {
|
||||
testVoid: testVoid,
|
||||
testMapMap: testMapMap,
|
||||
testInsanity: testInsanity,
|
||||
|
@ -44,10 +43,10 @@ function makeAsyncHandler(label) {
|
|||
return function(thing, result) {
|
||||
thing = syncHandlers[label](thing);
|
||||
result(null, thing);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var asyncHandlers = {
|
||||
const asyncHandlers = {
|
||||
testVoid: testVoidAsync,
|
||||
testMulti: testMultiAsync,
|
||||
testException: testExceptionAsync,
|
||||
|
@ -55,22 +54,22 @@ var asyncHandlers = {
|
|||
testOneway: testOnewayAsync
|
||||
};
|
||||
|
||||
var identityHandlers = [
|
||||
'testString',
|
||||
'testBool',
|
||||
'testByte',
|
||||
'testI32',
|
||||
'testI64',
|
||||
'testDouble',
|
||||
'testBinary',
|
||||
'testStruct',
|
||||
'testNest',
|
||||
'testMap',
|
||||
'testStringMap',
|
||||
'testSet',
|
||||
'testList',
|
||||
'testEnum',
|
||||
'testTypedef'
|
||||
const identityHandlers = [
|
||||
"testString",
|
||||
"testBool",
|
||||
"testByte",
|
||||
"testI32",
|
||||
"testI64",
|
||||
"testDouble",
|
||||
"testBinary",
|
||||
"testStruct",
|
||||
"testNest",
|
||||
"testMap",
|
||||
"testStringMap",
|
||||
"testSet",
|
||||
"testList",
|
||||
"testEnum",
|
||||
"testTypedef"
|
||||
];
|
||||
|
||||
function testVoid() {
|
||||
|
@ -81,13 +80,11 @@ 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++) {
|
||||
function testMapMap() {
|
||||
const mapmap = [];
|
||||
const pos = [];
|
||||
const neg = [];
|
||||
for (let i = 1; i < 5; i++) {
|
||||
pos[i] = i;
|
||||
neg[-i] = -i;
|
||||
}
|
||||
|
@ -102,16 +99,16 @@ function testInsanity(argument) {
|
|||
//console.log(argument);
|
||||
//console.log(')');
|
||||
|
||||
var first_map = [];
|
||||
var second_map = [];
|
||||
const first_map = [];
|
||||
const second_map = [];
|
||||
|
||||
first_map[ttypes.Numberz.TWO] = argument;
|
||||
first_map[ttypes.Numberz.THREE] = argument;
|
||||
|
||||
var looney = new ttypes.Insanity();
|
||||
const looney = new ttypes.Insanity();
|
||||
second_map[ttypes.Numberz.SIX] = looney;
|
||||
|
||||
var insane = [];
|
||||
const insane = [];
|
||||
insane[1] = first_map;
|
||||
insane[2] = second_map;
|
||||
|
||||
|
@ -120,11 +117,11 @@ function testInsanity(argument) {
|
|||
return insane;
|
||||
}
|
||||
|
||||
function testMulti(arg0, arg1, arg2, arg3, arg4, arg5) {
|
||||
function testMulti(arg0, arg1, arg2) {
|
||||
//console.log('testMulti()');
|
||||
|
||||
var hello = new ttypes.Xtruct();
|
||||
hello.string_thing = 'Hello2';
|
||||
const hello = new ttypes.Xtruct();
|
||||
hello.string_thing = "Hello2";
|
||||
hello.byte_thing = arg0;
|
||||
hello.i32_thing = arg1;
|
||||
hello.i64_thing = arg2;
|
||||
|
@ -132,18 +129,18 @@ function testMulti(arg0, arg1, arg2, arg3, arg4, arg5) {
|
|||
}
|
||||
|
||||
function testMultiAsync(arg0, arg1, arg2, arg3, arg4, arg5, result) {
|
||||
var hello = testMulti(arg0, arg1, arg2, arg3, arg4, arg5);
|
||||
const 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();
|
||||
if (arg === "Xception") {
|
||||
const x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = arg;
|
||||
throw x;
|
||||
} else if (arg === 'TException') {
|
||||
} else if (arg === "TException") {
|
||||
throw new TException(arg);
|
||||
} else {
|
||||
return;
|
||||
|
@ -152,12 +149,12 @@ function testException(arg) {
|
|||
|
||||
function testExceptionAsync(arg, result) {
|
||||
//console.log('testException('+arg+')');
|
||||
if (arg === 'Xception') {
|
||||
var x = new ttypes.Xception();
|
||||
if (arg === "Xception") {
|
||||
const x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = arg;
|
||||
result(x);
|
||||
} else if (arg === 'TException') {
|
||||
} else if (arg === "TException") {
|
||||
result(new TException(arg));
|
||||
} else {
|
||||
result(null);
|
||||
|
@ -166,49 +163,48 @@ function testExceptionAsync(arg, result) {
|
|||
|
||||
function testMultiException(arg0, arg1) {
|
||||
//console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
|
||||
if (arg0 === ('Xception')) {
|
||||
var x = new ttypes.Xception();
|
||||
if (arg0 === "Xception") {
|
||||
const x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = 'This is an Xception';
|
||||
x.message = "This is an Xception";
|
||||
throw x;
|
||||
} else if (arg0 === ('Xception2')) {
|
||||
var x2 = new ttypes.Xception2();
|
||||
} else if (arg0 === "Xception2") {
|
||||
const x2 = new ttypes.Xception2();
|
||||
x2.errorCode = 2002;
|
||||
x2.struct_thing = new ttypes.Xtruct();
|
||||
x2.struct_thing.string_thing = 'This is an Xception2';
|
||||
x2.struct_thing.string_thing = "This is an Xception2";
|
||||
throw x2;
|
||||
}
|
||||
|
||||
var res = new ttypes.Xtruct();
|
||||
const 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();
|
||||
if (arg0 === "Xception") {
|
||||
const x = new ttypes.Xception();
|
||||
x.errorCode = 1001;
|
||||
x.message = 'This is an Xception';
|
||||
x.message = "This is an Xception";
|
||||
result(x);
|
||||
} else if (arg0 === ('Xception2')) {
|
||||
var x2 = new ttypes.Xception2();
|
||||
} else if (arg0 === "Xception2") {
|
||||
const x2 = new ttypes.Xception2();
|
||||
x2.errorCode = 2002;
|
||||
x2.struct_thing = new ttypes.Xtruct();
|
||||
x2.struct_thing.string_thing = 'This is an Xception2';
|
||||
x2.struct_thing.string_thing = "This is an Xception2";
|
||||
result(x2);
|
||||
} else {
|
||||
var res = new ttypes.Xtruct();
|
||||
const res = new ttypes.Xtruct();
|
||||
res.string_thing = arg1;
|
||||
result(null, res);
|
||||
}
|
||||
}
|
||||
|
||||
function testOneway(sleepFor) {
|
||||
//console.log('testOneway(' + sleepFor + ') => JavaScript (like Rust) never sleeps!');
|
||||
}
|
||||
//console.log('testOneway(' + sleepFor + ') => JavaScript (like Rust) never sleeps!');
|
||||
function testOneway() {}
|
||||
|
||||
function testOnewayAsync(sleepFor, result) {
|
||||
function testOnewayAsync(sleepFor) {
|
||||
testOneway(sleepFor);
|
||||
}
|
||||
|
||||
|
@ -217,11 +213,8 @@ identityHandlers.forEach(function(label) {
|
|||
asyncHandlers[label] = makeAsyncHandler(label);
|
||||
});
|
||||
|
||||
['testMapMap', 'testInsanity'].forEach(function(label) {
|
||||
["testMapMap", "testInsanity"].forEach(function(label) {
|
||||
asyncHandlers[label] = makeAsyncHandler(label);
|
||||
});
|
||||
|
||||
exports.ThriftTestHandler = asyncHandlers;
|
||||
|
||||
exports.AsyncThriftTestHandler = asyncHandlers;
|
||||
exports.SyncThriftTestHandler = asyncHandlers;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue