Hi,
i started building some TestClasses that all share some code, like the @Deployment,...
My Problem now is that when the TestCase is started all Beans annotated with @EJB are null.
Arquillian Version 1.0.0 Alpha4 with openejb 3.1
Here is the Code:
@RunWith(Arquillian.class)
public abstract class AbstractTestContext
{
@EJB
protected BeanOne beanOne;
@EJB
protected BeanTwo beanTwo;
@Deployment
public static JavaArchive getContextDeployment()
{
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addPackages(true, RootClass.class.getPackage())
.addManifestResource("persistence.xml");
}
}
public class MyTest extends AbstractTestContext
{
@Test
public void testBeanOne()
{
Assert.assertNotNull(beanOne);
}
@Test
public void testBeanOne()
{
Assert.assertNotNull(beanOne);
}
}
After searching the Arquillian code i found the code for my problem in the Class:
org.jboss.arquillian.testenricher.ejb.SecurityActions
static List<Field> getFieldsWithAnnotation(final Class<?> source, final Class<? extends Annotation> annotationClass)
{
List<Field> declaredAccessableFields = AccessController.doPrivileged(new PrivilegedAction<List<Field>>()
{
public List<Field> run()
{
List<Field> foundFields = new ArrayList<Field>();
for(Field field : source.getDeclaredFields()) //<--------- there it is, it just ge the fields in upper class
{
if(field.isAnnotationPresent(annotationClass))
{
if(!field.isAccessible())
{
field.setAccessible(true);
}
foundFields.add(field);
}
}
return foundFields;
}
});
return declaredAccessableFields;
}
Is there a reason for that or is this a bug ?
thx,
Leopold Odenthal
Correct, this is suppose to work. Please file a Jira Issue. jira.jboss.org/jira/browse/ARQ