Use the Wizard to create a custom Activity - Java
Relevant for: API testing only
This task describes how to create a new activity using Java code, and deploy it in UFT One.
Prerequisite
Make sure you have a JAVA_HOME environment variable defined on your machine indicating the parent JDK folder.
Run the Activity Wizard
-
Open the Activity Wizard from the product's start menu (Start > All Programs > Micro Focus >Micro Focus UFT One > Tools >Activity Wizard or <UFT One installation folder>\bin\ActivityWizard.exe).
-
In the wizard's General Properties pane, select the Java as the Language.
-
Follow the steps of the wizard to create your activity.
Edit the code
-
On the final screen of the wizard, click Open Folder to open the <Activity Name> folder, corresponding to the activity name you specified in the wizard. Navigate to the <Activity Name>\hp\st\ext\java subfolder and locate the MyLogic<TimeStamp>.java file.
Caution: Do not close the Activity Wizard after this step.
-
Edit the ExecuteLogic function inside the MyLogic<TimeStamp>.java file. Make sure to keep the Properties definition.
public Properties Props = new Properties(); public ExecutionResult ExecuteLogic() { try{ //************************** // Execution code goes here //************************** return ExecutionResult.Success; } ...
Add Logger code - optional
In the MyLogic<TimeStamp>.java file, add information for the log using the Logger.LogInfo, Logger.LogDebug, or Logger.LogError statements. For example:
try{
...
Logger.LogInfo("Log Message 1");
Logger.LogDebug("Log Message 2");
Logger.LogError("Log Message 3");
...
return ExecutionResult.Success;
}
Add a Report statement - optional
In the MyLogic<TimeStamp>.java file, add a Report statement, Reporter.Report, using key value combinations. For example:
try{
...
Reporter.Report{"Name","John");
...
return ExecutionResult.Success;
}
Compile the Java into a class
-
In your design IDE, add the ServiceTestCall.jar file to the build path.
- In UFT One, run the CompileJavaFiles batch file in the <Activity Name>\hp\custom\java\activity folder to compile all java files into a class. This utility only compiles the files in its folder.
Deploy the activity
-
In the final wizard screen, click Deploy in UFT One.
-
Click Finish to close the wizard and restart UFT One.
Set up your environment for a Java Activity SDK
To set up your environment for using a Java activity SDK, do the following:
-
Collect all necessary .jar libraries. Create new folder in the UFT One installation directory, and copy all of the .jar libraries you collected into the new folder.
For example: <UFT One installation folder>\MQLibs
-
Browse to the <UFT One installation folder>\dat folder, and open the InternalJavaClasspath.dat file in a text editor.
- Add the paths to all the .jar files that you collected to the end of the InternalJavaClasspath.dat file.
- Launch UFT One and use your custom JMS activity to send or receive messages.