Verification Point Framework Reference |
This class contains the verification point's metadata -- that is, the information that determines the data to capture for this verification point. Examples of verification point metadata include the list of properties for a user-defined object properties verification point, or connection information and SELECT statements for the JDBC database verification point that is included in the com.rational.test.vp
package.
Don't confuse metadata with the data being verified. The data being verified is encapsulated by an implementation of the interface VerificationPointData
.
A verification point's metadata can be defined in either of these ways:
set...
methods in your specialized VerificationPoint
class.
If the metadata has not been explicitly specified and no metadata exists for this verification point in the datastore, the framework calls the defineVPcallback()
method in your specialized VerificationPoint
class. Your implementation of this method should provide some means of retrieving the verification point's metadata-- typically through some UI that prompts the tester for the information. When the metadata is retrieved, the framework stores it in the datastore.
For more information about specifying metadata, see Step 1. Specify the Metadata for the Verification Point.
This class must also implement its own serialization. By requiring your specific verification point implementations to perform their own serialization, you can support all file formats (such as INI, XML, and standard Java serialization).
Note: The current release only supports the vpm
and .ini
formats.
This abstract
class defines the metadata for and partially implements the behavior of a verification point. Because the VerificationPoint
class is abstract, it cannot be instantiated. Rather, all verification point classes, including the classes you create, extend from this class, implementing the abstract methods necessary to specialize themselves, and inheriting the rest of their behavior from this class.
As the verification point implementer, you must implement all abstract methods.
public abstract class VerificationPoint
extends java.lang.Object
java.lang.Object
|
+--com.rational.test.vp.VerificationPoint
Known subclass:
DatabaseVP
Commonly used with QualityArchitect.
This class requires QualityArchitect.
This class contains the following fields:
This class contains the following methods:
:
codeFactory_
getConstructorInvocation() Returns a parameterized constructor call.
codeFactory_
getExternalizedInputDecl() Returns a variable declaration.
codeFactory_
getNumExternalizedInputs() Returns the number of responses (inputs) that a tester provided when defining verification point metadata interactively through a UI.
codeFactory_getPrefix()
Retrieves the user-defined prefix that is currently available to prepend to a variable name to make the name unique.
codeFactory_setPrefix()
Specifies a user-defined prefix to prepend to the current set of variable names. The names are created and declared by the
codeFactory_getExternalizedInputDecl()
method.
defineVPcallback()
Provides a way to capture the metadata for the verification point -- typically, by presenting the tester with a UI device, such as the Query Builder tool provided with QualityArchitect (for use with the database verification point).
getIsDefined()
Retrieves the value of the
bIsDefined
field.
getOptions()
Retrieves the options associated with the current verification point.
getVPname()
Retrieves the name of the current verification point.
performTest()
Performs a static, dynamic, or manual verification point, depending upon the parameters that are passed to it.
readFile()
Deserializes a verification point object from the specified InputStream.
setIsDefined()
Sets a value for the
bIsDefined
field.
setOptions()
Sets the options for the current verification point.
setVPname()
Sets the name of the current verification point.
writeFile()
Serializes the verification point object to the specified OutputStream.
clone
, equals
, finalize
, getClass
, hashCode
, notify
, notifyAll
, toString
, wait
, wait
, wait
Note: For more information about these code factory methods, see Step 4. Implement the Code Factory Methods to Generate Code.
This constructor stores the name of the verification point and the classes that provide serialization and comparison services for the verification point.
publicVerificationPoint
(java.lang.StringsVPname
, java.lang.ClasscVPdataClass
, java.lang.ClasscVPdataProviderClass
, java.lang.ClasscVPdataRendererClass
, java.lang.ClasscVPcompClass
)
The classes passed in the cVPdataClass
, cVPdataProviderClass
, cVPdataRendererClass
, and cVPcompClass
parameters are passed to the constructor to allow late-binding to the methods in the classes.
A test script can never call this constructor because the VerificationPoint
class is abstract. A specific verification point implementation (such as the predefined database verification point or any custom verification points that you implement) extends the VerificationPoint
class and invokes this constructor from within its own constructor using the super
keyword -- for example:
public MyVerificationPoint( String sVPname ) { super(sVPname, MyVPData.class, MyVPDataProvider.class, MyVPDataRenderer.class, MyVPComparator.class); . . . }
Returns a parameterized constructor call.
public abstract java.lang.String
codeFactory_getConstructorInvocation
()
The test script never calls this method. This method is called during the following Rational code generation operations:
This method returns a parameterized constructor call. This call plus the variables declared by codeFactory_getExternalizedInputDecl()
allow these code generators to create a fully specified verification point in the generated test script code.
For more information, see Step 4. Implement the Code Factory Methods to Generate Code.
Returns a variable declaration.
public abstract java.lang.StringcodeFactory_getExternalizedInputDecl
(intnInput
)
nInput
A number that indicates the current variable to declare. The number should be initialized to 0 and incremented by 1 in a loop.
A line of code that declares the specified variable.
The test script never calls this method. This method is called during the following Rational code generation operations:
The Rational code generators (the QualityArchitect Session Recorder and the Rose scenario test generator) call this method in a loop that iterates as many times as there are variables to declare (that is, the number returned from codeFactory_getNumExternalizedInputs()
).
The code returned by codeFactory_getConstructorInvocation()
uses the variables declared with codeFactory_getExternalizedInputDecl()
.
Returns the number of responses (inputs) that a tester provided when defining verification point metadata interactively through a UI. The UI was presented to the tester through the defineVPcallback()
method.
public abstract int codeFactory_getNumExternalizedInputs
()
The number of inputs that require variable declarations.
The test script never calls this method. This method is called during the following Rational code generation operations:
Retrieves the user-defined prefix that is currently available to prepend to a variable name to make the name unique.
public java.lang.String codeFactory_getPrefix
()
Call this method only if you are implementing a new verification point.
Use the prefix whenever you are constructing a set of variable names for use with the codeFactory_getConstructorInvocation()
and codeFactory_getExternalizedInputDecl()
methods.
Specifies a user-defined prefix to prepend to the current set of variable names created and declared by the codeFactory_getExternalizedInputDecl()
method.
public voidcodeFactory_setPrefix
(java.lang.StringsSelfDescribePrefix
)
sSelfDescribedPrefix
The prefix to prepend to the variable names.
The variable-name prefix ensures that variable names are unique when the Rational code generators (the QualityArchitect Session Recorder and the Rational Rose scenario test generator) insert more than one verification point into a given scope.
QualityArchitect code generators call this method.
Provides a way to capture the metadata for the verification point -- typically, by presenting the tester with a UI device, such as the Query Builder tool provided with QualityArchitect (for use with the database verification point).
public abstract boolean defineVPcallback
()
true
if the verification point metadata was captured; otherwise, false
. If the metadata was not captured, the verification point will be in an invalid state, and it logs an error if its performTest()
method is called.
The verification point framework automatically invokes this method if the verification point is not fully defined when you invoke the performTest()
method.
When you invoke defineVPcallback()
, it should do the following (presumably through a UI):
For example, the defineVPcallback()
method included with the database verification point provided with QualityArchitect invokes the Query Builder software. Query Builder captures JDBC connection information and a SQL statement, and then populates the database verification point object with the captured metadata, resulting in a fully defined verification point.
This method applies to the verification point metadata, not to the data itself that is captured in accordance with the metadata. The specialized Verification Point Data Provider class uses the metadata to determine which data to capture.
If QualityArchitect Session Recorder is recording the verification point, or if a Rose model is generating it, this method is invoked at script generation time. The resulting verification point metadata is automatically provided to the test script. As a result, the defineVPcallback()
method is not invoked at script playback time.
Implement this method only if you are implementing a new verification point.
Retrieves the value of the bIsDefined
field.
public boolean getIsDefined
()
If true
, the verification point's metadata was fully specified in the constructor call. If false
, the metadata was not fully specified.
If the verification point metadata is not defined when performTest()
is called, the framework will call the defineVPcallback()
method on behalf of the test script in an attempt to get a complete set of verification point metadata from the tester.
Retrieves the options associated with the current verification point.
public int getOptions
()
The options associated with the current verification point.
Retrieves the name of the current verification point.
public java.lang.String getVPname
()
The name of the current verification point.
Performs a static verification point.
public intperformTest
(java.lang.ObjectobjTarget
)
In this implementation, performTest()
performs and logs a regression-style verification. It does so by checking the datastore for an expected (baseline) data object, and then comparing the expected data object to the actual data object that is captured in this call.
If there is no expected data object in the datastore, the framework creates one and the method returns a VERIFICATION_NO_RESULT
for this run of the verification point.
However, if there is no expected data, but the test script specifies the OPTION_USER_ACKNOWLEDGE_BASELINE
option in the setOptions()
method, the framework first invokes an implementer-defined UI that prompts the tester to verify that the captured data is correct:
VERIFICATION _SUCCEEDED
.
This method returns one of the following values:
Performs a dynamic verification point.
public intperformTest
(java.lang.ObjectobjTarget
, VerificationPointDatavpsExpected
)
This method returns one of the following values:
In this implementation, performTest()
captures an actual data object from the component-under-test, compares the actual data object to the expected data object that was passed to the call, and logs the results of the comparison.
Performs a manual verification point.
public intperformTest
(java.lang.ObjectobjTarget
, VerificationPointDatavpsExpected
, VerificationPointDatavpsActual
)
This method returns one of the following values:
In this implementation, performTest()
specifies both the expected data object and the actual data object. This allows a test script to capture or construct the actual data object, rather than relying on the Verification Point Data Provider class to create the actual data object.
This call simply compares the actual and expected data objects that are passed to it and logs the results of the comparison.
Deserializes a verification point object from the specified InputStream.
public abstract voidreadFile
(java.io.InputStreamin
)
in
The InputStream from which the object is read.
This method throws the following exception:
Assigns a value to the bIsDefined
field.
public voidsetIsDefined
(booleanbIsDefined
)
bIsDefined
If
true
, the verification point's metadata is fully specified. If false
, the metadata is not fully specified.
If the verification point metadata is not defined when performTest()
is called, the framework calls the defineVPcallback()
method on behalf of the test script in an attempt to get a complete set of verification point metadata from the tester.
Sets the options for the current verification point.
public voidsetOptions
(intiOptions
)
Assigns a name to the current verification point.
public voidsetVPname
(java.lang.StringsVPname
)
sVPname
The name to assign to the current verification point (40 characters maximum).
Serializes the verification point object to the specified OutputStream.
public abstract voidwriteFile
(java.io.OutputStreamout
)
out
The OutputStream to which the object is written.
This method throws the following exception:
Metafile format is used so that the Rational comparators can read the file. For information, see Step 5. Provide Serialization Services for the Metadata.
Rational Test Script Services for Java | Rational Software Corporation |
Copyright (c) 2003, Rational Software Corporation | http://www.rational.com support@rational.com info@rational.com |