diff --git a/wst/trunk/service_intf.pas b/wst/trunk/service_intf.pas
index 5953f1295..eb516eaea 100644
--- a/wst/trunk/service_intf.pas
+++ b/wst/trunk/service_intf.pas
@@ -152,7 +152,7 @@ Type
function GetTransportRegistry():ITransportRegistry;
implementation
-uses imp_utils, metadata_repository;
+uses wst_consts,imp_utils, metadata_repository;
{ TBaseProxy }
@@ -303,10 +303,15 @@ constructor TBaseProxy.Create(
const AProtocol : IServiceProtocol
);
begin
- Assert(Assigned(AProtocol));
- Assert(Assigned(AProtocol.GetCallHandler()));
- Assert(Assigned(AProtocol.GetSerializer()));
- Assert(Assigned(AProtocol.GetTransport()));
+ if ( AProtocol = nil ) then
+ raise EServiceConfigException.CreateFmt(SERR_InvalidParameter,['AProtocol']);
+ if ( AProtocol.GetCallHandler() = nil ) then
+ 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;
FTarget := ATarget;
FProtocol := AProtocol;
@@ -315,21 +320,21 @@ begin
end;
constructor TBaseProxy.Create(
- const ATarget: String;
+ const ATarget: string;
const AProtocolData: string;
const ATransportData: string
);
-Var
+var
ptcl : IServiceProtocol;
tmpTrprt : ITransport;
begin
- ptcl := Nil;
- If GetFormaterRegistry().Find(AProtocolData,ptcl) And
- GetTransportRegistry().Find(ATransportData,tmpTrprt)
- Then Begin
- ptcl.SetTransport(tmpTrprt);
- Create(ATarget,ptcl);
- End;
+ if not GetFormaterRegistry().Find(AProtocolData,ptcl) then
+ raise EServiceConfigException.CreateFmt(SERR_InvalidParameter,['AProtocolData']);
+ if not GetTransportRegistry().Find(ATransportData,tmpTrprt) then
+ raise EServiceConfigException.CreateFmt(SERR_InvalidParameter,['ATransportData']);
+
+ ptcl.SetTransport(tmpTrprt);
+ Create(ATarget,ptcl);
end;
destructor TBaseProxy.Destroy();
diff --git a/wst/trunk/tests/test_suite/test_support_client.pas b/wst/trunk/tests/test_suite/test_support_client.pas
new file mode 100644
index 000000000..fffa0334d
--- /dev/null
+++ b/wst/trunk/tests/test_suite/test_support_client.pas
@@ -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.
+
diff --git a/wst/trunk/tests/test_suite/wst_test_suite_gui.lpi b/wst/trunk/tests/test_suite/wst_test_suite_gui.lpi
index 9235163b9..1deab770f 100644
--- a/wst/trunk/tests/test_suite/wst_test_suite_gui.lpi
+++ b/wst/trunk/tests/test_suite/wst_test_suite_gui.lpi
@@ -37,7 +37,7 @@
-
+
@@ -138,6 +138,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/wst/trunk/tests/test_suite/wst_test_suite_gui.lpr b/wst/trunk/tests/test_suite/wst_test_suite_gui.lpr
index 329956cef..2bff07a5d 100644
--- a/wst/trunk/tests/test_suite/wst_test_suite_gui.lpr
+++ b/wst/trunk/tests/test_suite/wst_test_suite_gui.lpr
@@ -18,7 +18,8 @@ uses
test_basex_encode, json_formatter, server_service_json, test_json,
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_generators_runtime, test_date_utils, config_objects;
+ test_generators_runtime, test_date_utils, config_objects, test_support_client,
+ wst_consts;
begin
Application.Initialize;