|
OOoRunner test harness | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
lib
Class MultiPropertyTest.PropertyTester
java.lang.Object | +--lib.MultiPropertyTest.PropertyTester
- Direct Known Subclasses:
- MultiPropertyTest.PropertyValueSwitcher
- Enclosing class:
- MultiPropertyTest
- public class MultiPropertyTest.PropertyTester
- extends Object
PropertyTester class defines how to test a property and defined to allow subclasses of MultiPropertyTest to change the testing behaviour more flexible, since the behaviour can be customized for each property separately, by providing subclass of PropertyTester and passing it to testProperty(String, PropertyTester method).
Constructor Summary | |
MultiPropertyTest.PropertyTester()
|
Method Summary | |
protected void |
checkResult(String propName,
Object oldValue,
Object newValue,
Object resValue,
Exception exception)
The method checks result of setting a new value to the property based o the following arguments: |
protected boolean |
compare(Object obj1,
Object obj2)
The method compares obj1 and obj2. |
protected Object |
getNewValue(String propName,
Object oldValue)
The method produces new value of the property from the oldValue. |
protected void |
testProperty(String propName)
The method defines the whole process of testing propName property. |
protected String |
toString(Object obj)
The method returns a String representation of the obj. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
MultiPropertyTest.PropertyTester
public MultiPropertyTest.PropertyTester()
Method Detail |
testProperty
protected void testProperty(String propName)
- The method defines the whole process of testing propName
property.
First, it checks if the property exists(it maybe optional). Then, a value to set the property with is calculated with getNewValue method. Normally, the new value is calculated based on old value, but subclasses can override the behaviour (for example, if old value is null) and specify their own value. Then the property is set with that new value and the result( it maybe an exception too, for example a PropertyVetoException) is checked with checkResult method.
- Parameters:
propName
- - the property to test.
checkResult
protected void checkResult(String propName, Object oldValue, Object newValue, Object resValue, Exception exception) throws Exception
- The method checks result of setting a new value to the
property based o the following arguments:
- Throws:
-
- if not null - the exception thrown by XPropertySet.setPropertyValue, else indicates normal method completion.If the property is READ_ONLY, than either PropertyVetoException should be thrown or the value of property should not have changed (resValue is compared with oldValue with compare method).
If the property is not READ_ONLY, checks that the new value has been successfully set(resValue is compared with newValue with compare method).
If the exception is not null then(except the case of read-only property and PropertyVetoException above) it is rethrown to allow further catching it if needed.
Subclasses can override to change this behaviour.
getNewValue
protected Object getNewValue(String propName, Object oldValue) throws IllegalArgumentException
- The method produces new value of the property from the oldValue. It returns the result of ValueChanger.changePValue method. Subclasses can override the method to return their own value, when the changePValue beahviour is not enough, for example, when oldValue is null.
compare
protected boolean compare(Object obj1, Object obj2)
- The method compares obj1 and obj2. It calls MultiPropertyTest.compare, but subclasses can override to change the behaviour, since normally compare calls Object.equals method which is not apropriate in some cases(e.g., structs with equals not overridden).
toString
protected String toString(Object obj)
- The method returns a String representation of the obj. It calls MultipropertyTest.toString(Object), but subclasses can override to change the behaviour.
|
OOoRunner test harness | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |