The ResolverRegistry

Resolvers of all kinds can be implemented via the resolvers module as Jython or Groovy scripts as described in section 53.1. Unless you want to understand how the resolvers module itself works or want to implement a resolver in Java you may skip the following sections.

This section describes how to implement a resolver directly by Java classes. However, this will make the code of your application depend on QF-Test classes. The preferred alternative is to implement the resolver interfaces in Jython or Groovy. That way the whole mechanism can be strictly separated from the SUT and will not interfere with the build process.

Additionally to the resolver registration described in this section you need to implement the resolver interfaces described from subsection 53.1.7 and following.

The need for describing such a method as an interface that has to implemented by a class makes resolvers difficult at Java level. Then an instance of that class has to be created and registered for use by QF-Test. If you don't get it right on first try, that instance has to be deregistered before a new instance from a new class can be created and instance thereof registered, otherwise there may be interference between the two versions of the resolver. Add some code for error handling and you've got many times more glue code than actual "flesh".

As stated in section Implementation all exceptions thrown inside a name resolver will be caught and handled by the ResolverRegistry. However, instead of dumping a stack trace, the registry will only print a short message like "Exception inside NameResolver" because some resolvers may be called very often, and a buggy resolver printing a stack trace for every error would flood the net and the client terminal. Therefore name resolvers should include their own error handling. This can still generate a lot of output in some cases, but the output will be more useful than a Java stack trace.

Before implementing a resolver in Java please have a look at sections subsection 53.1.1 and subsection 53.1.2, where everything not specific to scripts and the resolvers module itself holds true for resolvers implemented in Java as well.

The singleton class de.qfs.apps.qftest.extensions.ResolverRegistry is the central agent for registering and removing name resolvers.

The ResolverRegistry API is pretty straightforward:

 
 
static String getElementName(Object element)
This static method should be used instead of com.getName() or widget.getData() by resolvers that need to operate based on existing names of elements, except for a NameResolver2 that gets just the original name passed to its getName method. This method suppresses trivial or AWT/Swing specific component names that QF-Test handles specially.
Parameters
elementThe element to get the name for.
Returns The name of the element or null if a trivial or special name is suppressed.
 
static ResolverRegistry instance()
There can only ever be one ResolverRegistry object and this is the method to get hold of this singleton instance.
ReturnsThe singleton ResolverRegistry instance.
 
static boolean isInstance(Object object, String className)
This static method should be used instead of instanceof (or isinstance() in Jython). It checks whether an object is an instance of a given class. The check is performed by name instead of through reflection, so conflicts with differing class loaders are prevented and there is no need to import the class to check against.
Parameters
objectThe object to check.
classNameThe name of the class to test for.
Returns True if the object is an instance of the given class.
 
void registerExtraFeatureResolver(ExtraFeatureResolver resolver)
Register a generic or global extra feature resolver.
Parameters
resolver The resolver to register.
 
void registerExtraFeatureResolver(Object element, ExtraFeatureResolver resolver)
Register an extra feature resolver for an individual GUI element. The resolver does not prevent garbage collection and will be removed automatically when the element becomes unreachable.
Parameters
element The GUI element to register for.
resolver The resolver to register.
 
void registerExtraFeatureResolver(String clazz, ExtraFeatureResolver resolver)
Register an extra feature resolver for a GUI element class.
Parameters
clazz The name of the class to register for.
resolver The resolver to register.
 
void registerFeatureResolver2(FeatureResolver2 resolver)
Register a generic or global feature resolver.
Parameters
resolver The resolver to register.
 
void registerFeatureResolver2(Object element, FeatureResolver2 resolver)
Register a feature resolver for an individual GUI element. The resolver does not prevent garbage collection and will be removed automatically when the element becomes unreachable.
Parameters
element The GUI element to register for.
resolver The resolver to register.
 
void registerFeatureResolver2(String clazz, FeatureResolver2 resolver)
Register a feature resolver for a GUI element class.
Parameters
clazz The name of the class to register for.
resolver The resolver to register.
 
void registerIdResolver(IdResolver resolver)
Register a generic or global ID resolver.
Parameters
resolver The resolver to register.
 
void registerIdResolver(Object element, IdResolver resolver)
Register an ID resolver for an individual GUI element. The resolver does not prevent garbage collection and will be removed automatically when the element becomes unreachable.
Parameters
element The GUI element to register for.
resolver The resolver to register.
 
