Verification Point Framework Reference

prevnext

VerificationPoint Class


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:

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.


Overview

public abstract class VerificationPoint 
extends java.lang.Object
java.lang.Object
  |
  +--com.rational.test.vp.VerificationPoint
Known subclass:
DatabaseVP

Applicability

Commonly used with QualityArchitect.

This class requires QualityArchitect.


Summary

This class contains the following fields:

Field Description
bIsDefined protected boolean. If true, indicates that the verification point's metadata is fully specified. If false when a performTest() method is invoked, the framework will call the defineVPcallback() method on behalf of the test script in an attempt to get a full set of verification point metadata from the tester. Note that this field applies to the verification point metadata, not to the data itself that is captured in accordance with the metadata.
bIsValid protected boolean. If true, indicates that the verification point was correctly instantiated, successfully captured, and is in a valid state; otherwise, false.
COMPARE_CASEINSENSITIVE static int. Specifies that the verification should be case insensitive.
COMPARE_CASESENSITIVE static int. Specifies that the verification should be case sensitive (default).
OPTION_EXPECT_FAILURE Specifies that the Verification Point's expected result is failure. If the comparison fails and this option is set, the verification point succeeds.
OPTION_USER_
ACKNOWLEDGE_BASELINE
static int. Specifies that the first run of a static verification point should display the captured data for the tester to validate before storing it as the expected (baseline) data object.
sFailureDescription protected java.lang.String. Specifies the reason for a failure.
VERIFICATION_ERROR static int. Indicates that an error occurred, and the verification point was not performed.
VERIFICATION_FAILED static int. Indicates that the verification point was performed, and the comparison failed.
VERIFICATION_NO_RESULT static int. Indicates that the static verification point was run for the first time, and a baseline (expected) data object was successfully captured.
VERIFICATION_SUCCEEDED static int. Indicates that the verification point was performed, and the comparison passed.

This class contains the following methods:

:
Method Description
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.

Methods Inherited from Class java.lang.Object
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.


Constructor

This constructor stores the name of the verification point and the classes that provide serialization and comparison services for the verification point.


Syntax

public VerificationPoint(java.lang.String sVPname, 
java.lang.Class cVPdataClass, java.lang.Class 
cVPdataProviderClass, java.lang.Class cVPdataRendererClass, 
java.lang.Class cVPcompClass)

Element Description
sVPname A user-defined name for the verification point (40 characters maximum).
cVPdataClass The class responsible for serialization of one set of the verification point's data.
cVPdataProviderClass The class responsible for capturing the verification point's data and populating a VerificationPointData object with the data.
cVPdataRendererClass The class responsible for visually rendering the data stored in an object of this verification point's VerificationPointData class.
cVPcompClass The class responsible for comparing two sets of this verification point's data.


Comments

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);
   . . .
	 }

VerificationPoint.codeFactory_getConstructorInvocation()

Returns a parameterized constructor call.


Syntax

public abstract java.lang.String 
codeFactory_getConstructorInvocation()

Comments

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.


VerificationPoint.codeFactory_getExternalizedInputDecl()

Returns a variable declaration.


Syntax

public abstract java.lang.String 
codeFactory_getExternalizedInputDecl(int nInput)

Element Description
nInput A number that indicates the current variable to declare. The number should be initialized to 0 and incremented by 1 in a loop.


Return Value

A line of code that declares the specified variable.


Comments

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().


VerificationPoint.codeFactory_getNumExternalizedInputs()

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.


Syntax

public abstract int codeFactory_getNumExternalizedInputs()

Return Value

The number of inputs that require variable declarations.


Comments

The test script never calls this method. This method is called during the following Rational code generation operations:


VerificationPoint.codeFactory_getPrefix()

Retrieves the user-defined prefix that is currently available to prepend to a variable name to make the name unique.


Syntax

public java.lang.String codeFactory_getPrefix()

Return Value

A prefix for a variable name.


Comments

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.


VerificationPoint.codeFactory_setPrefix()

Specifies a user-defined prefix to prepend to the current set of variable names created and declared by the codeFactory_getExternalizedInputDecl() method.


Syntax

public void codeFactory_setPrefix(java.lang.String 
sSelfDescribePrefix)

Element Description
sSelfDescribedPrefix The prefix to prepend to the variable names.


Comments

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.


VerificationPoint.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).


Syntax

public abstract boolean defineVPcallback()

Return Value

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.


Comments

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):

  1. Capture any information necessary for fully defining the metadata for the verification point

  2. Populate the verification point's attributes with the captured metadata.

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.


VerificationPoint.getIsDefined()

Retrieves the value of the bIsDefined field.


Syntax

