jbeantester.framework
Class JBeanTester

java.lang.Object
  |
  +--jbeantester.framework.JBeanTester

public class JBeanTester
extends Object

The JavaBeanTester class performs all testing. A developer would instantiate an instance of this class and then use one (or more) of the test methods and then compare the JBeanTestResults returned to the expected results.


Field Summary
protected  Logger cat
          A Logger to use in this object and all derivatives.
 
Constructor Summary
JBeanTester()
          Default constructor.
 
Method Summary
protected  Object getParamToUse(Class paramType)
          Obtain an object to use to satisfy this parameter.
 JBeanTestResults testJBeanConstructor(Class clazz, String[] params)
           Test that the specified constructors function properly.
 JBeanTestResults testJBeanProperties(Class clazz)
           This method is used to test the properties of a default consttucted instance of Classes conforming to the JavaBean Specification.
 JBeanTestResults testJBeanProperties(Object obj)
           This method is used to test the properties of Objects conforming to the JavaBean Specification.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cat

protected final Logger cat
A Logger to use in this object and all derivatives.

Constructor Detail

JBeanTester

public JBeanTester()
Default constructor.

Method Detail

getParamToUse

protected Object getParamToUse(Class paramType)
Obtain an object to use to satisfy this parameter. Determine type and instantiate, if possible, an instance (representing the next value in the sequence where possible) of the specified class.

Parameters:
paramType - the type of the object to be instantiated.
Returns:
the object of type paramType to pass as a parameter to this method.

testJBeanProperties

public JBeanTestResults testJBeanProperties(Class clazz)

This method is used to test the properties of a default consttucted instance of Classes conforming to the JavaBean Specification. This method constructs an instance of the specified Class and passes it to the overloaded version of this method accepting an Object. Please see the documentation for that method.

If any Exception or Error condition is encountered while examining the methods, the condition is logged and that property is ignored.

Note that no JUnit Assertions are made within this method. All results are returned for processing within the testCase.

Note that this object is not thread safe.

Parameters:
clazz - the class to be instantiated and tested; error on null.
Returns:
the results of the testing to be analysed within a test case.

testJBeanProperties

public JBeanTestResults testJBeanProperties(Object obj)

This method is used to test the properties of Objects conforming to the JavaBean Specification. An attempt is made to match up mutators (setters) accepting one parameter with appropriate accessors (getters). For those pairs found, an attempt is made at constructing input parameters. Each mutator is called with the appropriate data followed by each accessor to check that the return value matches.

Input data is constructed with sequentially different values. For non-primitive objects or their wrappers (those items found in java.lang) an attempt is made to construct an instance using the default constructor (no parameters). If this fails, the property is skipped.

Mutators must begin with 'set' while accessors must begin with 'get' unless the parameter is a boolean (primitive) in which case it may also begin with 'is'.

If any Exception or Error condition is encountered while examining the methods, the condition is logged and that property is ignored.

Note that no JUnit Assertions are made within this method. All results are returned for processing within the testCase.

Note that this object is not thread safe.

Parameters:
obj - the object to be tested; error on null.
Returns:
the results of the testing to be analysed within a test case.

testJBeanConstructor

public JBeanTestResults testJBeanConstructor(Class clazz,
                                             String[] params)

Test that the specified constructors function properly. Test that the constructor exists and that the getters for the specified properties return the expected values. If the the specified constructor does not exist, JBeanTestResults.NO_SUCH_CONSTRUCTOR will be returned.

Parameters:
clazz - the class to be tested.
params - the names of the properties which comprise the constructor to be tested.
Returns:
the results of the tests performed; JBeanTestResults.NO_SUCH_CONSTRUCTOR if no such constructor exists.