2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
20 unit Multiplex.Client.Main;
22 {.$DEFINE StressTest} // activate to stress-test the server with frequent connects/disconnects
23 {.$DEFINE PerfTest} // activate to activate the performance test
28 Windows, SysUtils, Classes,
33 Thrift.Protocol.Multiplex,
34 Thrift.Transport.Pipes,
38 Benchmark, // in gen-delphi folder
39 Aggr, // in gen-delphi folder
40 Multiplex.Test.Common;
45 FProtocol : IProtocol;
47 procedure ParseArgs( const args: array of string);
51 constructor Create( const args: array of string);
52 class procedure Execute( const args: array of string);
59 IServiceClient = interface
60 ['{7745C1C2-AB20-43BA-B6F0-08BF92DE0BAC}']
64 //--- TTestClient -------------------------------------
67 class procedure TTestClient.Execute( const args: array of string);
68 var client : TTestClient;
70 client := TTestClient.Create(args);
79 constructor TTestClient.Create( const args: array of string);
87 procedure TTestClient.ParseArgs( const args: array of string);
90 then raise Exception.Create('No args accepted so far');
94 procedure TTestClient.Setup;
95 var trans : ITransport;
97 trans := TSocketImpl.Create( 'localhost', 9090);
98 trans := TFramedTransportImpl.Create( trans);
100 FProtocol := TBinaryProtocolImpl.Create( trans, TRUE, TRUE);
104 procedure TTestClient.Run;
105 var bench : TBenchmarkService.Iface;
107 multiplex : IProtocol;
111 multiplex := TMultiplexedProtocol.Create( FProtocol, NAME_BENCHMARKSERVICE);
112 bench := TBenchmarkService.TClient.Create( multiplex);
114 multiplex := TMultiplexedProtocol.Create( FProtocol, NAME_AGGR);
115 aggr := TAggr.TClient.Create( multiplex);
118 do aggr.addValue( bench.fibonacci(i));
120 for i in aggr.getValues
121 do Write(IntToStr(i)+' ');
124 on e:Exception do Writeln(#10+e.Message);