public boolean getIsDefined()

Return Value

If true, the verification point's metadata was fully specified in the constructor call. If false, the metadata was not fully specified.


Comments

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.


See Also

getIsDefined()


VerificationPoint.getOptions()

Retrieves the options associated with the current verification point.


Syntax

public int getOptions()

Return Value

The options associated with the current verification point.


See Also

setOptions()


VerificationPoint.getVPname()

Retrieves the name of the current verification point.


Syntax

public java.lang.String getVPname()

Return Value

The name of the current verification point.


See Also

setVPname()


VerificationPoint.performTest()

Performs a static verification point.


Syntax

public int performTest(java.lang.Object objTarget)

Element Description
objTarget The object-under-test. If the verification point operates on an object that is not directly accessible (for example, a remote object or a database), the verification point object must contain the information needed to find the object-under-test, and the value of objTarget is ignored. This parameter is passed to captureData() as its first parameter.


Comments

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:


Return Value

This method returns one of the following values:

Value Description
VERIFICATION_SUCCEEDED The verification point was performed, and the comparison passed.
VERIFICATION_FAILED The verification point was performed, and the comparison failed.
VERIFICATION_NO_RESULT The static verification point was run for the first time, and a baseline (expected) data object was successfully captured.
VERIFICATION_ERROR An error occurred, and the verification point was not performed.


VerificationPoint.performTest()

Performs a dynamic verification point.


Syntax

public int performTest(java.lang.Object objTarget, 
VerificationPointData vpsExpected)

Element Description
objTarget The object-under-test. If the verification point operates on an object that is not directly accessible (for example, a remote object or a database), the verification point object must contain the information needed to find the object-under-test, and the value of objTarget is ignored. This parameter is passed to captureData() as its first parameter.
vpsExpected An expected data object. The test script can construct the expected data object, or it can deserialize the expected data object from a file that is not managed by the datastore.


Return Value

This method returns one of the following values:

Value Description
VERIFICATION_SUCCEEDED The verification point was performed, and the comparison passed.
VERIFICATION_ERROR An error occurred, and the verification point was not performed.
VERIFICATION_FAILED The verification point was performed, and the comparison failed.


Comments

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.


VerificationPoint.performTest()

Performs a manual verification point.


Syntax

public int performTest(java.lang.Object objTarget, 
VerificationPointData vpsExpected, VerificationPointData 
vpsActual)

Element Description
objTarget The object-under-test. If the verification point operates on an object that is not directly accessible (for example, a remote object or a database), the verification point object must contain the information needed to find the object-under-test, and the value of objTarget is ignored. This parameter is passed to captureData() as its first parameter.
vpsExpected An expected data object. The test script can construct the expected data object, or it can deserialize the expected data object from a file that is not managed by the datastore.
vpsActual The actual data object. The code in the test script captured or constructed this object.


Return Value

This method returns one of the following values:

Value Description
VERIFICATION_SUCCEEDED The verification point was performed, and the comparison passed.
VERIFICATION_ERROR An error occurred, and the verification point was not performed.
VERIFICATION_FAILED The verification point was performed, and the comparison failed.


Comments

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.


VerificationPoint.readFile()

Deserializes a verification point object from the specified InputStream.


Syntax

public abstract void readFile(java.io.InputStream in)

Element Description
in The InputStream from which the object is read.


Exceptions

This method throws the following exception:


VerificationPoint.setIsDefined()

Assigns a value to the bIsDefined field.


Syntax

public void setIsDefined(boolean bIsDefined)

Element Description
bIsDefined If true, the verification point's metadata is fully specified. If false, the metadata is not fully specified.


Comments

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.


See Also

getIsDefined()


VerificationPoint.setOptions()

Sets the options for the current verification point.


Syntax

public void setOptions(int iOptions)

Element Description
iOptions One or more options to assign to the verification point. Options can be predefined, as in the following: COMPARE_CASESENSITIVE COMPARE_CASEINSENSITIVE OPTION_EXPECT_FAILURE Options can also be any user-defined options.


See Also

getOptions()


VerificationPoint.setVPname()

Assigns a name to the current verification point.


Syntax

public void setVPname(java.lang.String sVPname)

Element Description
sVPname The name to assign to the current verification point (40 characters maximum).


See Also

getVPname()


VerificationPoint.writeFile()

Serializes the verification point object to the specified OutputStream.


Syntax

public abstract void writeFile(java.io.OutputStream out)

Element Description
out The OutputStream to which the object is written.


Exceptions

This method throws the following exception:


Comments

Metafile format is used so that the Rational comparators can read the file. For information, see Step 5. Provide Serialization Services for the Metadata.

prevnext


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