Enter the new JSFUnit deployer for JBoss AS 5. Now, here is all you need to do to set up JSFUnit for testing:
- Copy jboss-jsfunit-microdeployer.jar to
/server/default/deployers - Rename your war with a "-jsfunit" suffix (such as "mywar-jsfunit.war")
- Add your test classes to the WAR or put them in
/server/default/jsfunitTests - Restart JBoss AS 5 and run your tests.
This is all made possible because of the redesigned microcontainer of JBoss AS 5. You can take an ordinary WAR and add servlets, filters, and classes on the fly as it is being deployed. I've been wanting this kind of functionality for as long as I can remember. It's perfect for adding test tools, fixtures, or monitoring. Before now you had to bundle this stuff with the application - stuff that really doesn't belong in your WAR.
The interesting part is that now instead of thinking of a WAR or EAR as "my application", we can truly think of it as a reuseable deployment unit. It's just another component that can be decorated or combined with other components. While this view provokes a lot of questions (security, name collisions, etc.), the mind reels with the possibilities that this represents.
So long, and thanks for all the fish,
Stan
5 comments:
Where's the source code? :-)
The source is in the JSFUnit repo.
http://www.jboss.org/jsfunit/source-repository.html
Few comments to this deployer:
- http://anonsvn.jboss.org/repos/jsfunit/trunk/jboss-jsfunit-microdeployer/src/main/java/org/jboss/jsfunit/microdeployer/JSFUnitDeployer.java
It shouldn't extend an optional deployer.
Rather extend AbstractSimpleVFSRealDeployer.
So that it only applies to those units that have JBossWebMD attachment present == wars.
!vFile.isLeaf() doesn't mean it's a directory. ;-)
It will also apply for jar/zip, hence always recursively checking whole jar.
No need to build schema all the time. Add / remove on deployer's create / destroy.
e.g. http://anonsvn.jboss.org/repos/jbossas/projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/SchemaResolverDeployer.java
Thanks Ales. Still getting my feet wet here.
For those of you watching this discussion, Ales is the one who wrote a lot of this deployer stuff.
I fixed #1.
For #2, I think only the comment is wrong. While it's not technically a directory, it is a directory in the virtual (VFS) sense, right? Anyhow, I believe this is what I want because I want to add any file/directory specified, plus any descendant.
For #3, I don't understand at all. Obviously, I'm missing something about how all this works.
For #3, see how we do it in the deployer from the link - adding metadata class to xb binding in create, removing it at destroy.
Post a Comment