-
1. Re: How do I use JSFUnit in these circumstances?
ssilvert Dec 1, 2010 8:36 AM (in response to jimd11)1 of 1 people found this helpfulThere are three approaches to this.
- Create a "testable" version of your WAR that gets bundled instead of the production version. This testable version contains a modified web.xml and the extra jars. It just requires some build tricks to make sure the testable WAR is the one that gets bundled with your EAR. That's pretty easy to do in Maven but tougher in Ant.
- Use the JSFUnit Deployer. I was going back and looking at this yesterday and I have reason to believe that the JSFUnit 1.3 version of the deployer was not built properly. I don't know if I will have time to go back and investigate this further. You might want to try the JSFUnit 1.2 version. The other thing about the deployer is that it only works with JBoss AS5. A lot of things changed in the deployment architecture in AS6 and it changes even more in AS7. So we will deprecate the JSFUnit Deployer anyway.
- Use Arquillian. This is the new way to do things going forward and it will be much smoother and easier. You can start using Arquillian-based JSFUnit tests right away if you are using a Servlet 3.0 container. JSFUnit 2.0 will support older containers. See the last section of the Arquillian documentation and this page on JSFUnit with CDI.
Regards,
Stan
-
2. Re: How do I use JSFUnit in these circumstances?
jimd11 Dec 2, 2010 10:10 AM (in response to ssilvert)Thanks Stan, I'll investigate the options you offer.
I like the look of Arquillian, so will probably look at that approach first.
-
3. Re: How do I use JSFUnit in these circumstances?
ssilvert Dec 2, 2010 1:37 PM (in response to jimd11)Jim Gallagher wrote:
Thanks Stan, I'll investigate the options you offer.
I like the look of Arquillian, so will probably look at that approach first.
Great. Just make sure you are using a Servlet 3.0 container like JBoss AS6. The version that works on older containers probably won't be ready for awhile.
Stan
-
4. Re: How do I use JSFUnit in these circumstances?
jimd11 Dec 13, 2010 4:57 AM (in response to ssilvert)OK, to update on this.
I decided against using Arquillian, for a couple of reasons:
- I'm not familiar with Maven, and have no real need to learn at the moment
- The need for JBoss AS6 is a show-stopper, as I'm limited to AS5 in production and need to develop on the same stack as in prod
I appreciate that #1 above is not a valid excuse, and that I really should learn about it, but it's not a priority at the moment.
So I went back to JSFUnit 1.2 microdeployer, and simply could not get this to work. I wanted it to recognise my WAR without me renaming it, so I amended the parameter in the exploded deployer, but no joy. This may be because my WAR was deployed as part of an EAR.
So I returned to Ant, and finally achieved success by doing the following:
- I deploy my EAR to the JBoss server within Eclipse (this is stored in a plugin directory under the workspace)
- I run an Ant script which JSFUnit-ifies the WAR file, deletes the original WAR and renames the new one to the old name. This step also copies the tests to the WEB-INF/classes directory in the WAR
- I then start the server within Eclipse
- I run JSFUnit tests using a JUnit run configuration with the cactus VM arg set, and these execute appropriately
The main and ugly drawback is that a change to my tests requires a full rebuild and redeploy.
I'm fully aware that this a less than sub-optimal solution, but after nearly 2 weeks of wrestling with this I'm at least happy to have the ability to execute JSFunit tests. Now I have to learn how to use JSFUnit effectively!
If anyone has any suggestions on how to improve this approach, I'll gladly listen, but at the moment it works, if clunkily.
-
5. Re: How do I use JSFUnit in these circumstances?
ssilvert Dec 27, 2010 1:02 PM (in response to jimd11)I wish I had time to work on the deployer. It's the best way to do things on AS5.0, but it looks like it's not working on AS5.1. Like I said before, it would need to be completely rewritten if we were to use it with AS6. Since we are moving toward Arquillian it's hard to justify putting in the time and effort to get this Cactus-based solution udated.
Stan