org.jvnet.hk2.testing.junit
Class HK2Runner

java.lang.Object
  extended by 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

Field Summary
protected  ServiceLocator testLocator
          Test classes can use this service locator as their private test locator
 
Constructor Summary
HK2Runner()
           
 
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
 

Field Detail

testLocator

protected ServiceLocator testLocator
Test classes can use this service locator as their private test locator

Constructor Detail

HK2Runner

public HK2Runner()
Method Detail

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 null
packages - 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 set
clazzes - 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.