THRIFT-2327 nodejs: nodejs test suite should be bundled with the library
authorRoger Meier <roger@apache.org>
Sun, 26 Jan 2014 10:44:27 +0000 (11:44 +0100)
committerRoger Meier <roger@apache.org>
Sun, 26 Jan 2014 10:44:27 +0000 (11:44 +0100)
Patch: Pierre Lamot

further modifications by Roger Meier
- git mv instead of delete and add
- detect node or nodejs with configure.ac
- use exit instead of return within lib/nodejs/test/testAll.sh

26 files changed:
.gitignore
configure.ac
lib/Makefile.am
lib/nodejs/Makefile.am [new file with mode: 0755]
lib/nodejs/package.json
lib/nodejs/test/client.js [moved from test/nodejs/client.js with 57% similarity]
lib/nodejs/test/multiplex_client.js [moved from test/nodejs/multiplex_client.js with 91% similarity]
lib/nodejs/test/multiplex_server.js [new file with mode: 0644]
lib/nodejs/test/server.js [moved from test/nodejs/server.js with 51% similarity]
lib/nodejs/test/server_http.js [moved from test/nodejs/server_http.js with 100% similarity]
lib/nodejs/test/test.html [moved from test/nodejs/test.html with 100% similarity]
lib/nodejs/test/test.js [moved from test/nodejs/test.js with 100% similarity]
lib/nodejs/test/testAll.sh [new file with mode: 0755]
lib/nodejs/test/test_handler.js [moved from test/nodejs/test_handler.js with 100% similarity]
lib/nodejs/test/thrift_test_driver.js [moved from test/nodejs/thrift_test_driver.js with 100% similarity]
test/Makefile.am
test/nodejs/Makefile.am [deleted file]
test/nodejs/client_bin.js [deleted file]
test/nodejs/client_json.js [deleted file]
test/nodejs/client_json_frame.js [deleted file]
test/nodejs/multiplex_server.js [deleted file]
test/nodejs/package.json [deleted file]
test/nodejs/server_bin.js [deleted file]
test/nodejs/server_json.js [deleted file]
test/nodejs/server_json_frame.js [deleted file]
test/test.sh

index 3f95581..9755012 100644 (file)
@@ -188,6 +188,9 @@ gen-*
 /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
index 7d9a82e..b2577dd 100755 (executable)
@@ -178,6 +178,18 @@ if test "$with_erlang" = "yes";  then
 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,, :)
