Kbase P113879: How to test the use of an AppServer with separate client side and server side code?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  1/6/2011 |
|
Status: Verified
GOAL:
How to test the use of an AppServer with separate client side and server side code?
GOAL:
How to test the basic functionality of an AppServer?
GOAL:
How to test the AppServer with simple distributed application?
FIX:
The following is sample code that can be used with a copy of the Progress sports2000 database or adjusted as needed to work with any database. You can change this code, change the connection information, place pauses in the code, run while the database or AppServer is down, and test with as many other scenarios and you can fathom.
1. Client part:
/*cust.p*/
/*Use a copy of our sample database, sports2000*/
/*client side part of application*/
DEFINE VARIABLE hAppSrv AS HANDLE NO-UNDO.
DEFINE VARIABLE ret AS LOGICAL NO-UNDO.
DEFINE VARIABLE NAME AS CHAR FORMAT "X(30)" NO-UNDO.
/*Create AppServer handle*/
CREATE SERVER hAppSrv.
/*Connect to AppServer*/
ret = hAppSrv:CONNECT("-S 5162 -H XXXX -App AppLab","","").
/*The -H = host where the NameServer resides (and is running).
The -S = NameServer Port (by default the port is 5162).
You do not need the -N. The -App = specific AppServer name (case sensitive).
This can be left off completely since it goes to the default AppServer
if one exists.*/
/*Error checking, in case connect failed*/
IF NOT ret THEN RETURN ERROR "Failed to connect to AppServer".
/*Run custname.p on the AppServer*/
RUN custname.p ON hAppSrv (INPUT 84, OUTPUT NAME).
/*Display the results*/
DISPLAY NAME.
/*Disconnect from the AppServer*/
ret = hAppSrv:DISCONNECT().
/*Delete the AppServer handle*/
DELETE OBJECT hAppSrv.
2. Server side part of the application:
/*custname.p*/
/*This code needs to be accessible by the AppServer*/
DEFINE INPUT PARAMETER piCustNum AS INTEGER NO-UNDO.
DEFINE OUTPUT PARAMETER poName AS CHAR NO-UNDO.
FIND FIRST Customer NO-LOCK WHERE
Customer.custnum = piCustNum NO-ERROR.
IF AVAILABLE Customer THEN
poName = Customer.NAME