1 of 1 people found this helpful
You should be able to do that using the Arquillian SPI's.. They are a bit under documented at the moment, but work in progress: https://github.com/aslakknutsen/arquillian.github.com/blob/spi_guide/guides/getting_started_spi.textile
Aslak, I've tried using SPI, but it look's like the events are raised locally (my jboss is remote) and I need to start context (or transaction) inside the server.
Arquillian has two sides to it, the Client side and the Container side.
You can use the AuxiliaryArchiveAppender to create a Container v of your self, which register a RemoteLoadableExtension (same as LoadableExtension but used in Container)
See e.g. the CDI TestEnricher
Aslak, I've encountered problems (BoundConversationContext class not found from arquillian-service). Well it looks like when i'm using "Servlet 3.0" protocol then all libraries generated by AuxiliaryArchiveAppender are packaged into WAR, but if I don't specify that protocol then those jars are packaged into "arquillian-service.jar" but that jar doesn't have "Dependencies:org.jboss.weld.core" and looking at the code I think that there is no way currently to merge dependencies of extension generated archives into that "arquillian-service.jar".
Other thing is that even with "Servlet 3.0" protocol I can't get the BoundConversationContext injected (it's null). BTW. which Inject annotation should I use from javax.inject or from arquillian?
Where are you trying to inject it?
I've already solved that problem. I was trying to inject (using javax.enterprise.inject.Instance) BoundConversationContext into class that is registered by remote extension as observer. Right now I'm injecting BeanManager and retrieve ConversationContext like that:
private <T extends Context> T getContext(Class<T> contextClass)
final BeanManager beanManager = beanManagerInstance.get();
@SuppressWarnings("unchecked") final Bean<T> bean = (Bean<T>) beanManager.getBeans(contextClass).iterator().next();
private BoundConversationContext getConversationContext()
And this works. So extension works fine for conversation. Now I'm fighting ViewScopedContext.
I've implemented the extension for this. It supports starting/stopping Conversation and View contexts for each test. Look at "test" module for usage. Currently it's bound tightly with Weld due to BoundConversationContext usage.
I've faces strange problem. I've annotated MockViewScopedContext as ApplicationScoped but when I tried to inject it into MockViewScopedCDIExtension it was a different instance then the one obtained later from BeanManager inside MockContextsManager.startContexts. Any idea why?