-
1. Re: how to test an EJB through management interface & a JBoss POJO bean
aslak Oct 15, 2010 7:28 AM (in response to csabaszucs)1 of 1 people found this helpfulI believe what you want is this:
https://jira.jboss.org/browse/ARQ-265
We currently do not support this, but you are running incontainer so it shouldn't be to hard to get a hold of.
1) Management business interfaces, if i remember correctly are bound to the JMX, so you should be able to do something in the lines of:
MyEJBManagedView managedView = MBeanProxy.get( MyEJBManagedView.class, new ObjcetName("my.ejb:objectname"), MBeanServerLocator.locateJBoss());
2) For Pojo beans you would have to get a hold of the KernelController to lookup your Bean, something like:
KernelController kernelController = ((Kernel)MBeanServerLocator.locateJBoss().getAttribute( new ObjectName("jboss.system:type=Server"), "Kernel")).getController(); ControllerContext context = kernelController.getContext(new ObjectName("your-pojo-bean-name"), ControllerState.INSTALLED); MyPojo pojo = context.getTarget();
Both of these should be fairly simple to create TestEnrichers of by implementing the Arquillian SPI
Look at e.g. the @Resource injection enricher as a example:
For the Pojo enricher the basics are:
- Loop through all fields in the given instance testCase.getClass().getDeclaredFields()
- Check if the field is annotated with the mc inject, field.isAnnotationPresent(org.jboss.beans.metadata.api.annotations.Inject)
- If so, do the magic KernelController lookup etc above and set the result on the field. field.set(testCase, pojo);
Let me know if you want to contribute this back to Arquillian, I'll guide you through the contribution 'process'. (setting up repo, git fork / pull request etc etc)
-
2. Re: how to test an EJB through management interface & a JBoss POJO bean
jaikiran Oct 15, 2010 8:32 AM (in response to aslak)1 of 1 people found this helpfulMinor correction:
Aslak Knutsen wrote:
ControllerContext context = kernelController.getContext(new ObjectName("your-pojo-bean-name"), ControllerState.INSTALLED);
should be:
ControllerContext context = kernelController.getContext("your-pojo-bean-name", ControllerState.INSTALLED);
-
3. Re: how to test an EJB through management interface & a JBoss POJO bean
aslak Oct 15, 2010 8:52 AM (in response to jaikiran)aa yes.. thank you!
-
4. Re: how to test an EJB through management interface & a JBoss POJO bean
csabaszucs Oct 15, 2010 12:44 PM (in response to aslak)Sorry, an exception says there is no attribute called Kernel...
-
5. Re: how to test an EJB through management interface & a JBoss POJO bean
aslak Oct 15, 2010 1:25 PM (in response to csabaszucs)Sorry, forgot your on 5.1. The above is for 6.0. Trying to find where the Kernel is exposed via JMX in 5.1 as we speak..