Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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://www-01.ibm.com/software/awdtools/tester/robot/|Robot]] and [[http://www-01.ibm.com/software/awdtools/tester/functional/|Functional Tester]] or Borland [[http://www.borland.com/us/products/silk/silktest/index.html|SilkTest]]. 
  
-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, "localhost", 8888, "Demo_RemoteTrigger[[edit=RemoteTrigger|?]]", 5, 2000); 
-    // Execute the model, the params are user id and password 
-    //   to access the model.  Pass blank "" if the security is not enabled.  If the model is already started, the following execModel() and sleep() are not needed. 
-    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.  You may attach multiple agents 
-    //   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 
-      //   remote command to be sent back to the server. 
-      nextRemoteCmd = agent.getNextCmd(nextRemoteCmd); 
-      // if no remote command is received, break the loop 
-      if (nextRemoteCmd==null) { 
-         break; 
-      } 
-      // 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("exec results here"); 
-    } 
-    // stop the model execution.  If multiple agents are used, then 
-    //   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("from java agent xyz"); 
-    // print out the execution summary 
-    System.out.println("Execution result: " + agent.getExecSummary()); 
-    // close the model 
-    agent.closeModel(); 
-    ... 
- 
-The download package includes [[http://TestOptimal.com/demo/DemoRemoteAgent.java.txt|an example java agent]]. You may run this demo by running a batch file startDemoRemoteAgent.bat. 
- 
-(Release 3.0)