Unit-test EAF dst component

In case you are a poor PB developer still working on the dead EAF framework., here is the solution to make your life a little bit funner.

Unit-test IM

Lib List:

c:\pb_projects\testApp\src\server\testApp\pb112\integration-test\im_testApp_test.pbl;
c:\pb_projects\testApp\lib\my_client.pbd;
c:\pb_projects\testApp\lib\ext_client.pbd;
c:\pb_projects\testApp\lib\eaf_client.pbd;
c:\pb_projects\testApp\lib\my_shared.pbd;
c:\pb_projects\testApp\lib\eaf_shared.pbd;
c:\pb_projects\testApp\lib\ext_shared.pbd;
c:\pb_projects\testApp\test\tools\pbunit\pbunit.pbd;
c:\pb_projects\testApp\test\tools\pbunit\pbunitfunc.pbd;
c:\pb_projects\testApp\lib\my_eaf_ext_layer_rc.pbl;
c:\pb_projects\testApp\lib\eaf_proxies.pbd;

PBUnit test code:


//instance
n_connection icn_easerver
n_cst_interfaceservice inv_is

//setup

long ll_rc

constant string INI_FILE = "app.ini"

icn_easerver = CREATE n_connection
icn_easerver.driver = "jaguar"
icn_easerver.userID = ProfileString(INI_FILE, "EAServer", "UserID", "jagadmin")
icn_easerver.password = ProfileString(INI_FILE, "EAServer", "Password", "")
icn_easerver.options = ProfileString(INI_FILE, "EAServer", "Options", "")
icn_easerver.location = ProfileString(INI_FILE, "EAServer", "Server", "")+ ":" + ProfileString(INI_FILE, "EAServer", "Port", "")

ll_rc = icn_easerver.ConnectToServer()

IF ll_rc <> 0 THEN
fail("Connection failed: " + string(ll_rc))
return
END IF

inv_is = create n_cst_interfaceservice

inv_is.of_SetRequestor(This)
ll_rc = inv_is.setConnection(icn_EAServer)

inv_is.of_setUserID("jagadmin")
ll_rc = inv_is.setInterfaceManagerName("MyPackage/MyComponent")

// test dst without arg
long ll_rc

datastore lds_target
lds_target = create datastore

ll_rc = inv_is.registerdataset( "session_list" ,lds_target, "fullalways")

ll_rc = inv_is.retrieve("session_list" )

assert(ll_rc = 1)

assert(lds_target.rowcount() > 0)

//test dst with arg
long ll_rc

datastore lds_target
lds_target = create datastore

ll_rc = inv_is.registerdataset( "reg_activity" ,lds_target, "fullalways")
inv_is.addArgument( "reg_activity", "lastndays", 500  )

ll_rc = inv_is.retrieve("reg_activity" )

assert(ll_rc = 1)

assert(lds_target.rowcount() > 0)

Leave a comment