Rational QualityArchitect/Java API
Version 1.0

com.rational.test.vp
Class DatabaseVP

java.lang.Object
  |
  +--com.rational.test.vp.VerificationPoint
        |
        +--com.rational.test.vp.DatabaseVP

public class DatabaseVP
extends VerificationPoint

This class implements a database verification point. The database verification point is the verification point you typically use in EJB testing.

A database verification point is a pre-constructed verification point used to verify data in a JDBC accessible data source. This functionality can be used within a test script to ensure that the changes made to a data source by the component-under-test are correct.

The DatabaseVP object contains the verification point metadata needed for encapsulating data in a DatabaseVPData object -- namely:

In addition, the DatabaseVP object contains the database verification point name. It also contains options for affecting the behavior of the verification point.

To execute the database verification point, call the performTest() method in this class (interited from the VerificationPoint class).

Since:
QualityArchitect 0.1

Example of a Static Database Verification Point

In a static verification point, no data objects are passed to the verification point through the performTest() method. As a result, the framework is responsible for providing both the expected (baseline) and actual data objects.

String sJDBCdriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sJDBCurl = "jdbc:odbc:COFFEEBREAK";
String sJDBCuser = "";
String sJDBCpassword = "";

DatabaseVP regressionVP = new DatabaseVP( "RegressionVP1", "SELECT * FROM COFFEES", sJDBCuser, sJDBCpassword,
sJDBCdriver, sJDBCurl );

regressionVP.performTest( null );

Example of a Dynamic Database Verification Point

In a dynamic verification point, the test script is responsible for creating a DatabaseVPData data object for the expected data and for passing the expected data object to the verification point through the performTest() method. As a result, the framework is responsible for encapsulating only the actual data object.

String sJDBCdriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sJDBCurl = "jdbc:odbc:COFFEEBREAK";
String sJDBCuser = "";
String sJDBCpassword = "";
String sfilter = "1";
DatabaseVPData vpdExpected = new DatabaseVPData();
String[] asColumns = new String[2];
asColumns[0] = "Brand";
asColumns[1] = "Price";
vpdExpected.setColumns(asColumns);

Vector vData = new Vector();
String[] asData = new String[2];
asData[0] = "Peets";
asData[1] = "5.5";
vData.add(asData);
vpdExpected.setData(vData);

String sSQL = "SELECT Brand, Price FROM COFFEES WHERE ID = " + sFilter;

DatabaseVP VP1 = new DatabaseVP( "CoffeeVp1", sSQL, sJDBCuser, sJDBCpassword,
sJDBCdriver, sJDBCurl );

// Perform the test
VP1.performTest(null, vpdExpected);

Setting and Removing Options

To turn on multiple options, use the OR (|) operator. To remove an option after you have set it, but leave all other options unchanged, use the AND (&) and NOT (~) operators. Here are examples of turning options on and off:

Turns two options on:

MyVP.setOptions(OPTION_TRIM | OPTION_EXPECT_FAILURE);

Turns off the OPTION_TRIM option, but leaves all other options unchanged:

MyVP.setOptions(MyVP.Options & (~OPTION_TRIM));
See Also:
DatabaseVPData, DatabaseVPDataProvider, DatabaseVPComparator, DatabaseVPDataRenderer

Field Summary
static int OPTION_TRIM
          This option specifies that values captured from the DatabaseVP should have whitespace trimmed from the right and left sides.
 
Fields inherited from class com.rational.test.vp.VerificationPoint
bIsDefined, bIsValid, COMPARE_CASEINSENSITIVE, COMPARE_CASESENSITIVE, OPTION_EXPECT_FAILURE, OPTION_USER_ACKNOWLEDGE_BASELINE, sFailureDescription, VERIFICATION_ERROR, VERIFICATION_FAILED, VERIFICATION_NO_RESULT, VERIFICATION_SUCCEEDED
 
Constructor Summary
DatabaseVP(java.lang.String sVPname)
          This constructor specifies only the name of the verification point.
DatabaseVP(java.lang.String sVPname, java.lang.String sSQL, java.lang.String sJDBCuser, java.lang.String sJDBCpassword, java.lang.String sJDBCdriver, java.lang.String sJDBCurl)
          This constructor specifies the name of the verification point plus the verification point's metadata.
DatabaseVP(java.lang.String sVPname, java.lang.String sSQL, java.lang.String sJDBCuser, java.lang.String sJDBCpassword, java.lang.String sJDBCdriver, java.lang.String sJDBCurl, int iOptions)
          This constructor specifies the name of the verification point, the verification point's metadata, and any options that customize the behavior of the verification point.
 
