org.jvnet.hk2.testing.junit
Class HK2Runner
java.lang.Object
org.jvnet.hk2.testing.junit.HK2Runner
public class HK2Runner
- extends Object
This class should be extended by test classes in order to get an automatically
filled in ServiceLocator. By default the testLocator will inspect the package
of the test to find any classes annotated with @Service. The locator will
also be able to do second-chance advertisement of services that were injected.
The default ServiceLocator will also have an error handler that causes any classloading
failure to get rethrown up to the lookup call, since this can sometimes cause
confusion.
This behavior can be customized by overriding the before method and calling the super
of one of the other methods available for customization
- Author:
- jwells
Method Summary |
void |
before()
This will generate the default testLocator for this test
class, which will search the package of the test itself for
classes annotated with @Service. |
protected void |
initialize(String name,
List<String> packages,
List<Class<?>> clazzes)
This method initializes the service locator with services from the given list
of packages (in "." format) and with the set of classes given. |
protected void |
setVerbosity(boolean verbose)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
testLocator
protected ServiceLocator testLocator
- Test classes can use this service locator as their private test locator
HK2Runner
public HK2Runner()
before
public void before()
- This will generate the default testLocator for this test
class, which will search the package of the test itself for
classes annotated with @Service.
initialize
protected void initialize(String name,
List<String> packages,
List<Class<?>> clazzes)
- This method initializes the service locator with services from the given list
of packages (in "." format) and with the set of classes given.
- Parameters:
name
- The name of the service locator to create. If there is already a
service locator of this name then the remaining fields will be ignored and the existing
locator with this name will be returned. May not be nullpackages
- The list of packages (in "." format, i.e. "com.acme.test.services") that
we should hunt through the classpath for in order to find services. If null this is considered
to be the empty setclazzes
- A set of classes that should be analyzed as services, whether they declare
@Service or not. If null this is considered to be the empty set
setVerbosity
protected void setVerbosity(boolean verbose)
Copyright © 2013 Oracle Corporation. All Rights Reserved.