[EJB 3.0] - Re: EjB3 & JBoos AS - JUnit testing
by obfuscator
"karl.martens" wrote : I've just had a brief look at the Jakarta Cactus and it look promising. I will investigate and see if I can get it to work for my needs.
|
| AS far as connecting as a client it depends what you mean. I had considered using a test running like Watir and Ruby to test the application via http request response. I will use this approach for high level business case tests but I've found that the speed of these type of tests make it difficult to get high degrees of test coverage.
|
| If you meant connecting directly to the EJBs vie a remote interface, I hadn't considered that.
|
| Thanks for your reply much appreciated, gave me something to consider.
No problem. Unit testing of EJB:s is still a pain I think. I've really been waiting for the embeddable container, since this would simplify a great deal. I usually write separate ejbs for unit testing, just to be able to inject any dependencies I need. Regarding the client high level-approach, I agree with you that it's pretty useless since the pre and postconditions are to much of a hassle to check. Would be sweet to have a TestNG-pojo and just get the entity manager in a nice and clean way. Of course, this requires being in the same JVM, and hence you need to deploy the tests to the server (cactus helps here), or start the server in local JVM (embeddable).
The other problem I'm having is that maven expects the tests to be able to run directly after compilation, which usually makes me having a separate subproject for my ejb unit test. This does encourage refactoring a lot of logic into utility classes (makes that logic easily testable) , which I think is good, but the tests needs to be separated from the actual build and deploy process, which I think is really bad.
I like this discussion. Does anyone have a nice clean solution for how to unit test J2EE projects?
I'm happy to contribute with the stuff I've came up with (config, patterns, code etc).
Regards
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4043149#4043149
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4043149
18 years, 12 months
[JBoss Seam] - Re: Transaction Demarcation
by toni
Well thank you for clarifying this! I was already wondering why seam would introduce an extra transaction annotation, which lacks some of the EJB3 transactional attributes.
anonymous wrote :
| By the way, you can always use the TransactionalSeamPhaseListener and @TransactionAttribute(REQUIRES_NEW) to suspend the existing transaction during a particular method call in INVOKE APPLICATION. Your method then executes in a new transaction context - which is committed when the method returns.
|
| As long as your are using a Seam-managed persistence context with@In EntityManager, this should work fine even if your method calls other transactional methods that use the entity manager.
|
However, I still have to say that tagging my method with @TransactionAttribute(REQUIRES_NEW) and using a "TransactionalSeamPhaseListener" does not work: All the data is written at the very end of the invocation, which takes about 20 minutes.
Do you have any idea why your suggestion does/might not work in my szenario, which is:
User klicks a link, which calls an action method of a SFSB (statefull), which then calls a SLSB (stateless), which start inserting many entities by repeately calling local methods of which some again call another SLSB's method.
BTW: In another forum thread somebody told me to use @TransactionTimeout, when I ran into a TransactionTimeout exception, which occurred because the process lasts for 20 minutes. I tried that without any luck.
I had to increase the Timeout in jta-service.xml in order for this single transaction to complete at all. Because the suggested annotation did not extend the Timeout and because your suggestions does not work for me either, I get the feeling that those EJB3 annotations are not working with/on seam components.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4043146#4043146
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4043146
18 years, 12 months