/lib/js/test/build
/lib/js/test/Makefile
/lib/js/test/Makefile.in
+/lib/nodejs/Makefile
+/lib/nodejs/Makefile.in
+/lib/nodejs/node_modules/
/lib/perl/MANIFEST
/lib/perl/MYMETA.yml
/lib/perl/Makefile
fi
AM_CONDITIONAL(WITH_ERLANG, [test "$have_erlang" = "yes"])
+AX_THRIFT_LIB(nodejs, [Nodejs], yes)
+have_nodejs=no
+if test "$with_nodejs" = "yes"; then
+ AC_PATH_PROGS([NODEJS], [nodejs node])
+ AC_PATH_PROG([NPM], [npm])
+ if test "x$NODEJS" != "x" -a "x$NPM" != "x"; then
+ have_nodejs="yes"
+ fi
+fi
+AM_CONDITIONAL(WITH_NODEJS, [test "$have_nodejs" = "yes"])
+AM_CONDITIONAL(HAVE_NPM, [test "x$NPM" != "x"])
+
AX_THRIFT_LIB(python, [Python], yes)
if test "$with_python" = "yes"; then
AM_PATH_PYTHON(2.4,, :)
# gruard against pre defined config.h
AH_TOP([
#ifndef CONFIG_H
-#define CONFIG_H
+#define CONFIG_H
])
AH_BOTTOM([
#endif
lib/hs/Makefile
lib/java/Makefile
lib/js/test/Makefile
+ lib/nodejs/Makefile
lib/perl/Makefile
lib/perl/test/Makefile
lib/php/Makefile
test/Makefile
test/cpp/Makefile
test/hs/Makefile
- test/nodejs/Makefile
test/php/Makefile
test/perl/Makefile
test/py/Makefile
echo "Building Erlang Library ...... : $have_erlang"
echo "Building Go Library .......... : $have_go"
echo "Building D Library ........... : $have_d"
+echo "Building NodeJS Library ...... : $have_nodejs"
if test "$have_cpp" = "yes" ; then
echo
echo " Building D libevent tests . : $with_d_event_tests"
echo " Building D SSL tests ...... : $with_d_ssl_tests"
fi
+if test "$have_nodejs" = "yes" ; then
+ echo
+ echo "NodeJS Library:"
+ echo " Using NodeJS .............. : $NODEJS"
+ echo " Using NodeJS version....... : $($NODEJS --version)"
+fi
echo
echo "If something is missing that you think should be present,"
echo "please skim the output of configure to find the missing"
SUBDIRS += d
endif
+if WITH_NODEJS
+SUBDIRS += nodejs
+endif
+
+
# All of the libs that don't use Automake need to go in here
# so they will end up in our release tarballs.
EXTRA_DIST = \
delphi \
javame \
js \
- nodejs \
ocaml \
st
--- /dev/null
+# 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.
+
+
+THRIFT = $(top_srcdir)/compiler/cpp/thrift
+
+#stubs: $(top_srcdir)/test/ThriftTest.thrift
+# $(THRIFT) --gen js:node -o test/ $(top_srcdir)/test/ThriftTest.thrift
+
+deps: package.json
+ $(NPM) install
+
+check: deps
+ $(NPM) test
+
+clean-local:
+ $(RM) -r test/gen-nodejs
"nodeunit": "~0.8.0"
},
"devDependencies": {
- "connect": "2.7.x"
+ "connect": "2.7.x",
+ "commander": "2.1.x"
+ },
+ "scripts": {
+ "test" : "test/testAll.sh"
}
}
var assert = require('assert');
var thrift = require('thrift');
-var TFramedTransport = require('thrift/transport').TFramedTransport;
+var ThriftTransports = require('thrift/transport');
+var ThriftProtocols = require('thrift/protocol');
var ThriftTest = require('./gen-nodejs/ThriftTest');
var ThriftTestDriver = require('./thrift_test_driver').ThriftTestDriver;
-var connection = thrift.createConnection('localhost', 9090, { transport: TFramedTransport} );
+var program = require('commander');
+
+program
+ .option('-p, --protocol <protocol>', 'Set thift protocol (binary|json) [protocol]')
+ .option('-t, --transport <transport>', 'Set thift transport (buffered|framed) [transport]')
+ .parse(process.argv);
+
+var protocol = undefined;
+var transport = undefined;
+
+if (program.protocol === "binary") {
+ protocol = ThriftProtocols.TBinaryProtocol;
+} else if (program.protocol === "json") {
+ protocol = ThriftProtocols.TJSONProtocol;
+} else {
+ //default
+ protocol = ThriftProtocols.TBinaryProtocol;
+}
+
+if (program.transport === "framed") {
+ transport = ThriftTransports.TFramedTransport;
+} else if (program.transport === "buffered") {
+ transport = ThriftTransports.TBufferedTransport;
+} else {
+ //default
+ transport = ThriftTransports.TBufferedTransport;
+}
+
+var connection = thrift.createConnection('localhost', 9090, {
+ transport: transport,
+ protocol: protocol
+});
+
var client = thrift.createClient(ThriftTest, connection);
connection.on('error', function(err) {
// to make it also run on expresso
exports.expressoTest = function() {};
-
* under the License.
*/
var thrift = require('thrift');
-var ttransport = require('transport');
+var ThriftTransports = require('thrift/transport');
+var ThriftProtocols = require('thrift/protocol');
var assert = require('assert');
var ThriftTest = require('./gen-nodejs/ThriftTest'),
SecondService = require('./gen-nodejs/SecondService'),
ttypes = require('./gen-nodejs/ThriftTest_types');
+var program = require('commander');
+
+program
+ .option('-p, --protocol <protocol>', 'Set thift protocol (binary|json) [protocol]')
+ .option('-t, --transport <transport>', 'Set thift transport (buffered|framed) [transport]')
+ .parse(process.argv);
+
+var protocol = undefined;
+var transport = undefined;
+
+if (program.protocol === "binary") {
+ protocol = ThriftProtocols.TBinaryProtocol;
+} else if (program.protocol === "json") {
+ protocol = ThriftProtocols.TJSONProtocol;
+} else {
+ //default
+ protocol = ThriftProtocols.TBinaryProtocol;
+}
+
+if (program.transport === "framed") {
+ transport = ThriftTransports.TFramedTransport;
+} else if (program.transport === "buffered") {
+ transport = ThriftTransports.TBufferedTransport;
+} else {
+ //default
+ transport = ThriftTransports.TBufferedTransport;
+}
+
var connection = thrift.createConnection('localhost', 9090, {
- 'transport': ttransport.TFramedTransport
+ transport: transport,
+ protocol: protocol
});
var mp = new thrift.Multiplexer();
--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * 'License'); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+var thrift = require('thrift');
+var Thrift = thrift.Thrift;
+var ThriftTransports = require('thrift/transport');
+var ThriftProtocols = require('thrift/protocol');
+
+var ThriftTest = require('./gen-nodejs/ThriftTest'),
+ SecondService = require('./gen-nodejs/SecondService'),
+ ttypes = require('./gen-nodejs/ThriftTest_types');
+
+var program = require('commander');
+
+program
+ .option('-p, --protocol <protocol>', 'Set thift protocol (binary|json) [protocol]')
+ .option('-t, --transport <transport>', 'Set thift transport (buffered|framed) [transport]')
+ .parse(process.argv);
+
+var protocol = undefined;
+var transport = undefined;
+
+if (program.protocol === "binary") {
+ protocol = ThriftProtocols.TBinaryProtocol;
+} else if (program.protocol === "json") {
+ protocol = ThriftProtocols.TJSONProtocol;
+} else {
+ //default
+ protocol = ThriftProtocols.TBinaryProtocol;
+}
+
+if (program.transport === "framed") {
+ transport = ThriftTransports.TFramedTransport;
+} else if (program.transport === "buffered") {
+ transport = ThriftTransports.TBufferedTransport;
+} else {
+ //default
+ transport = ThriftTransports.TBufferedTransport;
+}
+
+var ThriftTestHandler = require("./test_handler").ThriftTestHandler;
+
+var SecondServiceHandler = {
+ secondtestString: function(thing, result) {
+ console.log('testString(\'' + thing + '\')');
+ result(null, thing);
+ }
+};
+
+var processor = new thrift.MultiplexedProcessor();
+
+processor.registerProcessor(
+ "ThriftTest",
+ new ThriftTest.Processor(ThriftTestHandler));
+
+processor.registerProcessor(
+ "SecondService",
+ new SecondService.Processor(SecondServiceHandler));
+
+var server = thrift.createMultiplexServer(processor, {
+ protocol: protocol,
+ transport: transport
+});
+
+server.listen(9090);
// TSocket
var thrift = require('thrift');
-var TFramedTransport = require('thrift/transport').TFramedTransport;
+var ThriftTransports = require('thrift/transport');
+var ThriftProtocols = require('thrift/protocol');
var ThriftTest = require('./gen-nodejs/ThriftTest');
var ThriftTestHandler = require('./test_handler').ThriftTestHandler;
-thrift.createServer(ThriftTest,
- ThriftTestHandler,
- {'transport': TFramedTransport}).listen(9090);
+var program = require('commander');
+
+program
+ .option('-p, --protocol <protocol>', 'Set thift protocol (binary|json) [protocol]')
+ .option('-t, --transport <transport>', 'Set thift transport (buffered|framed) [transport]')
+ .parse(process.argv);
+
+var protocol = undefined;
+var transport = undefined;
+
+if (program.protocol === "binary") {
+ protocol = ThriftProtocols.TBinaryProtocol;
+} else if (program.protocol === "json") {
+ protocol = ThriftProtocols.TJSONProtocol;
+} else {
+ //default
+ protocol = ThriftProtocols.TBinaryProtocol;
+}
+
+if (program.transport === "framed") {
+ transport = ThriftTransports.TFramedTransport;
+} else if (program.transport === "buffered") {
+ transport = ThriftTransports.TBufferedTransport;
+} else {
+ //default
+ transport = ThriftTransports.TBufferedTransport;
+}
+
+thrift.createServer(ThriftTest, ThriftTestHandler, {
+ protocol: protocol,
+ transport: transport
+}).listen(9090);
--- /dev/null
+#! /bin/sh
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# 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.
+#
+
+DIR="$( cd "$( dirname "$0" )" && pwd )"
+
+export NODE_PATH="${DIR}:${DIR}/../lib:${NODE_PATH}"
+
+testClientServer()
+{
+ echo " Testing Client/Server with protocol $1 and transport $2";
+ RET=0
+ node ${DIR}/server.js -p $1 -t $2 &
+ SERVERPID=$!
+ sleep 1
+ node ${DIR}/client.js -p $1 -t $2 || RET=1
+ kill -9 $SERVERPID || RET=1
+ return $RET
+}
+
+testMultiplexedClientServer()
+{
+ echo " Testing Multiplexed Client/Server with protocol $1 and transport $2";
+ RET=0
+ node ${DIR}/multiplex_server.js -p $1 -t $2 &
+ SERVERPID=$!
+ sleep 1
+ node ${DIR}/multiplex_client.js -p $1 -t $2 || RET=1
+ kill -9 $SERVERPID || RET=1 #f
+ return $RET
+}
+
+
+TESTOK=0
+
+#generating thrift code
+
+${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/ThriftTest.thrift
+
+#unit tests
+
+node ${DIR}/binary.test.js || TESTOK=1
+
+#integration tests
+
+testClientServer binary buffered || TESTOK=1
+testClientServer json buffered || TESTOK=1
+testClientServer binary framed || TESTOK=1
+testClientServer json framed || TESTOK=1
+
+testMultiplexedClientServer binary buffered || TESTOK=1
+testMultiplexedClientServer json buffered || TESTOK=1
+testMultiplexedClientServer binary framed || TESTOK=1
+testMultiplexedClientServer json framed || TESTOK=1
+
+exit $TESTOK
# under the License.
#
-SUBDIRS = nodejs
+SUBDIRS =
if WITH_CPP
SUBDIRS += cpp
test.sh \
cpp \
hs \
- nodejs \
ocaml \
perl \
php \
+++ /dev/null
-# 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.
-
-
-THRIFT = $(top_srcdir)/compiler/cpp/thrift
-
-stubs: ../ThriftTest.thrift
- $(THRIFT) --gen js:node ../ThriftTest.thrift
-
-check: stubs
- @if which nodeunit &> /dev/null ; then \
- echo " Testing thrift/binary"; \
- NODE_PATH=../../lib/nodejs/lib:../../lib/nodejs/lib/thrift:$(NODE_PATH) nodeunit ../../lib/nodejs/test/binary.test.js; \
- fi
- @if which node &> /dev/null ; then \
- echo " Testing Client/Server"; \
- timeout -s14 5 $(MAKE) server & \
- sleep 1; $(MAKE) client; sleep 2; \
- \
- echo " Testing Multiplex Client/Server"; \
- sleep 4; timeout -s14 5 $(MAKE) mserver & \
- sleep 1; $(MAKE) mclient; sleep 2; \
- \
- echo " Testing Client/Server examples"; \
- sleep 4; timeout -s14 5 $(MAKE) -C ../../lib/nodejs/examples server & \
- sleep 1; $(MAKE) -C ../../lib/nodejs/examples client; sleep 2; \
- fi
-
-clean-local:
- $(RM) -r gen-nodejs
-
-server:
- NODE_PATH=../../lib/nodejs/lib:../../lib/nodejs/lib/thrift:$(NODE_PATH) node server.js
-
-client:
- NODE_PATH=../../lib/nodejs/lib:../../lib/nodejs/lib/thrift:$(NODE_PATH) node client.js
-
-mserver:
- NODE_PATH=../../lib/nodejs/lib:../../lib/nodejs/lib/thrift:$(NODE_PATH) node multiplex_server.js
-
-mclient:
- NODE_PATH=../../lib/nodejs/lib:../../lib/nodejs/lib/thrift:$(NODE_PATH) node multiplex_client.js
+++ /dev/null
-/*\r
- * Licensed to the Apache Software Foundation (ASF) under one\r
- * or more contributor license agreements. See the NOTICE file\r
- * distributed with this work for additional information\r
- * regarding copyright ownership. The ASF licenses this file\r
- * to you under the Apache License, Version 2.0 (the\r
- * "License"); you may not use this file except in compliance\r
- * with the License. You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing,\r
- * software distributed under the License is distributed on an\r
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
- * KIND, either express or implied. See the License for the\r
- * specific language governing permissions and limitations\r
- * under the License.\r
- */\r
-\r
-//Node client test for the following I/O stack:\r
-// TJSONProtocol\r
-// TBufferedTransport\r
-// TSocket\r
-\r
-var assert = require('assert');\r
-var thrift = require('thrift');\r
-var TBufferedTransport = require('thrift/transport').TBufferedTransport;\r
-var TBinaryProtocol = require('thrift/protocol').TBinaryProtocol;\r
-var ThriftTest = require('./gen-nodejs/ThriftTest');\r
-var ThriftTestDriver = require('./thrift_test_driver').ThriftTestDriver;\r
-\r
-var connection = thrift.createConnection('localhost', 9090, \r
- { protocol: TBinaryProtocol, transport: TBufferedTransport} );\r
-var client = thrift.createClient(ThriftTest, connection);\r
-\r
-connection.on('error', function(err) {\r
- assert(false, err);\r
-});\r
-\r
-ThriftTestDriver(client, function (status) {\r
- console.log(status);\r
- connection.end();\r
-});\r
-\r
-// to make it also run on expresso\r
-exports.expressoTest = function() {};\r
-\r
+++ /dev/null
-/*\r
- * Licensed to the Apache Software Foundation (ASF) under one\r
- * or more contributor license agreements. See the NOTICE file\r
- * distributed with this work for additional information\r
- * regarding copyright ownership. The ASF licenses this file\r
- * to you under the Apache License, Version 2.0 (the\r
- * "License"); you may not use this file except in compliance\r
- * with the License. You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing,\r
- * software distributed under the License is distributed on an\r
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
- * KIND, either express or implied. See the License for the\r
- * specific language governing permissions and limitations\r
- * under the License.\r
- */\r
-\r
-//Node client test for the following I/O stack:\r
-// TJSONProtocol\r
-// TBufferedTransport\r
-// TSocket\r
-\r
-var assert = require('assert');\r
-var thrift = require('thrift');\r
-var TBufferedTransport = require('thrift/transport').TBufferedTransport;\r
-var TJSONProtocol = require('thrift/protocol').TJSONProtocol;\r
-var ThriftTest = require('./gen-nodejs/ThriftTest');\r
-var ThriftTestDriver = require('./thrift_test_driver').ThriftTestDriver;\r
-\r
-var connection = thrift.createConnection('localhost', 9090, \r
- { protocol: TJSONProtocol, transport: TBufferedTransport} );\r
-var client = thrift.createClient(ThriftTest, connection);\r
-\r
-connection.on('error', function(err) {\r
- assert(false, err);\r
-});\r
-\r
-ThriftTestDriver(client, function (status) {\r
- console.log(status);\r
- connection.end();\r
-});\r
-\r
-// to make it also run on expresso\r
-exports.expressoTest = function() {};\r
-\r
+++ /dev/null
-/*\r
- * Licensed to the Apache Software Foundation (ASF) under one\r
- * or more contributor license agreements. See the NOTICE file\r
- * distributed with this work for additional information\r
- * regarding copyright ownership. The ASF licenses this file\r
- * to you under the Apache License, Version 2.0 (the\r
- * "License"); you may not use this file except in compliance\r
- * with the License. You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing,\r
- * software distributed under the License is distributed on an\r
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
- * KIND, either express or implied. See the License for the\r
- * specific language governing permissions and limitations\r
- * under the License.\r
- */\r
-\r
-//Node client test for the following I/O stack:\r
-// TJSONProtocol\r
-// TBufferedTransport\r
-// TSocket\r
-\r
-var assert = require('assert');\r
-var thrift = require('thrift');\r
-var TFramedTransport = require('thrift/transport').TFramedTransport;\r
-var TJSONProtocol = require('thrift/protocol').TJSONProtocol;\r
-var ThriftTest = require('./gen-nodejs/ThriftTest');\r
-var ThriftTestDriver = require('./thrift_test_driver').ThriftTestDriver;\r
-\r
-var connection = thrift.createConnection('localhost', 9090, \r
- { protocol: TJSONProtocol, transport: TFramedTransport} );\r
-var client = thrift.createClient(ThriftTest, connection);\r
-\r
-connection.on('error', function(err) {\r
- assert(false, err);\r
-});\r
-\r
-ThriftTestDriver(client, function (status) {\r
- console.log(status);\r
- connection.end();\r
-});\r
-\r
-// to make it also run on expresso\r
-exports.expressoTest = function() {};\r
-\r
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * 'License'); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-var thrift = require('thrift');
-var Thrift = thrift.Thrift;
-var ttransport = require('transport');
-
-var ThriftTest = require('./gen-nodejs/ThriftTest'),
- SecondService = require('./gen-nodejs/SecondService'),
- ttypes = require('./gen-nodejs/ThriftTest_types');
-
-var ThriftTestHandler = {
- testVoid: function(result) {
- console.log('testVoid()');
- result(null);
- },
-
- testString: function(thing, result) {
- console.log('testString(\'' + thing + '\')');
- result(null, thing);
- },
-
- testByte: function(thing, result) {
- console.log('testByte(' + thing + ')');
- result(null, thing);
- },
-
- testI32: function(thing, result) {
- console.log('testI32(' + thing + ')');
- result(null, thing);
- },
-
- testI64: function(thing, result) {
- console.log('testI64(' + thing + ')');
- result(null, thing);
- },
-
- testDouble: function(thing, result) {
- console.log('testDouble(' + thing + ')');
- result(null, thing);
- },
-
- testStruct: function(thing, result) {
- console.log('testStruct(');
- console.log(thing);
- console.log(')');
- result(null, thing);
- },
-
- testNest: function(nest, result) {
- console.log('testNest(');
- console.log(nest);
- console.log(')');
- result(null, nest);
- },
-
- testMap: function(thing, result) {
- console.log('testMap(');
- console.log(thing);
- console.log(')');
- result(null, thing);
- },
-
- testStringMap: function(thing, result) {
- console.log('testStringMap(');
- console.log(thing);
- console.log(')');
- result(null, thing);
- },
-
- testSet: function(thing, result) {
- console.log('testSet(');
- console.log(thing);
- console.log(')');
- result(null, thing);
- },
-
- testList: function(thing, result) {
- console.log('testList(');
- console.log(thing);
- console.log(')');
- result(null, thing);
- },
-
- testEnum: function(thing, result) {
- console.log('testEnum(' + thing + ')');
- result(null, thing);
- },
-
- testTypedef: function(thing, result) {
- console.log('testTypedef(' + thing + ')');
- result(null, thing);
- },
-
- testMapMap: function(hello, result) {
- console.log('testMapMap(' + hello + ')');
-
- var mapmap = [];
- var pos = [];
- var neg = [];
- for (var i = 1; i < 5; i++) {
- pos[i] = i;
- neg[-i] = -i;
- }
- mapmap[4] = pos;
- mapmap[-4] = neg;
-
- result(null, mapmap);
- },
-
- testInsanity: function(argument, result) {
- console.log('testInsanity(');
- console.log(argument);
- console.log(')');
-
- var hello = new ttypes.Xtruct();
- hello.string_thing = 'Hello2';
- hello.byte_thing = 2;
- hello.i32_thing = 2;
- hello.i64_thing = 2;
-
- var goodbye = new ttypes.Xtruct();
- goodbye.string_thing = 'Goodbye4';
- goodbye.byte_thing = 4;
- goodbye.i32_thing = 4;
- goodbye.i64_thing = 4;
-
- var crazy = new ttypes.Insanity();
- crazy.userMap = [];
- crazy.userMap[ttypes.Numberz.EIGHT] = 8;
- crazy.userMap[ttypes.Numberz.FIVE] = 5;
- crazy.xtructs = [goodbye, hello];
-
- var first_map = [];
- var second_map = [];
-
- first_map[ttypes.Numberz.TWO] = crazy;
- first_map[ttypes.Numberz.THREE] = crazy;
-
- var looney = new ttypes.Insanity();
- second_map[ttypes.Numberz.SIX] = looney;
-
- var insane = [];
- insane[1] = first_map;
- insane[2] = second_map;
-
- console.log('insane result:');
- console.log(insane);
- result(null, insane);
- },
-
- testMulti: function(arg0, arg1, arg2, arg3, arg4, arg5, result) {
- console.log('testMulti()');
-
- var hello = new ttypes.Xtruct();;
- hello.string_thing = 'Hello2';
- hello.byte_thing = arg0;
- hello.i32_thing = arg1;
- hello.i64_thing = arg2;
- result(null, hello);
- },
-
- testException: function(arg, result) {
- console.log('testException(' + arg + ')');
- if (arg === 'Xception') {
- var x = new ttypes.Xception();
- x.errorCode = 1001;
- x.message = arg;
- result(x);
- } else if (arg === 'TException') {
- result(new Thrift.TException(arg));
- } else {
- result(null);
- }
- },
-
- testMultiException: function(arg0, arg1, result) {
- console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
- if (arg0 === ('Xception')) {
- var x = new ttypes.Xception();
- x.errorCode = 1001;
- x.message = 'This is an Xception';
- result(x);
- } else if (arg0 === ('Xception2')) {
- var x = new ttypes.Xception2();
- x.errorCode = 2002;
- x.struct_thing = new ttypes.Xtruct();
- x.struct_thing.string_thing = 'This is an Xception2';
- result(x);
- }
-
- var res = new ttypes.Xtruct();
- res.string_thing = arg1;
- result(null, res);
- },
-
- testOneway: function(sleepFor, result) {
- console.log('testOneway(' + sleepFor + ') => sleeping...');
- setTimeout(function() {
- console.log('Done sleeping for testOneway!');
- }, sleepFor * 1000); //seconds
- }
-};
-
-var SecondServiceHandler = {
- secondtestString: function(thing, result) {
- console.log('testString(\'' + thing + '\')');
- result(null, thing);
- }
-};
-
-var processor = new thrift.MultiplexedProcessor();
-
-processor.registerProcessor(
- "ThriftTest",
- new ThriftTest.Processor(ThriftTestHandler));
-
-processor.registerProcessor(
- "SecondService",
- new SecondService.Processor(SecondServiceHandler));
-
-
-var server = thrift.createMultiplexServer(processor, { //server options
- 'transport': ttransport.TFramedTransport
-});
-
-server.listen(9090);
+++ /dev/null
-{
- "name": "thrift-nodejs-test",
- "version": "1.0.0-dev",
- "description": "node.js test server and client for the Apache Thrift",
- "homepage": "http://thrift.apache.org/",
- "repository":
- { "type" : "git",
- "url" : "https://git-wip-us.apache.org/repos/asf/thrift.git"
- },
- "author":
- { "name": "Apache Thrift Developers",
- "email": "dev@thrift.apache.org",
- "url": "http://thrift.apache.org"
- },
- "licenses":
- [ { "type": "Apache-2.0",
- "url": "http://www.apache.org/licenses/LICENSE-2.0"
- }
- ],
- "bugs":
- { "mail": "dev@thrift.apache.org",
- "url": "https://issues.apache.org/jira/browse/THRIFT"
- },
- "directories" : { "lib" : "../lib/nodejs/lib/thrift" },
- "main": "../lib/nodejs/lib/thrift",
- "scripts": {
- "start": "node ./http-server"
- },
- "engines": { "node": ">= 0.2.4" }
-}
+++ /dev/null
-/*\r
- * Licensed to the Apache Software Foundation (ASF) under one\r
- * or more contributor license agreements. See the NOTICE file\r
- * distributed with this work for additional information\r
- * regarding copyright ownership. The ASF licenses this file\r
- * to you under the Apache License, Version 2.0 (the\r
- * 'License'); you may not use this file except in compliance\r
- * with the License. You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing,\r
- * software distributed under the License is distributed on an\r
- * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
- * KIND, either express or implied. See the License for the\r
- * specific language governing permissions and limitations\r
- * under the License.\r
- */\r
-\r
-//Node server test for the following I/O stack:\r
-// TJSONProtocol\r
-// TBufferedTransport\r
-// TSocket\r
-\r
-var thrift = require('thrift');\r
-var TBufferedTransport = require('thrift/transport').TBufferedTransport;\r
-var TBinaryProtocol = require('thrift/protocol').TBinaryProtocol;\r
-var ThriftTestSvc = require('./gen-nodejs/ThriftTest');\r
-var ThriftTestHandler = require('./test_handler').ThriftTestHandler;\r
-\r
-var ThriftTestSvcOpt = {\r
- transport: TBufferedTransport,\r
- protocol: TBinaryProtocol\r
-};\r
-\r
-thrift.createServer(ThriftTestSvc, \r
- ThriftTestHandler, \r
- ThriftTestSvcOpt).listen(9090);\r
+++ /dev/null
-/*\r
- * Licensed to the Apache Software Foundation (ASF) under one\r
- * or more contributor license agreements. See the NOTICE file\r
- * distributed with this work for additional information\r
- * regarding copyright ownership. The ASF licenses this file\r
- * to you under the Apache License, Version 2.0 (the\r
- * 'License'); you may not use this file except in compliance\r
- * with the License. You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing,\r
- * software distributed under the License is distributed on an\r
- * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
- * KIND, either express or implied. See the License for the\r
- * specific language governing permissions and limitations\r
- * under the License.\r
- */\r
-\r
-//Node server test for the following I/O stack:\r
-// TJSONProtocol\r
-// TBufferedTransport\r
-// TSocket\r
-\r
-var thrift = require('thrift');\r
-var TBufferedTransport = require('thrift/transport').TBufferedTransport;\r
-var TJSONProtocol = require('thrift/protocol').TJSONProtocol;\r
-var ThriftTestSvc = require('./gen-nodejs/ThriftTest');\r
-var ThriftTestHandler = require('./test_handler').ThriftTestHandler;\r
-\r
-var ThriftTestSvcOpt = {\r
- transport: TBufferedTransport,\r
- protocol: TJSONProtocol\r
-};\r
-\r
-thrift.createServer(ThriftTestSvc, \r
- ThriftTestHandler, \r
- ThriftTestSvcOpt).listen(9090);\r
+++ /dev/null
-/*\r
- * Licensed to the Apache Software Foundation (ASF) under one\r
- * or more contributor license agreements. See the NOTICE file\r
- * distributed with this work for additional information\r
- * regarding copyright ownership. The ASF licenses this file\r
- * to you under the Apache License, Version 2.0 (the\r
- * 'License'); you may not use this file except in compliance\r
- * with the License. You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing,\r
- * software distributed under the License is distributed on an\r
- * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
- * KIND, either express or implied. See the License for the\r
- * specific language governing permissions and limitations\r
- * under the License.\r
- */\r
-\r
-//Node server test for the following I/O stack:\r
-// TJSONProtocol\r
-// TBufferedTransport\r
-// TSocket\r
-\r
-var thrift = require('thrift');\r
-var TFramedTransport = require('thrift/transport').TFramedTransport;\r
-var TJSONProtocol = require('thrift/protocol').TJSONProtocol;\r
-var ThriftTestSvc = require('./gen-nodejs/ThriftTest');\r
-var ThriftTestHandler = require('./test_handler').ThriftTestHandler;\r
-\r
-var ThriftTestSvcOpt = {\r
- transport: TFramedTransport,\r
- protocol: TJSONProtocol\r
-};\r
-\r
-thrift.createServer(ThriftTestSvc, \r
- ThriftTestHandler, \r
- ThriftTestSvcOpt).listen(9090);\r
java_sockets="ip ip-ssl"
# TODO fastframed java transport is another implementation of framed transport
+nodejs_protocols="binary json"
+nodejs_transports="buffered framed"
+nodejs_sockets="ip"
ant -f ../lib/java/build.xml compile-test 1>/dev/null
done
done
+
+NODE_TEST_DIR=${BASEDIR}/../bin/nodejs/tests
+export NODE_PATH=${NODE_TEST_DIR}:${NODE_TEST_DIR}/../lib:${NODE_PATH}
+######### nodejs client - cpp server ##############
+##
+for proto in $(intersection "${nodejs_protocols}" "${cpp_protocols}"); do
+ for trans in $(intersection "${nodejs_transports}" "${cpp_transports}"); do
+ for sock in $(intersection "${nodejs_sockets}" "${cpp_sockets}"); do
+ do_test "nodejs-cpp" "${proto}" "${trans}-ip" \
+ "nodejs ${NODE_TEST_DIR}/client.js -p ${proto} -t ${trans}" \
+ "cpp/TestServer --protocol=${proto} --transport=${trans} ${extraparam}" \
+ "10" "10"
+ done
+ done
+done
+
+######### cpp client - nodejs server ##############
+for proto in $(intersection "${nodejs_protocols}" "${cpp_protocols}"); do
+ for trans in $(intersection "${nodejs_transports}" "${cpp_transports}"); do
+ for sock in $(intersection "${nodejs_sockets}" "${cpp_sockets}"); do
+ do_test "cpp-nodejs" "${proto}" "${trans}-ip" \
+ "cpp/TestClient --protocol=${proto} --transport=${trans}" \
+ "nodejs ${NODE_TEST_DIR}/server.js -p ${proto} -t ${trans}" \
+ "10" "10"
+ done
+ done
+done
+
# delete Unix Domain Socket used by cpp tests
rm -f /tmp/ThriftTest.thrift
"make -C php/ client" \
"cpp/TestServer" \
"10" "10"
-do_test "nodejs-nodejs" "binary" "framed-ip" \
- "make -C nodejs/ client" \
- "make -C nodejs/ server" \
- "1" "5"
-do_test "nodejs-cpp" "binary" "framed-ip" \
- "make -C nodejs/ client" \
- "cpp/TestServer --transport=framed" \
- "1" "10"
-do_test "cpp-nodejs" "binary" "framed-ip" \
- "cpp/TestClient --transport=framed" \
- "make -C nodejs/ server" \
- "1" "5"
do_test "rb-rb" "binary" "buffered-ip" \
"ruby rb/integration/simple_client.rb" \
"ruby rb/integration/simple_server.rb" \