Arquillian TestEnricher Resource 1.0.0.CR5

org.jboss.arquillian.testenricher.resource
Class ResourceInjectionEnricher

java.lang.Object
  extended by org.jboss.arquillian.testenricher.resource.ResourceInjectionEnricher
All Implemented Interfaces:
TestEnricher

public class ResourceInjectionEnricher
extends Object
implements TestEnricher

Enricher that provide @Resource field and method argument injection.

Field Resources will only be injected if the current value is NULL or primitive default value.

Version:
$Revision: $
Author:
Aslak Knutsen

Constructor Summary
ResourceInjectionEnricher()
           
 
Method Summary
 void enrich(Object testCase)
           
protected  Context getContainerContext()
          Obtains the appropriate context for the test.
protected  String getResourceName(Field field)
           
protected  String getResourceName(Resource resource)
           
protected  void injectClass(Object testCase)
           
protected  Object lookup(String jndiName)
           
 Object[] resolve(Method method)
           
protected  Object resolveResource(AnnotatedElement element)
          Looks up the JNDI resource for any given annotated element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceInjectionEnricher

public ResourceInjectionEnricher()
Method Detail

enrich

public void enrich(Object testCase)
Specified by:
enrich in interface TestEnricher

resolve

public Object[] resolve(Method method)
Specified by:
resolve in interface TestEnricher

injectClass

protected void injectClass(Object testCase)

resolveResource

protected Object resolveResource(AnnotatedElement element)
                          throws Exception
Looks up the JNDI resource for any given annotated element.

Parameters:
element - any annotated element (field, method, etc.)
Returns:
the located resource
Throws:
Exception

lookup

protected Object lookup(String jndiName)
                 throws Exception
Throws:
Exception

getContainerContext

protected Context getContainerContext()
                               throws NamingException
Obtains the appropriate context for the test. Can be overriden by enrichers for each container to provide the correct context.

Returns:
the test context
Throws:
NamingException

getResourceName

protected String getResourceName(Field field)

getResourceName

protected String getResourceName(Resource resource)

Arquillian TestEnricher Resource 1.0.0.CR5

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