You've already forked lazarus-ccr
Check TBaseProxy.Create() parameters for valid input + tests
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@787 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -152,7 +152,7 @@ Type
|
|||||||
function GetTransportRegistry():ITransportRegistry;
|
function GetTransportRegistry():ITransportRegistry;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses imp_utils, metadata_repository;
|
uses wst_consts,imp_utils, metadata_repository;
|
||||||
|
|
||||||
{ TBaseProxy }
|
{ TBaseProxy }
|
||||||
|
|
||||||
@@ -303,10 +303,15 @@ constructor TBaseProxy.Create(
|
|||||||
const AProtocol : IServiceProtocol
|
const AProtocol : IServiceProtocol
|
||||||
);
|
);
|
||||||
begin
|
begin
|
||||||
Assert(Assigned(AProtocol));
|
if ( AProtocol = nil ) then
|
||||||
Assert(Assigned(AProtocol.GetCallHandler()));
|
raise EServiceConfigException.CreateFmt(SERR_InvalidParameter,['AProtocol']);
|
||||||
Assert(Assigned(AProtocol.GetSerializer()));
|
if ( AProtocol.GetCallHandler() = nil ) then
|
||||||
Assert(Assigned(AProtocol.GetTransport()));
|
raise EServiceConfigException.CreateFmt(SERR_InvalidParameter,['AProtocol.GetCallHandler()']);
|
||||||
|
if ( AProtocol.GetSerializer() = nil ) then
|
||||||
|
raise EServiceConfigException.CreateFmt(SERR_InvalidParameter,['AProtocol.GetSerializer()']);
|
||||||
|
if ( AProtocol.GetTransport() = nil ) then
|
||||||
|
raise EServiceConfigException.CreateFmt(SERR_InvalidParameter,['AProtocol.GetTransport()']);
|
||||||
|
|
||||||
FCallContext := TSimpleCallContext.Create() as ICallContext;
|
FCallContext := TSimpleCallContext.Create() as ICallContext;
|
||||||
FTarget := ATarget;
|
FTarget := ATarget;
|
||||||
FProtocol := AProtocol;
|
FProtocol := AProtocol;
|
||||||
@@ -315,21 +320,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TBaseProxy.Create(
|
constructor TBaseProxy.Create(
|
||||||
const ATarget: String;
|
const ATarget: string;
|
||||||
const AProtocolData: string;
|
const AProtocolData: string;
|
||||||
const ATransportData: string
|
const ATransportData: string
|
||||||
);
|
);
|
||||||
Var
|
var
|
||||||
ptcl : IServiceProtocol;
|
ptcl : IServiceProtocol;
|
||||||
tmpTrprt : ITransport;
|
tmpTrprt : ITransport;
|
||||||
begin
|
begin
|
||||||
ptcl := Nil;
|
if not GetFormaterRegistry().Find(AProtocolData,ptcl) then
|
||||||
If GetFormaterRegistry().Find(AProtocolData,ptcl) And
|
raise EServiceConfigException.CreateFmt(SERR_InvalidParameter,['AProtocolData']);
|
||||||
GetTransportRegistry().Find(ATransportData,tmpTrprt)
|
if not GetTransportRegistry().Find(ATransportData,tmpTrprt) then
|
||||||
Then Begin
|
raise EServiceConfigException.CreateFmt(SERR_InvalidParameter,['ATransportData']);
|
||||||
ptcl.SetTransport(tmpTrprt);
|
|
||||||
Create(ATarget,ptcl);
|
ptcl.SetTransport(tmpTrprt);
|
||||||
End;
|
Create(ATarget,ptcl);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TBaseProxy.Destroy();
|
destructor TBaseProxy.Destroy();
|
||||||
|
101
wst/trunk/tests/test_suite/test_support_client.pas
Normal file
101
wst/trunk/tests/test_suite/test_support_client.pas
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
{ This file is part of the Web Service Toolkit
|
||||||
|
Copyright (c) 2006, 2007, 2008, 2009 by Inoussa OUEDRAOGO
|
||||||
|
|
||||||
|
This file is provide under modified LGPL licence
|
||||||
|
( the files COPYING.modifiedLGPL and COPYING.LGPL).
|
||||||
|
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
}
|
||||||
|
{$INCLUDE wst_global.inc}
|
||||||
|
unit test_support_client;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils,
|
||||||
|
{$IFDEF FPC}
|
||||||
|
fpcunit, testregistry,
|
||||||
|
{$ELSE}
|
||||||
|
TestFrameWork,
|
||||||
|
{$ENDIF}
|
||||||
|
TypInfo,
|
||||||
|
wst_types, base_service_intf, imp_utils, test_suite_utils, service_intf;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TTest_TBaseProxy }
|
||||||
|
|
||||||
|
TTest_TBaseProxy = class(TWstBaseTest)
|
||||||
|
published
|
||||||
|
procedure test_CreateWithInvalidParameters_AProtocol();
|
||||||
|
procedure test_CreateWithInvalidParameters_AProtocolData();
|
||||||
|
procedure test_CreateWithInvalidParameters_ATransportData();
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
uses
|
||||||
|
//Include this so we are sure to have a valid transport protocol registered
|
||||||
|
same_process_protocol,
|
||||||
|
//Include this so we are sure to have a valid serialization protocol registered
|
||||||
|
binary_formatter;
|
||||||
|
|
||||||
|
const
|
||||||
|
s_target_service = 'SampleService';
|
||||||
|
|
||||||
|
{ TTest_TBaseProxy }
|
||||||
|
|
||||||
|
procedure TTest_TBaseProxy.test_CreateWithInvalidParameters_AProtocol();
|
||||||
|
var
|
||||||
|
ok : Boolean;
|
||||||
|
sp : IServiceProtocol;
|
||||||
|
begin
|
||||||
|
ok := False;
|
||||||
|
try
|
||||||
|
sp := nil;
|
||||||
|
TBaseProxy.Create(s_target_service,sp);
|
||||||
|
except
|
||||||
|
ok := True;
|
||||||
|
end;
|
||||||
|
Check(ok);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTest_TBaseProxy.test_CreateWithInvalidParameters_AProtocolData();
|
||||||
|
var
|
||||||
|
ok : Boolean;
|
||||||
|
sp : IServiceProtocol;
|
||||||
|
begin
|
||||||
|
ok := False;
|
||||||
|
try
|
||||||
|
sp := nil;
|
||||||
|
TBaseProxy.Create(s_target_service,'NILPROTOCOL:nil_prop=nilvalue','SAME_PROCESS:');
|
||||||
|
except
|
||||||
|
ok := True;
|
||||||
|
end;
|
||||||
|
Check(ok);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTest_TBaseProxy.test_CreateWithInvalidParameters_ATransportData();
|
||||||
|
var
|
||||||
|
ok : Boolean;
|
||||||
|
sp : IServiceProtocol;
|
||||||
|
begin
|
||||||
|
ok := False;
|
||||||
|
try
|
||||||
|
sp := nil;
|
||||||
|
TBaseProxy.Create(s_target_service,'binary:','NILPROTOCOL:');
|
||||||
|
except
|
||||||
|
ok := True;
|
||||||
|
end;
|
||||||
|
Check(ok);
|
||||||
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
SAME_PROCESS_Register_Local_Transport();
|
||||||
|
|
||||||
|
RegisterTest('Support-Client',TTest_TBaseProxy.Suite);
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
@@ -37,7 +37,7 @@
|
|||||||
<PackageName Value="fpcunittestrunner"/>
|
<PackageName Value="fpcunittestrunner"/>
|
||||||
</Item3>
|
</Item3>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="20">
|
<Units Count="22">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="wst_test_suite_gui.lpr"/>
|
<Filename Value="wst_test_suite_gui.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
@@ -138,6 +138,16 @@
|
|||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="config_objects"/>
|
<UnitName Value="config_objects"/>
|
||||||
</Unit19>
|
</Unit19>
|
||||||
|
<Unit20>
|
||||||
|
<Filename Value="test_support_client.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="test_support_client"/>
|
||||||
|
</Unit20>
|
||||||
|
<Unit21>
|
||||||
|
<Filename Value="..\..\wst_consts.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="wst_consts"/>
|
||||||
|
</Unit21>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
|
@@ -18,7 +18,8 @@ uses
|
|||||||
test_basex_encode, json_formatter, server_service_json, test_json,
|
test_basex_encode, json_formatter, server_service_json, test_json,
|
||||||
test_suite_utils, test_generators, fpcunittestrunner, test_std_cursors,
|
test_suite_utils, test_generators, fpcunittestrunner, test_std_cursors,
|
||||||
test_rtti_filter, rtti_filters, wst_cursors, test_wst_cursors, test_registry, test_soap_specific,
|
test_rtti_filter, rtti_filters, wst_cursors, test_wst_cursors, test_registry, test_soap_specific,
|
||||||
test_generators_runtime, test_date_utils, config_objects;
|
test_generators_runtime, test_date_utils, config_objects, test_support_client,
|
||||||
|
wst_consts;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Application.Initialize;
|
Application.Initialize;
|
||||||
|
Reference in New Issue
Block a user