-
1. Re: Accessing container's resources
aslak Nov 4, 2010 6:38 AM (in response to iapazmino)Not sure what you mean by Containers Resources, but.. you can reach anything on the Contianer side..
Making your own TestEnricher that expose a Container abstraction is fully possible.
Make a implementation of org.jboss.arquillian.spi.TestEnricher
public class ContainerEnricher implements TestEnricher { public void enrich(Context context, Object testInstance) { // pesudo for each testInstance.getClass().getDeclaredFields() field.isAnnotationPresent(Container.class) field.set(testInstance, new MyContainerAbstraction()) } }
Make a implementation of org.jboss.arquillian.spi.AuxiliaryArchiveAppender to package the TestEnricher
public class ContainerPackager implement AuxiliaryArchiveAppener { public Archive<?> createAuxiliaryArchive() { return ShrinkWrap.create(JavaArchive.class, "container-enricher.jar") .addClass(ContainerEnricher.class) .addServiceProvider(TestEnricher.class, ContainerEnricher.class); } }
Make a file in META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender that contain the fully qualified name for your ContainerPackager and you should be good to go.
-
2. Re: Accessing container's resources
iapazmino Nov 7, 2010 1:49 AM (in response to aslak)Thanks, you caught the spirit of the question. What I meant exactly is for instance I'm making an EJB interceptor to log in a separate log file some operations made by a session bean. So, in order to test it's working I need a way to acces from the test class the container's log service. Mmm sure resource is not what I mean to say, but maybe service would suit better. Anyway, I haven't found the way to access the currently running DeployableContainer instance from my enricher, but I'll open another post in that matter.