Method Summary
 java.lang.String codeFactory_getConstructorInvocation()
          Internal use only.
 java.lang.String codeFactory_getExternalizedInputDecl(int nInput)
          Internal use only.
 int codeFactory_getNumExternalizedInputs()
          Internal use only.
 java.lang.String codeFactory_getStaticInvocation()
          Internal use only.
 boolean defineVPcallback()
          Internal use only.
 java.sql.Connection getCon()
          This method retrieves the current connection object used to connect to the JDBC data source.
 java.lang.String getJDBCdriver()
          This method retrieves the current driver used in the connection to the JDBC data source.
 java.lang.String getJDBCpassword()
          This method retrieves the current password for connecting to the JDBC data source.
 java.lang.String getJDBCurl()
          This method retrieves the current URL used to connect to the JDBC data source.
 java.lang.String getJDBCuser()
          This method retrieves the current user ID for connecting to the JDBC data source.
 VerificationPointProperties getProperties()
          Internal use only.
 java.lang.String getSQL()
          This method retrieves the current SQL statement used to capture data from the JDBC data source.
 java.sql.Statement getStmt()
          This method retrieves the current JDBC statement.
 void readFile(java.io.InputStream in)
          This method deserializes a verification point object from the specified InputStream.
 void setCon(java.sql.Connection con)
          This method sets the connection object for the JDBC data source.
 void setJDBCdriver(java.lang.String sJDBCdriver)
          This method sets the JDBC driver used to connect to the JDBC data source.
 void setJDBCpassword(java.lang.String sJDBCpassword)
          This method sets the password for the connection to the JDBC data source.
 void setJDBCurl(java.lang.String sJDBCurl)
          This method sets the JDBC URL used in the connection to the JDBC data source.
 void setJDBCuser(java.lang.String sJDBCuser)
          This method sets the user ID for the connection to the JDBC data source.
 void setSQL(java.lang.String sSQL)
          This method sets the SQL statement to use in capturing data from the JDBC data source.
 void setStmt(java.sql.Statement stmt)
          This method sets the JDBC statement
 void writeFile(java.io.OutputStream out)
          This method serializes the verification point object to the specified OutputStream.
 
Methods inherited from class com.rational.test.vp.VerificationPoint
codeFactory_getPrefix, codeFactory_setPrefix, getIsDefined, getLog, getLogActualFile, getLogBaselineFile, getLogMetaFile, getMasterBaselineFile, getMasterMetaFile, getOptions, getVPname, initializeVP, performTest, performTest, performTest, setIsDefined, setOptions, setVPname
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPTION_TRIM

public static final int OPTION_TRIM
This option specifies that values captured from the DatabaseVP should have whitespace trimmed from the right and left sides.
Constructor Detail

DatabaseVP

public DatabaseVP(java.lang.String sVPname)
This constructor specifies only the name of the verification point. if the verification point is executed before its metadata has been specified, the tester is prompted to specify the metadata for the verification point. The metadata includes JDBC connection information and a SQL statement to capture the data to test.
Parameters:
sVPname - The name of the verification point. 40 characters maximum.

DatabaseVP

public DatabaseVP(java.lang.String sVPname,
                  java.lang.String sSQL,
                  java.lang.String sJDBCuser,
                  java.lang.String sJDBCpassword,
                  java.lang.String sJDBCdriver,
                  java.lang.String sJDBCurl)
This constructor specifies the name of the verification point plus the verification point's metadata.
Parameters:
sVPname - The name of the verification point. 40 characters maximum.
sSQL - The select statement that this DatabaseVP uses to capture data from the data source.
sJDBCuser - The JDBC user name.
sJDBCpassword - The JDBC password for the user.
sJDBCdriver - The Java class for the JDBC driver for this data source.
sJDBCurl - The URL specifying the target JDBC data source.

DatabaseVP

public DatabaseVP(java.lang.String sVPname,
                  java.lang.String sSQL,
                  java.lang.String sJDBCuser,
                  java.lang.String sJDBCpassword,
                  java.lang.String sJDBCdriver,
                  java.lang.String sJDBCurl,
                  int iOptions)
This constructor specifies the name of the verification point, the verification point's metadata, and any options that customize the behavior of the verification point.
Parameters:
sVPname - The name of the Verification Point. 40 characters maximum.
sSQL - The select statement that this DatabaseVP uses to capture data from the data source.
sJDBCuser - The JDBC user name.
sJDBCpassword - The JDBC password for the user.
sJDBCdriver - The Java class for the JDBC driver for this data source.
sJDBCurl - The URL specifying the target JDBC data source.
iOptions - A bitfield of options that customize the behavior of this verification point. Options may include the pre-defined options shown below and any user-defined options.
See Also:
VerificationPoint.COMPARE_CASESENSITIVE, VerificationPoint.COMPARE_CASEINSENSITIVE, OPTION_TRIM
Method Detail

codeFactory_getConstructorInvocation

public java.lang.String codeFactory_getConstructorInvocation()
Internal use only.
Overrides:
codeFactory_getConstructorInvocation in class VerificationPoint

codeFactory_getExternalizedInputDecl

