Add stress test implementation for new Erlang


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666389 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/erl/Makefile b/test/erl/Makefile
index 8bffb62..d85371e 100644
--- a/test/erl/Makefile
+++ b/test/erl/Makefile
@@ -10,7 +10,7 @@
 ALL_INCLUDEDIR=$(GEN_INCLUDEDIR) $(INCLUDEDIR) ../../lib/erl/include
 INCLUDEFLAGS=$(patsubst %,-I%, ${ALL_INCLUDEDIR})
 
-MODULES = test_server
+MODULES = stress_server test_server
 
 INCLUDES = 
 TARGETS = $(patsubst %,${TARGETDIR}/%.beam,${MODULES})
@@ -18,12 +18,14 @@
 
 all: ${GEN_TARGETDIR}/ ${TARGETS}
 
-RPCFILE = ../ThriftTest.thrift
+TEST_RPCFILE = ../ThriftTest.thrift
+STRESS_RPCFILE = ../StressTest.thrift
 THRIFT = ../../compiler/cpp/thrift
 
 ${GENDIR}/: ${RPCFILE}
 	rm -rf ${GENDIR}
-	${THRIFT} -alterl ${RPCFILE}
+	${THRIFT} -alterl ${TEST_RPCFILE}
+	${THRIFT} -alterl ${STRESS_RPCFILE}
 	mkdir -p ${GEN_INCLUDEDIR}
 	mkdir -p ${GEN_SRCDIR}
 	mkdir -p ${GEN_TARGETDIR}
diff --git a/test/erl/src/stress_server.erl b/test/erl/src/stress_server.erl
new file mode 100644
index 0000000..915b027
--- /dev/null
+++ b/test/erl/src/stress_server.erl
@@ -0,0 +1,64 @@
+-module(stress_server).
+
+-include("thrift.hrl").
+
+-export([start_link/1, old_start_link/1,
+
+         handle_function/2,
+
+         echoVoid/0,
+         echoByte/1,
+         echoI32/1,
+         echoI64/1,
+         echoString/1,
+         echoList/1,
+         echoSet/1,
+         echoMap/1
+        ]).
+
+start_link(Port) ->
+    thrift_server:start_link(Port, service_thrift, ?MODULE).
+
+% Start the server with the old style bindings
+old_start_link(Port) ->
+    Handler   = ?MODULE,
+    Processor = service_thrift,
+
+    TF = tBufferedTransportFactory:new(),
+    PF = tBinaryProtocolFactory:new(),
+
+    ServerTransport = tErlAcceptor,
+    ServerFlavor    = tErlServer,
+
+    Server = oop:start_new(ServerFlavor, [Port, Handler, Processor, ServerTransport, TF, PF]),
+
+    case ?R0(Server, effectful_serve) of
+	ok    -> Server;
+	Error -> Error
+    end.
+    
+
+handle_function(Function, Args) ->
+    case apply(?MODULE, Function, tuple_to_list(Args)) of
+        ok ->
+             ok;
+        Else -> {reply, Else}
+    end.
+
+
+echoVoid() ->
+    ok.
+echoByte(X) ->
+    X.
+echoI32(X) ->
+    X.
+echoI64(X) ->
+    X.
+echoString(X) ->
+    X.
+echoList(X) ->
+    X.
+echoSet(X) ->
+    X.
+echoMap(X) ->
+    X.