ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/fbintf/testsuite/Test11.pas
(Generate patch)

Comparing ibx/trunk/fbintf/testsuite/Test11.pas (file contents):
Revision 45 by tony, Tue Dec 6 10:33:46 2016 UTC vs.
Revision 308 by tony, Sat Jul 18 10:26:30 2020 UTC

# Line 1 | Line 1
1   unit Test11;
2 + {$IFDEF MSWINDOWS}
3 + {$DEFINE WINDOWS}
4 + {$ENDIF}
5  
6 < {$mode objfpc}{$H+}
6 > {$IFDEF FPC}
7 > {$mode delphi}
8   {$codepage utf8}
9 + {$ENDIF}
10  
11   {Test 11: Services API}
12  
# Line 33 | Line 38 | type
38  
39    TTest11 = class(TTestBase)
40    private
41 <    procedure GetStatistics(Service: IServiceManager; DBName: string);
42 <    procedure BackupRestore(Service: IServiceManager; DBName: string);
41 >    procedure GetStatistics(Service: IServiceManager; DBName: AnsiString);
42 >    procedure BackupRestore(Service: IServiceManager; DBName: AnsiString);
43    public
44 <    function TestTitle: string; override;
45 <    procedure RunTest(CharSet: string; SQLDialect: integer); override;
44 >    function TestTitle: AnsiString; override;
45 >    procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override;
46    end;
47  
48   implementation
49  
50   { TTest11 }
51  
52 < procedure TTest11.GetStatistics(Service: IServiceManager; DBName: string);
52 > procedure TTest11.GetStatistics(Service: IServiceManager; DBName: AnsiString);
53   var Req: ISRB;
54      Results: IServiceQueryResults;
55   begin
# Line 158 | Line 163 | begin
163    writeln(OutFile);
164   end;
165  
166 < procedure TTest11.BackupRestore(Service: IServiceManager; DBName: string);
166 > procedure TTest11.BackupRestore(Service: IServiceManager; DBName: AnsiString);
167   var Req: ISRB;
168      Results: IServiceQueryResults;
169      BakFile: TFileStream;
# Line 168 | Line 173 | var Req: ISRB;
173      bytesWritten: integer;
174      bytesAvailable: integer;
175      i: integer;
176 <    RestoreDBName: string;
176 >    RestoreDBName: AnsiString;
177      Attachment: IAttachment;
178      DPB: IDPB;
179   begin
# Line 191 | Line 196 | begin
196          QueryResultsItem := Results.Find(isc_info_svc_to_eof);
197          if QueryResultsItem <> nil then
198            bytesWritten := QueryResultsItem.CopyTo(BakFile,0);
199 <      until (bytesWritten = 0) or not WriteServiceQueryResult(Results);
199 >      until ((bytesWritten = 0) and (Results.Find(isc_info_svc_timeout) = nil))
200 >        or not WriteServiceQueryResult(Results);
201        writeln(OutFile,'Local Backup Complete');
202      finally
203        BakFile.Free;
# Line 203 | Line 209 | begin
209  
210    {Local Restore}
211    writeln(OutFile,'Local Restore');
212 <  RestoreDBName := Owner.GetNewDatabaseName;
212 >  RestoreDBName := ExtractDBName(Owner.GetNewDatabaseName);
213    i := Pos(':',RestoreDBName);
214    if i > 0 then
215      system.Delete(RestoreDBName,1,i);
# Line 224 | Line 230 | begin
230          SQPB := Service.AllocateSQPB;
231          if ReqLength > 0 then
232              bytesWritten := SQPB.Add(isc_info_svc_line).CopyFrom(BakFile,ReqLength);
233 <        bytesAvailable -= bytesWritten;
233 >        bytesAvailable := bytesAvailable - bytesWritten;
234          Req := Service.AllocateSRB;
235          Req.Add(isc_info_svc_stdin);
236          Req.Add(isc_info_svc_line);
# Line 253 | Line 259 | begin
259    writeln(OutFile,'Database Dropped');
260   end;
261  
262 < function TTest11.TestTitle: string;
262 > function TTest11.TestTitle: AnsiString;
263   begin
264    Result := 'Test 11: Services API';
265   end;
266  
267 < procedure TTest11.RunTest(CharSet: string; SQLDialect: integer);
267 > procedure TTest11.RunTest(CharSet: AnsiString; SQLDialect: integer);
268   var SPB: ISPB;
269      Service: IServiceManager;
270 <    I: integer;
271 <    ServerName: string;
266 <    DBName: string;
270 >    ServerName: AnsiString;
271 >    DBName: AnsiString;
272   begin
273    if not FirebirdAPI.HasServiceAPI then Exit;
274  
275 <  ServerName := Owner.GetEmployeeDatabaseName;
276 <  I := Pos(':',ServerName);
272 <  if i > 0 then
273 <    DBName := system.copy(ServerName,i+1,length(ServerName) - 2);
274 <  system.Delete(ServerName,i,Length(ServerName)-i+1);
275 >  DBName := ExtractDBName(Owner.GetEmployeeDatabaseName);
276 >  ServerName := Owner.Server;
277  
278    SPB := FirebirdAPI.AllocateSPB;
279    SPB.Add(isc_spb_user_name).setAsString(Owner.GetUserName);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines