|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.nitido.qabase.BaseTestCore
public abstract class BaseTestCore
This is the base class for a set of tests to be run in the QA environment. There are four concepts involved: TestCore, TestDriver, TestCase and TestStep.
A TestCore is an object that contains the logic of QA tests for a specific set of interfaces (or abstract implementation). Each TestCore is composed of test methods called TestCases. The method name of the TestCase methods are stored in the member variable methodNames (which is a java.util.Vector object). The QA execution code will invoke these method according to the sequence that they are stored.
A TestDriver is the first object to be invoked by the QA tests. It is responsible for setting up the environment for QA. Each TestDriver is designed for a specific implementation of certain modules. Figuratively speaking, TestDriver object "drives" one or more TestCore objects for QA testing. As a result, TestDriver object also contains the access methods for the TestCore it is designed to be executed with.
For example, the DataControl interface has different implementations, depending on the backend storage system. The LDAP-based DataControl will need a TestDriver that initialize the directory related parameter. (Note: it only set up the directory parameters, but it doesn't really connect to the server.) A hashtable-based DataControl will also has a TestDriver. However, both TestDriver will be able to use the same TestCore, which is designed for the DataControl interface instead of a specific implementation.
A TestCase is intended to encapsulate a set of test steps that requires certain setup and cleanup. The basic format of TestCase should be a big try-catch-finally block. A programmer can assume that the testing environment would return to the same state before the TestCase is executed, no matter the test succeed or failed. The TestCase may return one of the ResultStatus value. If it returns ResultStatus.FATAL, the execution will be stoped even if the methodNames vector still has more TestCase methods to be invoked.
For example, if a TestCase for a DataControl failed to contact the backend storage system, it should return ResultStatus.FATAL to stop executing the rest of TestCases.
A TestStep is a block of code within a TestCase method. It performs certain test action and check the result. If an major error occur, it would throw an exception to direct the logic to the TestCase's "finally" block (for cleaning up the TestCase).
Field Summary | |
---|---|
protected java.lang.String |
_caseId
The _caseId String is printed out by the default header (invoked through _stepHeader) and step completion message. |
protected java.lang.String |
_className
Just a quick temp store for the current runtime classname. |
protected BaseTestDriver |
_driver
The test driver object that is used by the test core. |
protected java.util.Vector |
_methodNames
The methodNames Vector contains all the TestCase method names. |
protected Logger |
_qaLogger
The _qaLogger member variable is an instance of com.nitido.util.Logger object. |
protected java.lang.String |
_stepDesc
The _stepDesc will appear as part of the error message. |
protected java.lang.String |
_stepId
The _stepId String is used in the same maner as _caseId. |
Constructor Summary | |
---|---|
BaseTestCore(BaseTestDriver driver)
Class constructor. |
Method Summary | |
---|---|
protected void |
checkEitherValueFromObject(java.lang.Object exp1,
java.lang.Object exp2,
java.lang.Object tempObj)
Check whether the object matches one of the epxected value. |
protected void |
checkEmptyArray(java.lang.Object[] array)
Check whether the array is empty. |
protected void |
checkEmptyEnum(java.util.Enumeration en)
Check whether the enumeration is empty. |
protected void |
checkEmptyVector(java.util.Vector vec)
Check whether the vector is empty. |
protected void |
checkIntValueFromInt(int expected,
int tempInt)
Check whether an int matches the expected value. |
protected void |
checkNotNullFromObject(java.lang.Object tempObj)
Check whether an object is a non-null object. |
protected void |
checkSingleValueFromEnum(java.lang.Object expected,
java.util.Enumeration en)
Check whether the enumeration contain only a single object, which also matches the expected value. |
protected void |
checkSingleValueFromObject(java.lang.Object expected,
java.lang.Object tempObj)
Check whether an object matches the expected value. |
protected void |
checkSingleValueFromVector(java.lang.Object expected,
java.util.Vector vec)
Check whether the vector contain only a single object, which also matches the expected value. |
protected void |
checkValuesFromArray(java.lang.Object[] expectedValues,
int[] expectedCounts,
java.lang.Object[] array)
Check whether the array contains the expected values (and also the expected times of appearance). |
protected void |
checkValuesFromEnum(java.lang.Object[] expectedValues,
int[] expectedCounts,
java.util.Enumeration en)
Check whether the enumeration contains the expected values (and also the expected times of appearance). |
protected void |
checkValuesFromVector(java.lang.Object[] expectedValues,
int[] expectedCounts,
java.util.Vector vec)
Check whether the vector contains the expected values (and also the expected times of appearance). |
protected static Logger |
getLogger(java.lang.Class categoryClass)
This method returns a Category class used for logging QA executions. |
java.util.Enumeration |
getMethodNames()
This method returns an enumeration with all the methods that are to be executed by the test driver. |
java.lang.String |
getProperty(java.lang.String propKey)
Retrieves the value associated to the key from the default property section. |
java.lang.String |
getProperty(java.lang.String section,
java.lang.String propKey)
Retrieves the value associated to the key from the specified property section. |
java.lang.String |
getPropertyWithDefault(java.lang.String propKey,
java.lang.String defaultValue)
Retrieves the value associated to the key from the default property section. |
java.lang.String |
getPropertyWithDefault(java.lang.String section,
java.lang.String propKey,
java.lang.String defaultValue)
Retrieves the value associated to the key from the specified property section. |
protected BaseTestDriver |
getTestDriver()
This method returns the test driver used that runs the test cases described by this class. |
protected void |
handleFailureException(java.lang.Exception failEx)
Print out the standard failure Exception message. |
protected void |
stepHeader(java.lang.String msg)
Print out the Header for a step. |
protected void |
stepOK()
Print out the message "case_id: step_id completed successfully". |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected BaseTestDriver _driver
This member variable should be accessed by implementor of BaseTestCore only.
protected java.lang.String _caseId
This member variable should be accessed by implementor of BaseTestCore only.
protected java.lang.String _stepId
This member variable should be accessed by implementor of BaseTestCore only.
protected java.lang.String _stepDesc
protected java.util.Vector _methodNames
protected Logger _qaLogger
protected java.lang.String _className
Constructor Detail |
---|
public BaseTestCore(BaseTestDriver driver)
driver
- The test driver that executes the TestCase defined in this
test core. Constructors of all child classes should always
call this constructor.Method Detail |
---|
protected final BaseTestDriver getTestDriver()
public java.util.Enumeration getMethodNames()
BaseTestDriver
protected static final Logger getLogger(java.lang.Class categoryClass)
categoryClass
- The class of the new logger instance
protected void stepHeader(java.lang.String msg)
msg
- The message to be printed in the header.protected void stepOK()
protected void checkNotNullFromObject(java.lang.Object tempObj) throws java.lang.Exception
If the object turns out to be null, an error message "case_id: step_id failed to get a non-null object." will be printed to the qa_execution log at INFO level, while the detail information of the object will be printed at DEBUG level.
tempObj
- The object to be check.
java.lang.Exception
- Exception will be thrown if the check failed.protected void checkSingleValueFromObject(java.lang.Object expected, java.lang.Object tempObj) throws java.lang.Exception
If the object doesn't matches the expected value, an error message "case_id: step_id failed to get expected value." will be printed to the qa_execution log at INFO level, while the detail information of the object will be printed at DEBUG level. The comparison is done through Object.equals().
expected
- The expected value. This can be null object.tempObj
- The object to be check.
java.lang.Exception
- Exception will be thrown if the check failed.protected void checkIntValueFromInt(int expected, int tempInt) throws java.lang.Exception
If the int does not match the expected value, an error message "case_id: step_id failed to get expected int value." will be printed to the qa_execution log at INFO level, while the detail information of the object will be printed at DEBUG level.
expected
- The expected value.tempInt
- The int to be check.
java.lang.Exception
- Exception will be thrown if the check failed.protected void checkEitherValueFromObject(java.lang.Object exp1, java.lang.Object exp2, java.lang.Object tempObj) throws java.lang.Exception
If the object does not match any of the expected values, an error message "case_id: step_id failed to get expected value." will be printed to the qa_execution log at INFO level, while the detail information of the object and expected values will be printed at DEBUG level. The comparison is done through Object.equals().
exp1
- The first expected value. This can be null object.exp2
- The second expected value. This can be null object.tempObj
- The object to be compared.
java.lang.Exception
- Exception will be thrown if the check failed.protected void checkSingleValueFromEnum(java.lang.Object expected, java.util.Enumeration en) throws java.lang.Exception
If the object does not match any of the expected values, an error message "case_id: step_id failed to get expected value." will be printed to the qa_execution log at INFO level, while the detail information of the object and expected values will be printed at DEBUG level. The comparison is done through Object.equals().
expected
- The expected value. This can be null object.en
- The enumeration to be compared.
java.lang.Exception
- Exception will be thrown if the check failed.protected void checkSingleValueFromVector(java.lang.Object expected, java.util.Vector vec) throws java.lang.Exception
If the object does not match any of the expected values, an error message "case_id: step_id failed to get expected value." will be printed to the qa_execution log at INFO level, while the detail information of the object and expected values will be printed at DEBUG level. The comparison is done through Object.equals().
expected
- The expected value. This can be null object.vec
- The vector to be compared.
java.lang.Exception
- Exception will be thrown if the check failed.protected void checkEmptyEnum(java.util.Enumeration en) throws java.lang.Exception
If the object does not match any of the expected values, an error message "case_id: step_id got unexpected enumeration instead of an empty one." will be printed to the qa_execution log at INFO level, while the detail information of the object and expected values will be printed at DEBUG level. The comparison is done through Object.equals().
en
- The enumeration to be compared.
java.lang.Exception
- Exception will be thrown if the check failed.protected void checkEmptyVector(java.util.Vector vec) throws java.lang.Exception
If the object does not match any of the expected values, an error message "case_id: step_id got unexpected vector instead of an empty one." will be printed to the qa_execution log at INFO level, while the detail information of the object and expected values will be printed at DEBUG level. The comparison is done through Object.equals().
vec
- The vector to be compared.
java.lang.Exception
- Exception will be thrown if the check failed.protected void checkEmptyArray(java.lang.Object[] array) throws java.lang.Exception
If the object does not match any of the expected values, an error message "case_id: step_id got unexpected array instead of an empty one." will be printed to the qa_execution log at INFO level, while the detail information of the object and expected values will be printed at DEBUG level. The comparison is done through Object.equals().
array
- The array to be compared.
java.lang.Exception
- Exception will be thrown if the check failed.protected void checkValuesFromEnum(java.lang.Object[] expectedValues, int[] expectedCounts, java.util.Enumeration en) throws java.lang.Exception
If at least one of the matches failed, an error message will be printed to the qa_execution log at INFO level, while the detail information of the object and expected values will be printed at DEBUG level. The comparison is done through Object.equals().
The error messages are:
expectedValues
- An array of object that contains all the expected values.expectedCounts
- If this parameter is declared null, this method will only check
if the specificed value appears at least once in the enumeration.
Otherwise, this parameter should be an array of int values that
represent the count of the expected number of appearance of the
associated value.
(i.e. the object that has the same index in the expectedValues array).
java.lang.Exception
- Exception will be thrown if an unexpected value exists in the
enumeration, or the expected occurrence count doesn't match the
actual count of appearance.protected void checkValuesFromVector(java.lang.Object[] expectedValues, int[] expectedCounts, java.util.Vector vec) throws java.lang.Exception
If at least one of the matches failed, an error message will be printed to the qa_execution log at INFO level, while the detail information of the object and expected values will be printed at DEBUG level. The comparison is done through Object.equals().
The error messages are:
expectedValues
- An array of object that contains all the expected values.expectedCounts
- If this parameter is declared null, this method will only check
if the specificed value appears at least once in the enumeration.
Otherwise, this parameter should be an array of int values that
represent the count of the expected number of appearance of the
associated value.
(i.e. the object that has the same index in the expectedValues array).
java.lang.Exception
- Exception will be thrown if an unexpected value exists in the
enumeration, or the expected occurrence count doesn't match the
actual count of appearance.protected void checkValuesFromArray(java.lang.Object[] expectedValues, int[] expectedCounts, java.lang.Object[] array) throws java.lang.Exception
If at least one of the matches failed, an error message will be printed to the qa_execution log at INFO level, while the detail information of the object and expected values will be printed at DEBUG level. The comparison is done through Object.equals().
The error messages are:
expectedValues
- An array of object that contains all the expected values.expectedCounts
- If this parameter is declared null, this method will only check
if the specificed value appears at least once in the array.
Otherwise, this parameter should be an array of int values that
represent the count of the expected number of appearance of the
associated value.
(i.e. the object that has the same index in the expectedValues array).
java.lang.Exception
- Exception will be thrown if an unexpected value exists in the
array, or the expected occurrence count doesn't match the
actual count of appearance.public final java.lang.String getProperty(java.lang.String propKey)
propKey
- The property key.
public final java.lang.String getProperty(java.lang.String section, java.lang.String propKey)
section
- The section name.propKey
- The property key.
public final java.lang.String getPropertyWithDefault(java.lang.String propKey, java.lang.String defaultValue)
propKey
- The property key.defaultValue
- The default value to be returned if the property key has no value.
public final java.lang.String getPropertyWithDefault(java.lang.String section, java.lang.String propKey, java.lang.String defaultValue)
section
- The section name.propKey
- The property key.defaultValue
- The default value to be returned if the property key has no value.
protected void handleFailureException(java.lang.Exception failEx)
failEx
- The failed exception object.
|
Nitido NiM 2.5 Java API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1999-2009 Nitido Inc. Proprietary and Confidential. All Rights Reserved.