Defining a new type of captured data

The data captured by a recorder must be stored in a file and consumed by a test generator to produce a test. Captured data must be defined so that it can be stored by the recorder and consumed by the test generator.

To define a new type of recorded data, complete these tasks:

  • Declare a new type of recorder packet in the plugin.xml file, using the com.ibm.rational.test.lt.recorder.core.recorderPacket extension point.
  • Define one or more implementation classes, in the same plug-in that implement the interface: com.ibm.rational.test.lt.recorder.core.packet.IRecorderPacket.

These factors apply to IRecorderPacket class implementations:

  • You can define as many fields as required to store your data.
  • Because these classes are instantiated by a recorder, they must expose a way to construct themselves.
  • Because a test generator uses these classes, the classes must expose ways to retrieve information for the test generator. In other words, they must expose getter methods.
  • You must make the classes serializable. Take this into account when designing the classes. The classes must not have any references to data that you do not want to include in the stored information. Fields that include references to data that you do not want stored must be declared using the transient keyword. If you plan to have evolutions to these classes, make sure that these evolutions are compatible with earlier versions.

Recorder packets have these common features:

  • They have a type. This must be a type ID that is declared in an extension to the com.ibm.rational.test.lt.recorder.core.recorderPacket extension point. The implementation class must be in the same plug-in where the type ID is declared.
  • They have a start time and end time. This is important for sorting captured packets, as recorders typically do not send the packets at the exact same time as they are captured. Many packets have the same time for start and end events, because they are atomically captured. Packets do not have to have different start and end times. Packet end times must, however, be higher or equal to the start time. All timestamps must be expressed in units that the framework provides. The units must be of the highest accuracy that the system permits.

For best results, follow these practices for implementing recorder packets:

  • If you have more than one type of data, define an interface that all implementation classes implement.
  • Define an interface for each concrete implementation class, which exposes only read-only features of the class. The test generator requires access only to the interfaces, while the recorder requires access to the classes.
  • Do not define redundant or computable fields. Because the classes are serialized, a single additional field might make the recording file much larger if many packets are stored. Declare a redundant or computable field using the transient keyword.