-
1. Re: @Inject'able attributes not available for TestWatchman
aslak Apr 5, 2012 4:03 AM (in response to blabno)1 of 1 people found this helpfulYou 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
-
2. Re: @Inject'able attributes not available for TestWatchman
blabno Apr 12, 2012 5:40 AM (in response to aslak)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.
-
3. Re: @Inject'able attributes not available for TestWatchman
aslak Apr 12, 2012 9:13 AM (in response to blabno)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
Client LoadableExtension
AuxiliaryArchiveAppender
Container RemoteLoadableExtension
-
4. Re: @Inject'able attributes not available for TestWatchman
blabno Apr 13, 2012 5:48 AM (in response to aslak)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?
-
5. Re: @Inject'able attributes not available for TestWatchman
aslak Apr 13, 2012 9:52 AM (in response to blabno)Where are you trying to inject it?
-
6. Re: @Inject'able attributes not available for TestWatchman
blabno Apr 13, 2012 10:48 AM (in response to aslak)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();
return bean.create(beanManager.createCreationalContext(bean));
}
private BoundConversationContext getConversationContext()
{
return getContext(BoundConversationContext.class);
}
And this works. So extension works fine for conversation. Now I'm fighting ViewScopedContext.
-
7. Re: @Inject'able attributes not available for TestWatchman
blabno Apr 16, 2012 12:47 PM (in response to blabno)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.
Sources: https://github.com/blabno/mock-contexts-extension
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?
-
8. Re: @Inject'able attributes not available for TestWatchman
blabno Apr 19, 2012 7:52 AM (in response to blabno)I wrote blog post about the extension:
http://blog.it-crowd.com.pl/2012/04/mock-contexts-for-arquillian.html