Parameterized Java Method Calls

As long as test code is parameterized in the Java test class, it may be sufficient to call simple Java methods that do not take parameters or have return values. Often however it is desirable to customize test code in BDL and execute it in Java. Attribute functions can be used to pass parameters from BDL to Java code, but with Silk Performer it is also possible to call test methods in a Java test class that expect or return simple or complex parameters.

To call a test method that takes parameters, use the following function calls prior to invoking the test method:

The first parameter of the functions must be a valid handle on a Java object, usually the handle on the Java test object that was retrieved in the TInit transaction.

The data type of the first parameter of the Java test method must match the first usage of the JavaSet* function, and so on. In parameters are only valid for the following method call on a referenced object.

To call a test method that returns a parameter, use the following function calls after invoking the test method:

Here is an example parameterized Java method call:

  transaction TMyJavaTrans
    fValue : float;
    // set the first parameter
    JavaSetString(hTestObj, "1");
    // set the second parameter
    JavaSetNumber(hTestObj, 1);
    // invoke the method
    JavaCallMethod(hTestObj, "doFoo");
    // retrieve the result
    fValue := JavaGetFloat(hTestObj);
    Print("doFoo returned "+String(fValue));
  end TMyJavaTrans;