summaryrefslogtreecommitdiff
path: root/lib/nodejs
diff options
context:
space:
mode:
authorJames E. King, III <jking@apache.org>2017-10-26 00:09:34 -0400
committerJames E. King, III <jking@apache.org>2017-10-28 17:54:58 -0400
commit375bfee701d3caa74074f8afb3d6940e52c45c88 (patch)
treef6bde60d9c4deefacc2658bd0b6be51748766079 /lib/nodejs
parent5a4f7382d2c37231693890be11c6faaec495194a (diff)
downloadthrift-375bfee701d3caa74074f8afb3d6940e52c45c88.tar.gz
THRIFT-2998: enable cross test for nodejs http transport,
fix missing apache license headers in nodejs Client: nodejs This closes #1403
Diffstat (limited to 'lib/nodejs')
-rw-r--r--lib/nodejs/test/browser_client.js18
-rw-r--r--lib/nodejs/test/client.js12
-rw-r--r--lib/nodejs/test/deep-constructor.test.js21
-rw-r--r--lib/nodejs/test/exceptions.js19
-rw-r--r--lib/nodejs/test/helpers.js19
-rw-r--r--lib/nodejs/test/server.js11
-rw-r--r--lib/nodejs/test/test-cases.js19
7 files changed, 112 insertions, 7 deletions
diff --git a/lib/nodejs/test/browser_client.js b/lib/nodejs/test/browser_client.js
index 27db543be..72fd8375b 100644
--- a/lib/nodejs/test/browser_client.js
+++ b/lib/nodejs/test/browser_client.js
@@ -1,3 +1,21 @@
+/*
+ * 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 assert = require('assert');
var thrift = require('thrift');
diff --git a/lib/nodejs/test/client.js b/lib/nodejs/test/client.js
index a38a66b76..9609518c4 100644
--- a/lib/nodejs/test/client.js
+++ b/lib/nodejs/test/client.js
@@ -32,13 +32,13 @@ var ttypes = require('./gen-nodejs/ThriftTest_types');
var program = require('commander');
program
- .option('-p, --protocol <protocol>', 'Set thrift protocol (binary|json) [protocol]')
- .option('-t, --transport <transport>', 'Set thrift transport (buffered|framed) [transport]')
+ .option('-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('--ssl', 'use SSL transport')
.option('--promise', 'test with promise style functions')
- .option('-t, --type <type>', 'Select server type (tcp|multiplex|http)', 'tcp')
+ .option('-t, --type <type>', 'Select server type (http|multiplex|tcp|websocket)', 'tcp')
.parse(process.argv);
var host = program.host;
@@ -47,6 +47,12 @@ var type = program.type;
var ssl = program.ssl;
var promise = program.promise;
+/* for compatibility with cross test invocation for http transport testing */
+if (program.transport === 'http') {
+ program.transport = 'buffered';
+ type = 'http';
+}
+
var options = {
transport: helpers.transports[program.transport],
protocol: helpers.protocols[program.protocol]
diff --git a/lib/nodejs/test/deep-constructor.test.js b/lib/nodejs/test/deep-constructor.test.js
index 2caeb824d..145b66875 100644
--- a/lib/nodejs/test/deep-constructor.test.js
+++ b/lib/nodejs/test/deep-constructor.test.js
@@ -1,3 +1,22 @@
+/*
+ * 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/JsDeepConstructorTest_types');
var thrift = require('thrift');
var test = require('tape');
@@ -286,7 +305,7 @@ function createTestCases(serialize, deserialize) {
"Can make list with objects": function(assert) {
var tObj = new ttypes.ComplexList({
- "struct_list_field": [new ttypes.Complex({})]
+ "struct_list_field": [new ttypes.Complex({})]
});
var innerObj = tObj.struct_list_field[0];
assert.ok(innerObj instanceof ttypes.Complex)
diff --git a/lib/nodejs/test/exceptions.js b/lib/nodejs/test/exceptions.js
index c6f2e4d25..0a7577062 100644
--- a/lib/nodejs/test/exceptions.js
+++ b/lib/nodejs/test/exceptions.js
@@ -1,3 +1,22 @@
+/*
+ * 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';
var test = require('tape');
var thrift = require('../lib/thrift/thrift.js');
diff --git a/lib/nodejs/test/helpers.js b/lib/nodejs/test/helpers.js
index c850c46c4..5f828b31c 100644
--- a/lib/nodejs/test/helpers.js
+++ b/lib/nodejs/test/helpers.js
@@ -1,3 +1,22 @@
+/*
+ * 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';
var thrift = require('../lib/thrift');
diff --git a/lib/nodejs/test/server.js b/lib/nodejs/test/server.js
index 6e5cdfa7a..bad3b1777 100644
--- a/lib/nodejs/test/server.js
+++ b/lib/nodejs/test/server.js
@@ -32,12 +32,12 @@ var ThriftTestHandlerPromise = require('./test_handler').SyncThriftTestHandler;
var ttypes = require('./gen-nodejs/ThriftTest_types');
program
- .option('-p, --protocol <protocol>', 'Set thrift protocol (binary|json|compact)', 'binary')
- .option('-t, --transport <transport>', 'Set thrift transport (buffered|framed)', 'buffered')
+ .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('--promise', 'test with promise style functions')
- .option('-t, --type <type>', 'Select server type (tcp|multiplex|http)', 'tcp')
+ .option('-t, --type <type>', 'Select server type (http|multiplex|tcp|websocket)', 'tcp')
.parse(process.argv);
var port = program.port;
@@ -47,6 +47,11 @@ var promise = program.promise;
var handler = program.promise ? ThriftTestHandler : ThriftTestHandlerPromise;
+if (program.transport === 'http') {
+ program.transport = 'buffered';
+ type = 'http';
+}
+
var options = {
transport: helpers.transports[program.transport],
protocol: helpers.protocols[program.protocol]
diff --git a/lib/nodejs/test/test-cases.js b/lib/nodejs/test/test-cases.js
index 13722be8b..bd66dc496 100644
--- a/lib/nodejs/test/test-cases.js
+++ b/lib/nodejs/test/test-cases.js
@@ -1,3 +1,22 @@
+/*
+ * 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';
var ttypes = require('./gen-nodejs/ThriftTest_types');