void registerIdResolver(String clazz, IdResolver resolver)
Register an ID resolver for a GUI element class.
Parameters
clazz The name of the class to register for.
resolver The resolver to register.
 
void registerNameResolver2(NameResolver2 resolver)
Register a generic or global name resolver.
Parameters
resolver The resolver to register.
 
void registerNameResolver2(Object element, NameResolver2 resolver)
Register a name resolver for an individual GUI element. The resolver does not prevent garbage collection and will be removed automatically when the element becomes unreachable.
Parameters
element The GUI element to register for.
resolver The resolver to register.
 
void registerNameResolver2(String clazz, NameResolver2 resolver)
Register a name resolver for a GUI element class.
Parameters
clazz The name of the class to register for.
resolver The resolver to register.
 
void registerTreeTableResolver(TreeTableResolver resolver)
Register a generic or global TreeTable resolver.
Parameters
resolver The resolver to register.
 
void registerTreeTableResolver(Object com, TreeTableResolver resolver)
Register a TreeTable resolver for a specific component. The resolver will be removed automatically if the component becomes invisible.
Parameters
com The component to register for.
resolver The resolver to register.
 
void registerTreeTableResolver(String clazz, TreeTableResolver resolver)
Register a TreeTable resolver for a component class.
Parameters
clazz The name of the class to register for.
resolver The resolver to register.
 
void unregisterExtraFeatureResolver(ExtraFeatureResolver resolver)
Unregister a generic or global extra feature resolver.
Parameters
resolver The resolver to unregister.
 
void unregisterExtraFeatureResolver(Object element, ExtraFeatureResolver resolver)
Unregister an extra feature resolver for an individual GUI element.
Parameters
element The GUI element to unregister for.
resolver The resolver to unregister.
 
void unregisterExtraFeatureResolver(String clazz, ExtraFeatureResolver resolver)
Unregister an extra feature resolver for a GUI element class.
Parameters
clazz The name of the class to unregister for.
resolver The resolver to unregister.
 
void unregisterFeatureResolver2(FeatureResolver2 resolver)
Unregister a generic or global feature resolver.
Parameters
resolver The resolver to unregister.
 
void unregisterFeatureResolver2(Object element, FeatureResolver2 resolver)
Unregister a feature resolver for an individual GUI element.
Parameters
element The GUI element to unregister for.
resolver The resolver to unregister.
 
void unregisterFeatureResolver2(String clazz, FeatureResolver2 resolver)
Unregister a feature resolver for a GUI element class.
Parameters
clazz The name of the class to unregister for.
resolver The resolver to unregister.
 
void unregisterIdResolver(IdResolver resolver)
Unregister a generic or global ID resolver.
Parameters
resolver The resolver to unregister.
 
void unregisterIdResolver(Object element, IdResolver resolver)
Unregister an ID resolver for an individual GUI element.
Parameters
element The GUI element to unregister for.
resolver The resolver to unregister.
 
void unregisterIdResolver(String clazz, IdResolver resolver)
Unregister an ID resolver for a GUI element class.
Parameters
clazz The name of the class to unregister for.
resolver The resolver to unregister.
 
void unregisterNameResolver2(NameResolver2 resolver)
Unregister a generic or global name resolver.
Parameters
resolver The resolver to unregister.
 
void unregisterNameResolver2(Object element, NameResolver2 resolver)
Unregister a name resolver for an individual GUI element.
Parameters
element The GUI element to unregister for.
resolver The resolver to unregister.
 
void unregisterNameResolver2(String clazz, NameResolver2 resolver)
Unregister a name resolver for a GUI element class.
Parameters
clazz The name of the class to unregister for.
resolver The resolver to unregister.
 
void unregisterResolvers(Object element)
Unregister all resolvers for a specific GUI element.
Parameters
element The element to unregister for.
 
void unregisterResolvers(String clazz)
Unregister all resolvers for the class of a GUI element, value or renderer.
Parameters
clazz The name of the class to unregister for.
 
void unregisterTreeTableResolver(TreeTableResolver resolver)
Unregister a generic or global TreeTable resolver.
Parameters
resolver The resolver to unregister.
 
void unregisterTreeTableResolver(Object com, TreeTableResolver resolver)
Unregister a TreeTable resolver for a specific component.
Parameters
com The component to unregister for.
resolver The resolver to unregister.
 
void unregisterTreeTableResolver(String clazz, TreeTableResolver resolver)
Unregister a TreeTable resolver for a component class.
Parameters
clazz The name of the class to unregister for.
resolver The resolver to unregister.