THRIFT-5012 Centralize configuration aspects into a commonly used configuration object [ci skip]
Client: Delphi
Patch: Jens Geyer
This closes #1955
diff --git a/lib/delphi/test/TestClient.pas b/lib/delphi/test/TestClient.pas
index 3562dab..1579bd5 100644
--- a/lib/delphi/test/TestClient.pas
+++ b/lib/delphi/test/TestClient.pas
@@ -53,6 +53,8 @@
Thrift.Test,
Thrift.WinHTTP,
Thrift.Utils,
+
+ Thrift.Configuration,
Thrift.Collections;
type
@@ -122,7 +124,7 @@
procedure InitializeProtocolTransportStack;
procedure ShutdownProtocolTransportStack;
- function InitializeHttpTransport( const aTimeoutSetting : Integer) : IHTTPClient;
+ function InitializeHttpTransport( const aTimeoutSetting : Integer; const aConfig : IThriftConfiguration = nil) : IHTTPClient;
procedure JSONProtocolReadWriteTest;
function PrepareBinaryData( aRandomDist : Boolean; aSize : TTestSize) : TBytes;
@@ -1068,6 +1070,7 @@
var prot : IProtocol;
stm : TStringStream;
list : TThriftList;
+ config : IThriftConfiguration;
binary, binRead, emptyBinary : TBytes;
i,iErr : Integer;
const
@@ -1089,6 +1092,8 @@
try
StartTestGroup( 'JsonProtocolTest', test_Unknown);
+ config := TThriftConfigurationImpl.Create;
+
// prepare binary data
binary := PrepareBinaryData( FALSE, Normal);
SetLength( emptyBinary, 0); // empty binary data block
@@ -1096,7 +1101,7 @@
// output setup
prot := TJSONProtocolImpl.Create(
TStreamTransportImpl.Create(
- nil, TThriftStreamAdapterDelphi.Create( stm, FALSE)));
+ nil, TThriftStreamAdapterDelphi.Create( stm, FALSE), config));
// write
Init( list, TType.String_, 9);
@@ -1119,7 +1124,7 @@
stm.Position := 0;
prot := TJSONProtocolImpl.Create(
TStreamTransportImpl.Create(
- TThriftStreamAdapterDelphi.Create( stm, FALSE), nil));
+ TThriftStreamAdapterDelphi.Create( stm, FALSE), nil, config));
// read and compare
list := prot.ReadListBegin;
@@ -1161,7 +1166,7 @@
stm.Position := 0;
prot := TJSONProtocolImpl.Create(
TStreamTransportImpl.Create(
- TThriftStreamAdapterDelphi.Create( stm, FALSE), nil));
+ TThriftStreamAdapterDelphi.Create( stm, FALSE), nil, config));
Expect( prot.ReadString = SOLIDUS_EXCPECTED, 'Solidus encoding');
@@ -1172,12 +1177,12 @@
stm.Size := 0;
prot := TJSONProtocolImpl.Create(
TStreamTransportImpl.Create(
- nil, TThriftStreamAdapterDelphi.Create( stm, FALSE)));
+ nil, TThriftStreamAdapterDelphi.Create( stm, FALSE), config));
prot.WriteString( G_CLEF_AND_CYRILLIC_TEXT);
stm.Position := 0;
prot := TJSONProtocolImpl.Create(
TStreamTransportImpl.Create(
- TThriftStreamAdapterDelphi.Create( stm, FALSE), nil));
+ TThriftStreamAdapterDelphi.Create( stm, FALSE), nil, config));
Expect( prot.ReadString = G_CLEF_AND_CYRILLIC_TEXT, 'Writing JSON with chars > 8 bit');
// Widechars should work with hex-encoding too. Do they?
@@ -1187,7 +1192,7 @@
stm.Position := 0;
prot := TJSONProtocolImpl.Create(
TStreamTransportImpl.Create(
- TThriftStreamAdapterDelphi.Create( stm, FALSE), nil));
+ TThriftStreamAdapterDelphi.Create( stm, FALSE), nil, config));
Expect( prot.ReadString = G_CLEF_AND_CYRILLIC_TEXT, 'Reading JSON with chars > 8 bit');
@@ -1330,7 +1335,7 @@
end;
-function TClientThread.InitializeHttpTransport( const aTimeoutSetting : Integer) : IHTTPClient;
+function TClientThread.InitializeHttpTransport( const aTimeoutSetting : Integer; const aConfig : IThriftConfiguration) : IHTTPClient;
var sUrl : string;
comps : URL_COMPONENTS;
dwChars : DWORD;
@@ -1367,8 +1372,8 @@
Console.WriteLine('Target URL: '+sUrl);
case FSetup.endpoint of
- trns_MsxmlHttp : result := TMsxmlHTTPClientImpl.Create( sUrl);
- trns_WinHttp : result := TWinHTTPClientImpl.Create( sUrl);
+ trns_MsxmlHttp : result := TMsxmlHTTPClientImpl.Create( sUrl, aConfig);
+ trns_WinHttp : result := TWinHTTPClientImpl.Create( sUrl, aConfig);
else
raise Exception.Create(ENDPOINT_TRANSPORTS[FSetup.endpoint]+' unhandled case');
end;
@@ -1396,7 +1401,7 @@
case FSetup.endpoint of
trns_Sockets: begin
Console.WriteLine('Using sockets ('+FSetup.host+' port '+IntToStr(FSetup.port)+')');
- streamtrans := TSocketImpl.Create( FSetup.host, FSetup.port, DEFAULT_THRIFT_TIMEOUT);
+ streamtrans := TSocketImpl.Create( FSetup.host, FSetup.port);
FTransport := streamtrans;
end;
@@ -1417,7 +1422,7 @@
end;
trns_AnonPipes: begin
- streamtrans := TAnonymousPipeTransportImpl.Create( FSetup.hAnonRead, FSetup.hAnonWrite, FALSE);
+ streamtrans := TAnonymousPipeTransportImpl.Create( FSetup.hAnonRead, FSetup.hAnonWrite, FALSE, PIPE_TIMEOUT);
FTransport := streamtrans;
end;