org.jboss.arquillian.testenricher.ejb
Class EJBInjectionEnricher

java.lang.Object
  extended by org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher
All Implemented Interfaces:
TestEnricher

public class EJBInjectionEnricher
extends Object
implements TestEnricher

Enricher that provide EJB class and setter method injection.

Version:
$Revision: $
Author:
Aslak Knutsen

Constructor Summary
EJBInjectionEnricher()
           
 
Method Summary
protected  Context createContext()
           
 void enrich(Object testCase)
          Extension point to add features to the a Test class instance.

IE.
protected  List<Field> getFieldsWithAnnotation(Class<?> clazz, Class<? extends Annotation> annotation)
          Obtains all field in the specified class which contain the specified annotation
protected  void injectClass(Object testCase)
           
protected  Object lookupEJB(String[] jndiNames)
           
 Object[] resolve(Method method)
          Extension point to add features to the test method arguments.

IE.
protected  String[] resolveJNDINames(Class<?> fieldType, String mappedName, String beanName)
          Resolves the JNDI name of the given field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EJBInjectionEnricher

public EJBInjectionEnricher()
Method Detail

enrich

public void enrich(Object testCase)
Description copied from interface: TestEnricher
Extension point to add features to the a Test class instance.

IE. Instance field injection

Specified by:
enrich in interface TestEnricher
Parameters:
testCase - The test case instance

resolve

public Object[] resolve(Method method)
Description copied from interface: TestEnricher
Extension point to add features to the test method arguments.

IE. Argument injection

The return value Object[] must match the Field[] indexes. Leave Object[] index as null if it can't be handled by this TestEnricher.

Specified by:
resolve in interface TestEnricher
Returns:
A Object[] of Arguments

getFieldsWithAnnotation

protected List<Field> getFieldsWithAnnotation(Class<?> clazz,
                                              Class<? extends Annotation> annotation)
                                       throws IllegalArgumentException
Obtains all field in the specified class which contain the specified annotation

Parameters:
clazz -
annotation -
Returns:
Throws:
IllegalArgumentException - If either argument is not specified

injectClass

protected void injectClass(Object testCase)

resolveJNDINames

protected String[] resolveJNDINames(Class<?> fieldType,
                                    String mappedName,
                                    String beanName)
Resolves the JNDI name of the given field. If mappedName or beanName are specified, they're used to resolve JNDI name. Otherwise, default policy applies. If both, the mappedName and beanName, are specified at the same time, an IllegalStateException will be thrown.

Parameters:
fieldType - annotated field which JNDI name should be resolved.
mappedName - Value of EJB's mappedName attribute.
beanName - Value of EJB's beanName attribute.
Returns:
possible JNDI names which should be looked up to access the proper object.

lookupEJB

protected Object lookupEJB(String[] jndiNames)
                    throws Exception
Throws:
Exception

createContext

protected Context createContext()
                         throws Exception
Throws:
Exception


Copyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.