|
Rational QualityArchitect/Java API Version 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.rational.test.vp.VerificationPoint | +--com.rational.test.vp.DatabaseVP
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.
TheDatabaseVP
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).
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 );
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);
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));
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 |
public static final int OPTION_TRIM
DatabaseVP
should have whitespace trimmed
from the right and left sides.Constructor Detail |
public DatabaseVP(java.lang.String sVPname)
sVPname
- The name of the verification point. 40
characters maximum.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)
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.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)
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.VerificationPoint.COMPARE_CASESENSITIVE
,
VerificationPoint.COMPARE_CASEINSENSITIVE
,
OPTION_TRIM
Method Detail |
public java.lang.String codeFactory_getConstructorInvocation()
codeFactory_getConstructorInvocation
in class VerificationPoint
public java.lang.String codeFactory_getExternalizedInputDecl(int nInput)
codeFactory_getExternalizedInputDecl
in class VerificationPoint
com.rational.test.vp.VerificationPoint
nInput
- A number that indicates the current variable to declare. The number
should be initialized to 0 and incremented by 1 in the loop.public int codeFactory_getNumExternalizedInputs()
codeFactory_getNumExternalizedInputs
in class VerificationPoint
com.rational.test.vp.VerificationPoint
public java.lang.String codeFactory_getStaticInvocation()
codeFactory_getStaticInvocation
in class VerificationPoint
public boolean defineVPcallback()
defineVPcallback
in class VerificationPoint
com.rational.test.vp.VerificationPoint
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.public VerificationPointProperties getProperties()
public java.sql.Connection getCon()
public java.lang.String getJDBCdriver()
public java.lang.String getJDBCpassword()
public java.lang.String getJDBCurl()
public java.lang.String getJDBCuser()
public java.lang.String getSQL()
public java.sql.Statement getStmt()
public void readFile(java.io.InputStream in) throws java.io.IOException
VerificationPoint
readFile
in class VerificationPoint
com.rational.test.vp.VerificationPoint
in
- The InputStream from which the object is read.java.io.IOException
- An error has occurred in attempting
to read from the InputStream.public void setCon(java.sql.Connection con)
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.public void setJDBCdriver(java.lang.String sJDBCdriver)
sJDBCdriver
- The driver used to connect to the JDBC data source.public void setJDBCpassword(java.lang.String sJDBCpassword)
sJDBCpassword
- The password for connecting to the JDBC data source.public void setJDBCurl(java.lang.String sJDBCurl)
sJDBCurl
- The URL used in the connection to the JDBC data source.public void setJDBCuser(java.lang.String sJDBCuser)
sJDBCuser
- The user ID for connecting to the JDBC data source.public void setSQL(java.lang.String sSQL)
sSQL
- The SQL statement to use.public void setStmt(java.sql.Statement stmt)
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.public void writeFile(java.io.OutputStream out) throws java.io.IOException
VerificationPoint
writeFile
in class VerificationPoint
com.rational.test.vp.VerificationPoint
out
- The OutputStream to which the object is written.java.io.IOException
- An error has occurred in attempting
to write to the OutputStream.
|
30-Jun-2003 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |