Converting existing function classes without Eclipse

You can convert functions that were written for HCL OneTest™ API version 4 to work with version 5 or later without Eclipse.

About this task

Note: The following steps assume that HCL OneTest API is installed in C:\Program Files\HCL\HCLProducts\API\, that the Installation Manager shared resources directory is installed in C:\Program Files\HCL\HCLIMShared\, and that you are using a Windows Command Prompt. However, running the commands from a Linux Terminal is also supported and the Installation Manager shared resources directory is installed on Linux systems in /opt/HCL/HCLIMShared/.

Procedure

  1. Create a folder in which to develop your custom function. For example, c:\customFunction.
  2. Create folders for the source and the build output. For example, c:\customFunction\src and c:\customFunction\build.
  3. Copy the plugin.xml file and the META-INF directory from C:\Program Files\HCL\HCLProducts\API\examples\FunctionsSamplePlugin into the build directory. Both the plugin.xml file and the META-INF directory must be copied to the same target directory (C:\customFunction\build).
  4. Create the required directory structure under src to contain your custom function code. For information about how to write your custom function code, see Implementing the function class. If you have existing code, copy the root package and all sub packages under the src folder. For example: C:\customFunction\src\com\samples\functions\FormatDate.java. An example directory structure follows:

    Example directory structure

    Except in the src folder, if you compile your own function, you have your own Java™ classes in a similar folder hierarchy. For example:

    Example src directory structure

  5. Remove the register() method as it is not required anymore.
  6. Change the visibility of the default constructor to be public. No other visibility (for example, protected) can be used, otherwise an exception is generated when you try to execute the function.
  7. Remove the super(String, String, int, int) call in the default constructor.

    This super constructor does not exist anymore, so any calls to it produce an error. This call is replaced by the information that is contained in the extension point definition.

  8. Remove the method getSyntax(). This information is now contained in the extension point definition.
  9. In your command prompt or terminal, from the C:\customFunction\src folder compile the custom function into the build directory, such as by running the following command:
    Note: Run the javac executable from the Java Development Kit (JDK). If the commands shown do not find that executable, add the full path to the executable's location to the beginning of each command.

    javac -d ../build -classpath .;"C:/Program Files/HCL/HCLIMShared/plugins/*" com/samples/functions/FormatDate.java

    Note: If the source contains multiple Java files, you must specify each file in the command. For example, if you use the second directory structure above, the command is:
    javac -d ../build -classpath .;"C:/Program Files/HCL/HCLIMShared/plugins/*" com/mycompany/myfunction/MyFunction.java com/mycompany/myfunction/MyUtilities.java

    or

    javac -d ../build -classpath .;"C:/Program Files/HCL/HCLIMShared/plugins/*" com/mycompany/myfunction/*.java
    On a Linux systems, the command is:
    javac -d ../build -classpath .:"/opt/HCL/HCLIMShared/plugins/*" **/*.java
  10. Edit MANIFEST.MF, which is in the META-INF directory under the build directory, for example, META-INF/MANIFEST.MF and change the following values:
    Value Change to...
    Bundle-Name Enter a descriptive name for the plug-in (for example, Format Date Function).
    Bundle-SymbolicName Enter a unique ID that describes your plug-in. This ID must be different from any other plug-in, as two plug-ins with the same ID cannot be loaded at one time. Leave the "singleton:=true" part untouched.
    Bundle-Vendor Enter your company’s name or some other provider description.
    An example of a manifest file follows:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.0
    Created-By: 10.0-b19 (Sun Microsystems Inc.)
    Bundle-ManifestVersion: 2
    Bundle-Name: The Function That Does Exactly What I Need
    Bundle-SymbolicName: com.mycompany.myfunction;singleton:=true
    Bundle-Version: 1.0.0
    Bundle-Vendor: My Company
    Import-Package: com.ghc.ghTester.expressions

    Replace the values for Bundle_Name, the Bundle-SymbolicName, and the Bundle-Vendor with your own. The Bundle-SymbolicName value usually, but does not have to, match the Java package name in which the function Java classes are located.

  11. Open plug-in.xml (in your build directory) in a text editor and update the values as described in Configuring the extension point element.
  12. In your command prompt or terminal, from the c:\customFunction\build directory create a JAR file that contains your custom function classes, MANIFEST.MF, and plug-in.xml. For example, you can use the following command:
    Note: Run the jar executable from the Java Development Kit (JDK). If the commands shown do not find that executable, add the full path to the executable's location to the beginning of each command.

    jar cvfm custom-function-plug-in_1.0.0.jar META-INF\MANIFEST.MF com plugin.xml

    Note: You can choose any name for your JAR file, but you must follow a convention that prevents conflicting names.
  13. Copy the new JAR file into the "Functions" folder of your project.

    After a plug-in is generated for your function (Create the plug-ins in Eclipse) and your function is implemented (Implementing the function class), you need to tell HCL OneTest API about it.

    When finished, follow the instructions to load the function into HCL OneTest API (see Configuring the function in HCL OneTest API).

    Note: An example of how the plug-in looks can be found under C:\Program Files\HCL\HCLProducts\API\examples\FunctionsSamplePlugin.
Feedback