blob: 3e64393818b3b1728c8e4e4e21ca6f2c9f9e682d [file] [log] [blame]
Roger Meier8909cbd2014-01-26 11:44:27 +01001#! /bin/sh
2
3#
4# Licensed to the Apache Software Foundation (ASF) under one
5# or more contributor license agreements. See the NOTICE file
6# distributed with this work for additional information
7# regarding copyright ownership. The ASF licenses this file
8# to you under the Apache License, Version 2.0 (the
9# "License"); you may not use this file except in compliance
10# with the License. You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing,
15# software distributed under the License is distributed on an
16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17# KIND, either express or implied. See the License for the
18# specific language governing permissions and limitations
19# under the License.
20#
21
22DIR="$( cd "$( dirname "$0" )" && pwd )"
23
24export NODE_PATH="${DIR}:${DIR}/../lib:${NODE_PATH}"
25
26testClientServer()
27{
28 echo " Testing Client/Server with protocol $1 and transport $2";
29 RET=0
30 node ${DIR}/server.js -p $1 -t $2 &
31 SERVERPID=$!
32 sleep 1
33 node ${DIR}/client.js -p $1 -t $2 || RET=1
34 kill -9 $SERVERPID || RET=1
35 return $RET
36}
37
38testMultiplexedClientServer()
39{
40 echo " Testing Multiplexed Client/Server with protocol $1 and transport $2";
41 RET=0
42 node ${DIR}/multiplex_server.js -p $1 -t $2 &
43 SERVERPID=$!
44 sleep 1
45 node ${DIR}/multiplex_client.js -p $1 -t $2 || RET=1
46 kill -9 $SERVERPID || RET=1 #f
47 return $RET
48}
49
50
51TESTOK=0
52
53#generating thrift code
54
55${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/ThriftTest.thrift
56
57#unit tests
58
59node ${DIR}/binary.test.js || TESTOK=1
60
61#integration tests
62
63testClientServer binary buffered || TESTOK=1
64testClientServer json buffered || TESTOK=1
65testClientServer binary framed || TESTOK=1
66testClientServer json framed || TESTOK=1
67
68testMultiplexedClientServer binary buffered || TESTOK=1
69testMultiplexedClientServer json buffered || TESTOK=1
70testMultiplexedClientServer binary framed || TESTOK=1
71testMultiplexedClientServer json framed || TESTOK=1
72
73exit $TESTOK