Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
remoteagentjava [2016/09/22 02:36] 127.0.0.1 external edit |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | TestOptimal agent in java can be run in standalone mode or included in other test automation tools that support java scripting like IBM Rational [[http:// | ||
- | Creating an agent in java is quite simple as the download package (agent.jar) already includes a java class which implements [[RemoteTriggerPlugin|the API to TestOptimal server]]. | ||
- | |||
- | Below is an example of a java agent using the provided TestOptimalAgent class: | ||
- | |||
- | ... | ||
- | // creates the agent object. | ||
- | // If you are not using log4j, then pass null instead. | ||
- | // localhost and 8888 are TestOptimal server host and port# | ||
- | // Demo_RemoteTrigger is the name of the model to be executed | ||
- | // last 2 params are # of retries on any communication errors | ||
- | // and # of milliseconds delay between retries | ||
- | TestOptimalAgent agent = new TestOptimalAgent (log4jObj, " | ||
- | // Execute the model, the params are user id and password | ||
- | // to access the model. | ||
- | agent.execModel("", | ||
- | // sleept for 5 sec to model to wait for the model to start | ||
- | Thread.sleep(5000); | ||
- | // obtain an agent id from the server. | ||
- | // in which case you would create multiple agent objects and have | ||
- | // each agent run in a separate thread. | ||
- | String agentID = agent.attachToServer(); | ||
- | RemoteCmd nextRemoteCmd = null; | ||
- | // loop until no more remote command is received from the server | ||
- | while (true) { | ||
- | // obtain the next command from the server | ||
- | // pass nextRemoteCmd to have the execution results of last | ||
- | // | ||
- | nextRemoteCmd = agent.getNextCmd(nextRemoteCmd); | ||
- | // if no remote command is received, break the loop | ||
- | if (nextRemoteCmd==null) { | ||
- | | ||
- | } | ||
- | // optionally set the command executing for measuring performance | ||
- | nextRemoteCmd.setExecuting(); | ||
- | // add your logic to execute remote command received in nextRemoteCmd. | ||
- | ... | ||
- | // set the command execution status and results which will be | ||
- | // be sent back to the server to be stored with the remote command. | ||
- | nextRemoteCmd.setExecCompleted(" | ||
- | } | ||
- | // stop the model execution. | ||
- | // the model should not be stopped until the last agent has completed. | ||
- | agent.stopExec(); | ||
- | // save the execution result to be reviewed later using TestOptimal Browser. | ||
- | agent.saveStat(" | ||
- | // print out the execution summary | ||
- | System.out.println(" | ||
- | // close the model | ||
- | agent.closeModel(); | ||
- | ... | ||
- | |||
- | The download package includes [[http:// | ||
- | |||
- | (Release 3.0) |