@@ -547,7 +559,7 @@ AC_CONFIG_HEADERS(lib/cpp/src/thrift/config.h:config.hin)
 # gruard against pre defined config.h
 AH_TOP([
 #ifndef CONFIG_H
-#define CONFIG_H 
+#define CONFIG_H
 ])
 AH_BOTTOM([
 #endif
@@ -578,6 +590,7 @@ AC_CONFIG_FILES([
   lib/hs/Makefile
   lib/java/Makefile
   lib/js/test/Makefile
+  lib/nodejs/Makefile
   lib/perl/Makefile
   lib/perl/test/Makefile
   lib/php/Makefile
@@ -587,7 +600,6 @@ AC_CONFIG_FILES([
   test/Makefile
   test/cpp/Makefile
   test/hs/Makefile
-  test/nodejs/Makefile
   test/php/Makefile
   test/perl/Makefile
   test/py/Makefile
@@ -623,6 +635,7 @@ echo "Building PHP Library ......... : $have_php"
 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
@@ -687,6 +700,12 @@ if test "$have_d" = "yes" ; then
   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"
index 1cc5c6c..26d9020 100644 (file)
@@ -70,6 +70,11 @@ if WITH_D
 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 = \
@@ -79,6 +84,5 @@ EXTRA_DIST = \
                        delphi \
                        javame \
                        js \
-                       nodejs \
                        ocaml \
                        st
diff --git a/lib/nodejs/Makefile.am b/lib/nodejs/Makefile.am
new file mode 100755 (executable)
index 0000000..5e298d4
--- /dev/null
@@ -0,0 +1,31 @@
+# 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
index 668c58d..b2b92d6 100755 (executable)
     "nodeunit": "~0.8.0"
   },
   "devDependencies": {
-    "connect": "2.7.x"
+    "connect": "2.7.x",
+    "commander": "2.1.x"
+  },
+  "scripts": {
+    "test" : "test/testAll.sh"
   }
 }
similarity index 57%
rename from test/nodejs/client.js
rename to lib/nodejs/test/client.js
index d70ec0c..e7d6e61 100644 (file)
 
 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) {
@@ -42,4 +75,3 @@ ThriftTestDriver(client, function (status) {
 
 // to make it also run on expresso
 exports.expressoTest = function() {};
-
similarity index 91%
rename from test/nodejs/multiplex_client.js
rename to lib/nodejs/test/multiplex_client.js
index ba0d47b..6cf6975 100644 (file)
  * 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();
diff --git a/lib/nodejs/test/multiplex_server.js b/lib/nodejs/test/multiplex_server.js
new file mode 100644 (file)
index 0000000..a2a1709
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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);
similarity index 51%
rename from test/nodejs/server.js
rename to lib/nodejs/test/server.js
index 78a21c6..da9a4d6 100644 (file)
 //    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);
similarity index 100%
rename from test/nodejs/test.js
rename to lib/nodejs/test/test.js
diff --git a/lib/nodejs/test/testAll.sh b/lib/nodejs/test/testAll.sh
new file mode 100755 (executable)
index 0000000..3e64393
--- /dev/null
@@ -0,0 +1,73 @@
+#! /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
index 175f477..2d44229 100755 (executable)
@@ -17,7 +17,7 @@
 # under the License.
 #
 
-SUBDIRS = nodejs
+SUBDIRS =
 
 if WITH_CPP
 SUBDIRS += cpp
@@ -55,7 +55,6 @@ EXTRA_DIST = \
        test.sh \
        cpp \
        hs \
-       nodejs \
        ocaml \
        perl \
        php \
diff --git a/test/nodejs/Makefile.am b/test/nodejs/Makefile.am
deleted file mode 100755 (executable)
index 39a7237..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-# 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
diff --git a/test/nodejs/client_bin.js b/test/nodejs/client_bin.js
deleted file mode 100644 (file)
index d077202..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*\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
diff --git a/test/nodejs/client_json.js b/test/nodejs/client_json.js
deleted file mode 100644 (file)
index de0190f..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*\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
diff --git a/test/nodejs/client_json_frame.js b/test/nodejs/client_json_frame.js
deleted file mode 100644 (file)
index f23ddd4..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*\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
diff --git a/test/nodejs/multiplex_server.js b/test/nodejs/multiplex_server.js
deleted file mode 100644 (file)
index 6b2d7d3..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * 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);
diff --git a/test/nodejs/package.json b/test/nodejs/package.json
deleted file mode 100755 (executable)
index 85adef1..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-{
-  "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" }
-}
diff --git a/test/nodejs/server_bin.js b/test/nodejs/server_bin.js
deleted file mode 100644 (file)
index ba84449..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*\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
diff --git a/test/nodejs/server_json.js b/test/nodejs/server_json.js
deleted file mode 100644 (file)
index 406c982..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*\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
diff --git a/test/nodejs/server_json_frame.js b/test/nodejs/server_json_frame.js
deleted file mode 100644 (file)
index 828063a..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*\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
index 520a632..5170e13 100755 (executable)
@@ -101,6 +101,9 @@ cpp_sockets="ip domain"
 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
 
@@ -170,6 +173,34 @@ for proto in $(intersection "${cpp_protocols}" "${java_protocols}"); do
   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
 
@@ -221,18 +252,6 @@ do_test "php-cpp"  "binary" "buffered-ip" \
         "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" \