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)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s