Manual

44.3
The ResolverRegistry

Resolvers of all kinds can be implemented via the resolvers module as Jython or Groovy scripts as described in section 44.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 44.1.6 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 section The resolvers module. 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 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 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 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 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 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 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 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 registerNameResolver2(NameResolver2 resolver)
Register a generic or global name resolver.
Parameters
resolver The resolver to register.
 
void unregisterNameResolver2(NameResolver2 resolver)
Unregister a generic or global name resolver.
Parameters
resolver The resolver to unregister.
 
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 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 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 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 registerIdResolver(IdResolver resolver)
Register a generic or global ID resolver.
Parameters
resolver The resolver to register.
 
void unregisterIdResolver(IdResolver resolver)
Unregister a generic or global ID resolver.
Parameters
resolver The resolver to unregister.
 
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 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 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 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 registerFeatureResolver2(FeatureResolver2 resolver)
Register a generic or global feature resolver.
Parameters
resolver The resolver to register.
 
void unregisterFeatureResolver2(FeatureResolver2 resolver)
Unregister a generic or global feature resolver.
Parameters
resolver The resolver to unregister.
 
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 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 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 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 registerExtraFeatureResolver(ExtraFeatureResolver resolver)
Register a generic or global extra feature resolver.
Parameters
resolver The resolver to register.
 
void unregisterExtraFeatureResolver(ExtraFeatureResolver resolver)
Unregister a generic or global extra feature resolver.
Parameters
resolver The resolver to unregister.
 
void registerTreeTableResolver(Component 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 unregisterTreeTableResolver(Component com, TreeTableResolver resolver)
Unregister a TreeTable resolver for a specific component.
Parameters
com The component to unregister for.
resolver The resolver to unregister.
 
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 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.
 
void registerTreeTableResolver(TreeTableResolver resolver)
Register a generic or global TreeTable resolver.
Parameters
resolver The resolver to register.
 
void unregisterTreeTableResolver(TreeTableResolver resolver)
Unregister a generic or global TreeTable resolver.
Parameters
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.