public class EJBInjectionEnricher extends java.lang.Object implements TestEnricher
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ANNOTATION_NAME |
private Instance<javax.naming.Context> |
contextInst |
private static java.util.logging.Logger |
log |
Constructor and Description |
---|
EJBInjectionEnricher() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
attemptToGet31LookupField(javax.ejb.EJB annotation) |
protected javax.naming.Context |
createContext() |
void |
enrich(java.lang.Object testCase)
Extension point to add features to the a Test class instance.
IE. |
protected java.util.List<java.lang.reflect.Field> |
getFieldsWithAnnotation(java.lang.Class<?> clazz,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Obtains all field in the specified class which contain the specified annotation
|
protected java.lang.String[] |
getJndiNamesForAnonymousEJB(java.lang.Class<?> fieldType) |
private boolean |
hasValue(java.lang.String string)
Helper method that checks if the given String has a non-empty value.
|
protected void |
injectClass(java.lang.Object testCase) |
private boolean |
isMoreThanOneValueTrue(boolean... values) |
private java.lang.String |
joinJndiNames(java.lang.String[] strings) |
protected java.lang.Object |
lookupEJB(java.lang.String[] jndiNames) |
java.lang.Object[] |
resolve(java.lang.reflect.Method method)
Extension point to add features to the test method arguments.
IE. |
protected java.lang.String[] |
resolveJNDINames(java.lang.Class<?> fieldType,
java.lang.String mappedName,
java.lang.String beanName,
java.lang.String lookup)
Resolves the JNDI name of the given field.
|
private static final java.lang.String ANNOTATION_NAME
private static final java.util.logging.Logger log
public void enrich(java.lang.Object testCase)
TestEnricher
enrich
in interface TestEnricher
testCase
- The test case instancepublic java.lang.Object[] resolve(java.lang.reflect.Method method)
TestEnricher
TestEnricher
.resolve
in interface TestEnricher
protected java.util.List<java.lang.reflect.Field> getFieldsWithAnnotation(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotation) throws java.lang.IllegalArgumentException
clazz
- annotation
- java.lang.IllegalArgumentException
- If either argument is not specifiedprotected void injectClass(java.lang.Object testCase)
protected java.lang.String attemptToGet31LookupField(javax.ejb.EJB annotation) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
protected java.lang.String[] resolveJNDINames(java.lang.Class<?> fieldType, java.lang.String mappedName, java.lang.String beanName, java.lang.String lookup)
EJB
annotation attributes is specified at the same time, an IllegalStateException
will be thrown.fieldType
- annotated field which JNDI name should be resolved.mappedName
- Value of EJB
's mappedName attribute.beanName
- Value of EJB
's beanName attribute.lookup
- Value of EJB
's lookup attribute.protected java.lang.String[] getJndiNamesForAnonymousEJB(java.lang.Class<?> fieldType)
protected java.lang.Object lookupEJB(java.lang.String[] jndiNames) throws java.lang.Exception
java.lang.Exception
protected javax.naming.Context createContext() throws java.lang.Exception
java.lang.Exception
private java.lang.String joinJndiNames(java.lang.String[] strings)
private boolean hasValue(java.lang.String string)
string
- String to be checked.private boolean isMoreThanOneValueTrue(boolean... values)