public java.lang.String codeFactory_getExternalizedInputDecl(int nInput)
Internal use only.
Overrides:
codeFactory_getExternalizedInputDecl in class VerificationPoint
Following copied from class: com.rational.test.vp.VerificationPoint
Parameters:
nInput - A number that indicates the current variable to declare. The number should be initialized to 0 and incremented by 1 in the loop.
Returns:
A line of code that declares the specified variable.

codeFactory_getNumExternalizedInputs

public int codeFactory_getNumExternalizedInputs()
Internal use only.
Overrides:
codeFactory_getNumExternalizedInputs in class VerificationPoint
Following copied from class: com.rational.test.vp.VerificationPoint
Returns:
The number of inputs that require variable declarations.


codeFactory_getStaticInvocation

public java.lang.String codeFactory_getStaticInvocation()
Internal use only.
Overrides:
codeFactory_getStaticInvocation in class VerificationPoint

defineVPcallback

public boolean defineVPcallback()
Internal use only.
Overrides:
defineVPcallback in class VerificationPoint
Following copied from class: com.rational.test.vp.VerificationPoint
Returns:
true if the verification point metadata was captured, false otherwise. If the metadata was not captured, the verification point will be in an invalid state, and it will log an error if its performTest() method is called.

getProperties

public VerificationPointProperties getProperties()
Internal use only.

getCon

public java.sql.Connection getCon()
This method retrieves the current connection object used to connect to the JDBC data source.
Returns:
The current connection information.

getJDBCdriver

public java.lang.String getJDBCdriver()
This method retrieves the current driver used in the connection to the JDBC data source.
Returns:
The current JDBC driver.

getJDBCpassword

public java.lang.String getJDBCpassword()
This method retrieves the current password for connecting to the JDBC data source.
Returns:
The current password.

getJDBCurl

public java.lang.String getJDBCurl()
This method retrieves the current URL used to connect to the JDBC data source.
Returns:
The current URL.

getJDBCuser

public java.lang.String getJDBCuser()
This method retrieves the current user ID for connecting to the JDBC data source.
Returns:
The current user ID.

getSQL

public java.lang.String getSQL()
This method retrieves the current SQL statement used to capture data from the JDBC data source.
Returns:
The current SQL statement.

getStmt

public java.sql.Statement getStmt()
This method retrieves the current JDBC statement.
Returns:
The current JDBC statement.

readFile

public void readFile(java.io.InputStream in)
              throws java.io.IOException
Description copied from class: VerificationPoint
This method deserializes a verification point object from the specified InputStream.
Overrides:
readFile in class VerificationPoint
Following copied from class: com.rational.test.vp.VerificationPoint
Parameters:
in - The InputStream from which the object is read.
Throws:
java.io.IOException - An error has occurred in attempting to read from the InputStream.

setCon

public void setCon(java.sql.Connection con)
This method sets the connection object for the JDBC data source.
Parameters:
con - The connection object to use in connecting to the JDBC data source. If not specified, a new object is created by the database verification point, as necessary.

setJDBCdriver

public void setJDBCdriver(java.lang.String sJDBCdriver)
This method sets the JDBC driver used to connect to the JDBC data source.
Parameters:
sJDBCdriver - The driver used to connect to the JDBC data source.

setJDBCpassword

public void setJDBCpassword(java.lang.String sJDBCpassword)
This method sets the password for the connection to the JDBC data source.
Parameters:
sJDBCpassword - The password for connecting to the JDBC data source.

setJDBCurl

public void setJDBCurl(java.lang.String sJDBCurl)
This method sets the JDBC URL used in the connection to the JDBC data source.
Parameters:
sJDBCurl - The URL used in the connection to the JDBC data source.

setJDBCuser

public void setJDBCuser(java.lang.String sJDBCuser)
This method sets the user ID for the connection to the JDBC data source.
Parameters:
sJDBCuser - The user ID for connecting to the JDBC data source.

setSQL

public void setSQL(java.lang.String sSQL)
This method sets the SQL statement to use in capturing data from the JDBC data source.
Parameters:
sSQL - The SQL statement to use.

setStmt

public void setStmt(java.sql.Statement stmt)
This method sets the JDBC statement
Parameters:
stmt - The JDBC object to send to the data source. If not specified, a new object is created by the database verification point, as necessary.

writeFile

public void writeFile(java.io.OutputStream out)
               throws java.io.IOException
Description copied from class: VerificationPoint
This method serializes the verification point object to the specified OutputStream. Metafile format should be used so that the Rational comparators can read the file.
Overrides:
writeFile in class VerificationPoint
Following copied from class: com.rational.test.vp.VerificationPoint
Parameters:
out - The OutputStream to which the object is written.
Throws:
java.io.IOException - An error has occurred in attempting to write to the OutputStream.

30-Jun-2003

Rational QualityArchitect/Java Support Home Page
Copyright (c) 2000, Rational Software Corporation