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/serializer/TestSerializer.Tests.pas b/lib/delphi/test/serializer/TestSerializer.Tests.pas
index fe69f4e..83d67b1 100644
--- a/lib/delphi/test/serializer/TestSerializer.Tests.pas
+++ b/lib/delphi/test/serializer/TestSerializer.Tests.pas
@@ -33,6 +33,7 @@
   Thrift.Protocol.JSON,
   Thrift.Protocol.Compact,
   Thrift.Collections,
+  Thrift.Configuration,
   Thrift.Server,
   Thrift.Utils,
   Thrift.Serializer,
@@ -283,8 +284,12 @@
 
 class function TTestSerializer.Serialize(const input : IBase; const factory : TFactoryPair) : TBytes;
 var serial : TSerializer;
+    config : IThriftConfiguration;
 begin
-  serial := TSerializer.Create( factory.prot, factory.trans);
+  config := TThriftConfigurationImpl.Create;
+  config.MaxMessageSize := 0;   // we don't read anything here
+
+  serial := TSerializer.Create( factory.prot, factory.trans, config);
   try
     result := serial.Serialize( input);
   finally
@@ -295,8 +300,12 @@
 
 class procedure TTestSerializer.Serialize(const input : IBase; const factory : TFactoryPair; const aStream : TStream);
 var serial : TSerializer;
+    config : IThriftConfiguration;
 begin
-  serial := TSerializer.Create( factory.prot, factory.trans);
+  config := TThriftConfigurationImpl.Create;
+  config.MaxMessageSize := 0;   // we don't read anything here
+
+  serial := TSerializer.Create( factory.prot, factory.trans, config);
   try
     serial.Serialize( input, aStream);
   finally
@@ -307,8 +316,12 @@
 
 class procedure TTestSerializer.Deserialize( const input : TBytes; const target : IBase; const factory : TFactoryPair);
 var serial : TDeserializer;
+    config : IThriftConfiguration;
 begin
-  serial := TDeserializer.Create( factory.prot, factory.trans, Length(input));
+  config := TThriftConfigurationImpl.Create;
+  config.MaxMessageSize := Length(input);
+
+  serial := TDeserializer.Create( factory.prot, factory.trans, config);
   try
     serial.Deserialize( input, target);
     ValidateReadToEnd( input, serial);
@@ -320,8 +333,12 @@
 
 class procedure TTestSerializer.Deserialize( const input : TStream; const target : IBase; const factory : TFactoryPair);
 var serial : TDeserializer;
+    config : IThriftConfiguration;
 begin
-  serial := TDeserializer.Create( factory.prot, factory.trans, input.Size);
+  config := TThriftConfigurationImpl.Create;
+  config.MaxMessageSize := input.Size;
+
+  serial := TDeserializer.Create( factory.prot, factory.trans, config);
   try
     serial.Deserialize( input, target);
     ValidateReadToEnd( input, serial);
diff --git a/lib/delphi/test/serializer/TestSerializer.dpr b/lib/delphi/test/serializer/TestSerializer.dpr
index bb4cc89..0620014 100644
--- a/lib/delphi/test/serializer/TestSerializer.dpr
+++ b/lib/delphi/test/serializer/TestSerializer.dpr
@@ -34,6 +34,7 @@
   Thrift.Protocol.JSON in '..\..\src\Thrift.Protocol.JSON.pas',
   Thrift.Protocol.Compact in '..\..\src\Thrift.Protocol.Compact.pas',
   Thrift.Collections in '..\..\src\Thrift.Collections.pas',
+  Thrift.Configuration in '..\..\src\Thrift.Configuration.pas',
   Thrift.Server in '..\..\src\Thrift.Server.pas',
   Thrift.Utils in '..\..\src\Thrift.Utils.pas',
   Thrift.Serializer in '..\..\src\Thrift.Serializer.pas',
@@ -42,8 +43,8 @@
   Thrift.TypeRegistry in '..\..\src\Thrift.TypeRegistry.pas',
   System_,
   DebugProtoTest,
-  TestSerializer.Tests,
-  TestSerializer.Data;
+  TestSerializer.Tests in 'TestSerializer.Tests.pas',
+  TestSerializer.Data in 'TestSerializer.Data.pas';
 
 
 var test : TTestSerializer;