Previous Topic: Java-J2EE StepsNext Topic: RMI Server Execution


Dynamic Java Execution

The Dynamic Java Execution step lets you instantiate and manipulate a Java object. All Java classes on the DevTest classpath are available, including the classes in the JRE classpath. Any user classes can be placed on the classpath by copying them into the hotDeploy directory. The class under test is loaded into the Complex Object Editor where it can be manipulated without having to write any Java code.

This example uses a Java date instance of class java.util.Date.

  1. Enter the following parameters in the Dynamic Java Execution editor:
    Use JVM

    Select Local.

    Note: You can use In-Container Testing (ICT) to execute a Java object remotely by clicking the Remote option button. However, this mode requires some extra setup before it can be used. For more information, see the Using the SDK.

    Local JVM Settings

    Select one of the following options:

    • Make New Object of Class: Select this option button and enter, select, or browse to the Java class to instantiate. This value must be the fully qualified class name including the package of the Java class; for example, com.example.MyClass.
    • Load from Property: Click the option button and enter the name of the property that has the serialized object as its value.
    If environment error

    Select the step to redirect to if an environment error occurs while trying to create an object.

    Note: If you require that the Java object be loaded by its own classloader, add the Class Loader Sandbox Companion.

  2. Click Construct/Load Object.

    The Complex Object Constructor window opens and lists the available constructors for your object.

  3. Select a constructor and click Next.
  4. Enter any input parameters that the constructor needs.

    Dynamic Java Execution step Complex Object Constructor

  5. In this example, enter a string representation of a day (5/10/2011). You can enter a value, a property, or null. DevTest constructs the object and loads it into the Complex Object Editor.

    Dynamic Java Execution step Complex Object Editor

  6. You can now manipulate the object, and execute methods, using the Complex Object Editor.

    For more information about how to use the Complex Object Editor, see Complex Object Editor (COE) in Using CA Application Test.

  7. You can use either of the following methods to add filters and assertions:

    For example, the following graphic is a window before we execute the before method on the Date class.

    COE before we execute the before method on the Date class

    In the Status/Result section, you can add an inline filter in the Save Results in Property text box. You can also add an inline assertion in the Comparison on Result Like text box.

    The Dynamic Java Execution step has a default name using this convention: Dynamic Java Execution. You can change step names at any time.