tag:blogger.com,1999:blog-56437891617063202342024-03-13T14:36:34.755-04:00Test, Test, JSFThis is a blog about testing and JSF. But mostly, it's about JSFUnit, the new JSF testing framework from JBoss.Stan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.comBlogger23125tag:blogger.com,1999:blog-5643789161706320234.post-35693275888736564642012-12-13T15:39:00.000-05:002012-12-13T15:40:43.999-05:00Setting JSF ProjectStage with JNDIOne nice feature of JSF2 is the ProjectStage setting. It lets the JSF implementation and the application developer optimize and customize behavior based on whether JSF is running in Development, Production, SystemTest, or UnitTest. The usual way to tell JSF about which ProjectStage to use is through a context param in web.xml.<br />
<blockquote class="tr_bq">
<pre><context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param></pre>
</blockquote>
But you would rather not muck with web.xml for something like this. It's much cleaner to define your ProjectStage based on what kind of server environment you are running. In other words, wouldn't it be nice if JSF could know whether your server is running in Development, Test, Production, etc? Then you wouldn't need to change your application at all.<br />
<br />
A little-known but handy feature of JSF2 is the ability to use JNDI to set the JSF ProjectStage. Here is how you do that in JBoss AS7.<br />
<br />
First, add a resource reference in <span style="font-family: Times,"Times New Roman",serif;">web.xml</span>.<br />
<blockquote class="tr_bq">
<pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><resource-ref>
<res-ref-name>jsf/ProjectStage</res-ref-name>
<res-type>java.lang.String</res-type>
</resource-ref></span><span class="jive-xml-tag"></span></code></pre>
</blockquote>
Then, create a jboss-web.xml file and place it beside web.xml in your WEB-INF directory. The file should bind the resource reference to JNDI like this:
<br />
<pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><?xml version="1.0" encoding="ISO-8859-1"?>
<jboss-web>
<resource-ref>
<res-ref-name>jsf/ProjectStage</res-ref-name>
<res-type>java.lang.String</res-type>
<jndi-name>java:/env/jsf/ProjectStage</jndi-name>
</resource-ref>
</jboss-web></span> </code></pre>
Next, add the JNDI value to JBoss AS7 in the naming subsystem of your configuration file, such as standalone.xml:<br />
<subsystem xmlns="urn:jboss:domain:naming:1.1"><br />
<bindings><br />
<simple name="java:/env/jsf/ProjectStage" value="Development"/><br />
</bindings><br />
</subsystem><br />
<br />
You can also add the JNDI value using <a href="https://community.jboss.org/wiki/CommandLineInterface" target="_blank">CLI</a>:
<br />
<blockquote class="tr_bq">
<pre class="jive-pre"><code class="jive-code">/subsystem=naming/binding=java\:\/env\/jsf\/ProjectStage/:add(binding-type=simple,value=Development,class=java.lang.String)</code></pre>
</blockquote>
But I like to use <a href="https://community.jboss.org/wiki/AGUIForTheCommandLineInterface" target="_blank">CLI GUI</a> for this because it automatically handles the escape characters:
<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="http://4.bp.blogspot.com/-ca-bhFUg94A/UMo4EZcoi5I/AAAAAAAAACk/jNlNo0UdUAw/s1600/projectstage1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="295" src="http://4.bp.blogspot.com/-ca-bhFUg94A/UMo4EZcoi5I/AAAAAAAAACk/jNlNo0UdUAw/s320/projectstage1.png" width="320" /></a></div>
<div style="text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://4.bp.blogspot.com/-iOdC__Wvg7E/UMo4IORt7vI/AAAAAAAAACs/jZdT8vWZDVw/s1600/projectstage2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="297" src="http://4.bp.blogspot.com/-iOdC__Wvg7E/UMo4IORt7vI/AAAAAAAAACs/jZdT8vWZDVw/s320/projectstage2.png" width="320" /></a></div>
Now we are done, but you might also want to change the value of ProjectStage on your server. Again, you can do that in XML or you can use CLI:<code class="jive-code"> </code><br />
<code class="jive-code">/subsystem=naming/binding=java\:\/env\/jsf\/ProjectStage/:write-attribute(name=value,value=UnitTest)</code>Stan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com6tag:blogger.com,1999:blog-5643789161706320234.post-25672355329123355622012-11-26T16:21:00.000-05:002012-12-13T18:28:18.034-05:00Multi-JSF is here! Use any JSF in JBoss ASMulti-JSF is a JBoss AS feature that I've wanted to implement for a very, very long time. Basically, it allows you to use any JSF implementation as if it were the impl that ships with JBoss AS. This works with almost any version of MyFaces or Mojarra. You can even install multiple JSF implementations and tell each app which one to use.<br />
<br />
Until now, if you wanted to use a different JSF version, <a href="https://community.jboss.org/thread/203257" target="_blank">you could hack AS7</a>. But this only worked for Mojarra implementations. If you wanted to use MyFaces, you had to resort to bundling JSF with your web app and <a href="https://community.jboss.org/wiki/JBoss5AndMyFaces" target="_blank">setting WAR_BUNDLES_JSF_IMPL</a> in web.xml.<br />
<br />
Both methods had potential integration problems if you wanted to use JEE5 features such as @EJB , or JEE6 features like CDI and bean validation. What's worse is that if you wanted to use more than one JSF version you would end up bundling JSF with every WAR.<br />
<br />
In short, it was messy and it didn't always work. Plus, WAR_BUNDLES_JSF_IMPL isn't even officially supported.<br />
<br />
Multi-JSF is now in the latest <a href="http://hudson.jboss.org/hudson/view/AS7/job/as7-master-build/" target="_blank">nightly build of 7.2.0-Alpha1</a>. You can get all the details on how to use it at <a href="https://community.jboss.org/wiki/DesignOfAS7Multi-JSFFeature" target="_blank"> https://community.jboss.org/wiki/DesignOfAS7Multi-JSFFeature</a>.<br />
<br />
I hope you'll try it out and provide some feedback before AS7.2 goes final.<br />
<br />
So long and thanks for all the fish,<br />
<br />
Stan<br />
<br />
<br />Stan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com0tag:blogger.com,1999:blog-5643789161706320234.post-50933925424919186292011-09-15T14:35:00.004-04:002011-09-15T15:15:24.187-04:00JSFUnit 2.0.0.Beta 2 is Out<span style="font-weight: bold;font-size:130%;" ></span>It's hard to believe that it has taken this long to get from Beta 1 to Beta 2. There were some good reasons for it. One is because we were waiting for Arquillian and JBoss AS7 to stabilize. The other reason is just because I haven't had as much time to work on JSFUnit as I did in the past. Most of my time has been taken up with AS7-related stuff.<br /><br />However, I'm thrilled that the community has come to the rescue! In fact, the community gets almost all the credit for this release. First, there is Josè Freitas. Josè did most of the coding to get the us running with the latest Aqruillian and JBoss AS7. This included porting the CDI-based annotations to use Arquillian TestEnricher. Now, you no longer need CDI for the new annotations to work. That's a big help for containers that don't natively support CDI.<br /><br />We got some further help from JBoss developers Aslak Knudsen and Andrew Lee Rubinger. Plus, there were lots of community members who stepped up to answer questions on the <a href="http://community.jboss.org/en/jsfunit?view=discussions">JSFUnit forum</a> while I was less active. Wolfgang Knauf even went so far as to write a comprehensive tutorial on using <a href="http://www.cs.hs-rm.de/%7Eknauf/JavaEE6/jsfunit/index.html">JSFUnit Beta 2 with Eclipse</a>.<a href="https://webmail.corp.redhat.com/horde/imp/message.php?index=405513"></a><br /><br /><span style="font-weight: bold;font-size:130%;" >So, what's new in the release?</span><br />You can <a href="http://community.jboss.org/wiki/JSFUnit200Beta2ReleaseNotes">click here</a> for the official release notes.<br /><br />In summary, we now fully support the latest version of <a href="http://www.jboss.org/arquillian">Arquillian </a>and added the long-awaited support for JBoss AS7. As mentioned above, the <a href="http://community.jboss.org/wiki/InjectionForJSFSessionJSFClientSessionAndJSFServerSession">annotations</a> no longer require CDI. And, we've moved the source code to <a href="https://github.com/jsfunit">GitHub</a>. That should make it even easier for everyone to get involved.<br /><br />Here are some helpful links to get you started:<br /><a href="http://www.jboss.org/jsfunit/gettingstarted_version_2-0-0.html">Getting Started with JSFUnit 2.x</a><br /><a href="http://community.jboss.org/wiki/JSFUnit200Beta2GettingStartedExample">Getting Started Sample App</a><br /><a href="http://community.jboss.org/wiki/JSFUnit200FAQ">JSFUnit 2.x FAQ</a><br /><a href="http://community.jboss.org/wiki/InjectionCDIforJSFSessionJSFClientSessionandJSFServerSession">JSFUnit 2.x Annotations</a><br /><br />Hope you enjoy the release. We'll probably do one more beta soon. But with all the extra help, it shouldn't be long before JSFUnit 2 goes final.<br /><br />So long and thanks for all the fish,<br /><br />StanStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com0tag:blogger.com,1999:blog-5643789161706320234.post-56201611895653940462011-02-07T16:01:00.003-05:002011-02-07T19:34:55.964-05:00JSFUnit 2.0.0.Beta1 is OutI'm very excited to announce the availability of JSFUnit 2.0.0.Beta1. The two biggest shortcomings of JSFUnit 1.x were always a lack of JUnit 4 support and relatively slow execution times compared with "mock object" solutions.<br /><br />The reason we couldn't do anything about this up until now was because JSFUnit 1.x needed Cactus as the in-container test runner. Being in-container has tremendous advantages because you don't need the messy mock objects and you can run your tests against the real system. But Cactus is rather old and it only supported JUnit 3.<br /><br />So now, JSFUnit 2.x takes advantage of the new in-container framework from JBoss called <a href="http://www.jboss.org/arquillian">Arquillian</a>. It not only supports JUnit 4, but you get TestNG support to boot. And depending on the container you choose, the speed can be really fast.<br /><br />Here are the links you need to know about to get started:<br /><a href="http://www.jboss.org/jsfunit/gettingstarted_version_2-0-0.html">Getting Started with JSFUnit 2.x</a><br /><a href="http://community.jboss.org/wiki/JSFUnit200GettingStartedExample">Getting Started Sample App</a><br /><a href="http://community.jboss.org/wiki/JSFUnit200FAQ">JSFUnit 2.x FAQ</a><br /><a href="http://community.jboss.org/wiki/InjectionCDIforJSFSessionJSFClientSessionandJSFServerSession">JSFUnit 2.x Annotations</a><br /><br />I want to thank those who have helped with this release. Thanks goes to Ole for his nifty new method to <a href="https://issues.jboss.org/browse/JSFUNIT-262">click a RichFaces panel bar item</a>. Also thanks to Bernard Labno who has been working hard on some additional RichFaces support. His code hasn't been integrated yet but I'm confident that his work will solve some long-standing issues with ajax queues. <br /><br />And last but not least, thanks to Aslak Knutsen and all his fellow contributors to the <a href="http://www.jboss.org/arquillian">Arquillian</a> project. You guys have been extremely helpful. I'm sure our two products will continue to complement each other and spread the gospel of in-container testing.<br /><br />So long and thanks for all the fish,<br /><br />StanStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com2tag:blogger.com,1999:blog-5643789161706320234.post-15000306077127055112010-12-28T08:21:00.004-05:002010-12-28T11:08:17.760-05:00JSF on JBoss AS6 FinalWhen I do blog here, it's usually about JSFUnit. But today it's time for me to blog about the other stuff I do at JBoss. Besides JSFUnit, I'm also responsible for JSF integration in the JBoss Application Server. With JBoss AS6 going final, I'd like to talk about some big improvements.<br /><br /><span style="font-size:130%;"><span style="font-weight: bold;">A short history of JSF on JBoss AS</span></span><br />JSF has been integrated into JBoss AS since version 4.0.3. Back then we were using MyFaces 1.1. All it really meant was that JSF would be on the classpath so you didn't need to bundle JSF with your WAR any more. The integration was so crude that you still had to declare the MyFaces context listener in your own web.xml.<br /><br />With JBoss AS4.2 and AS5, integration got tighter. We switched to Sun's JSF 1.2 implementation, now known as Mojarra. JSF 1.2 included support for JEE5 annotations on your managed beans such as @PostConstruct, @PreDestroy, and @Resource. It also included integration with JSP and EL. And, you no longer had to declare a listener in your own web.xml.<br /><br />Despite better integration and more features, some people got mad. You see, even though MyFaces and Mojarra comply with the same spec and pass the same TCK, they are not 100% compatible. So apps that ran fine on AS4.0.3 broke on AS4.2 and AS5. What's more, the reality is that JSF apps are not even fully compatible from version to version. Apps that run fine on Mojarra 1.2 might not run on Mojarra 2.0.<br /><br />And don't even get me started about JSF component libraries. Suffice it to say that compatibility between versions and implementations is even worse.<br /><br /><span style="font-size:130%;"><span style="font-weight: bold;">JSF on AS6: Coming to grips with reality</span></span><br />The reality is that an application server needs to play nice with more than one JSF implementation. So with AS6, we ship with three versions of JSF. Mojarra 2.0 is there as the default implementation. Mojarra 1.2 is there to ease migration from AS5. And, MyFaces 2.0 is there for those who prefer MyFaces. To choose a different JSF, all you need to do is declare a single context param in your web.xml like this<span style="font-family:courier new;">:</span><br /><pre id="line179"><span class="entity"><</span>context-param<span class="entity">></span><br /> <<span class="entity"></span>param-name<span class="entity">></span>org.jboss.jbossfaces.JSF_CONFIG_NAME<span class="entity"><</span>/param-name> <br /> <<span class="entity"></span>param-value<span class="entity">></span>Mojarra-1.2<span class="entity"><</span>/param-value><span class="entity"></span><br /><span class="entity"><</span>/context-param><span class="entity"></span><br /><br /></pre><span style="font-family:courier new;"></span>But it doesn't stop there. If you want to bundle JSF with your WAR like in Tomcat, that's fine. If you want to add a fourth JSF version to JBoss AS and make it the default, that's easy to do.<br /><br />You can even bundle a component library together with a particular JSF version and call that "MyPerfectJSFConfig". Then refer to the JSF Config in web.xml for all your apps that use that. No need to bundle RichFaces or IceFaces jars over and over with every WAR:<br /><pre id="line179"><<span class="entity"></span>context-param><span class="entity"></span><br /> <<span class="entity"></span>param-name<span class="entity">></span>org.jboss.jbossfaces.JSF_CONFIG_NAME<span class="entity"><</span>/param-name> <br /> <<span class="entity"></span>param-value<span class="entity">></span>MyPerfectJSFConfig<span class="entity"><</span>/param-value><span class="entity"></span><br /><span class="entity"><</span>/context-param><span class="entity"></span><br /><br /></pre><br />This is all really handy for testing your application against different JSF versions and implementations. Ever ask yourself if your Mojarra app would run faster (or without errors) on MyFaces? Now it's easy to find out. What if you have an old app that runs on JSF 1.2 but you also have a new app that runs on JSF 2.0? You don't have to worry that the upgrade to JSF 2.0 will break the old app. They can run side-by-side in the same JBoss AS instance without changes.<br /><br />If you want the details on how to do this stuff, take a look at the <a href="http://www.jboss.org/jbossas/docs/6-x/Component-Documentation/jsf.html">JSF on AS6 documentation</a>.<br /><br /><span style="font-size:130%;"><span style="font-weight: bold;">All this and more</span></span><br />I don't want to leave out the fact that all the JEE integration you expect will be there. If you are using JSF 1.2 you will get the EE5 features like annotations on your managed beans. If you are using JSF 2.0 you will also get EE6 features like Bean Validation.<br /><br />In summary, I'm really proud of the JSF integration in AS6. It took a lot of work to get this level of flexibility. And I can honestly say that every JSF integration complaint I heard in previous JBoss versions is now fixed and addressed. Onward now to JBoss AS7.<br /><br />So long, and thanks for all the fish,<br /><br />StanStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com2tag:blogger.com,1999:blog-5643789161706320234.post-61147288952918362952010-08-11T17:19:00.007-04:002010-08-16T20:27:12.576-04:00JSFUnit 1.3.0.Final is Released<span style="font-weight: bold;"><span style="font-size:130%;">A</span> <span style="font-size:78%;">Small</span> <span style="font-size:130%;">Release with</span> <span style="font-size:180%;">Big</span> <span style="font-size:130%;">Consequences</span></span><br /><br />JSFUnit 1.3.0 is out. There are only three interesting changes:<br /><ul><li>A new API call on <a href="https://community.jboss.org/wiki/JSFUnitWithRichFaces">RichFacesClient</a> for Drag and Drop</li><li>Updates for compatibility with HtmlUnit 2.8</li><li>One JSFUnit bug fix</li></ul>The Drag and Drop thing is nice. And HtmlUnit 2.8 fixes a LOT of the bugs from 2.7, several of which were reported by the JSFUnit community.<br /><br />But the big story is the one tiny JSFUnit bug fix submitted by Aslak Knudsen. You see, that fix enables JSFUnit to integrate with <a href="http://community.jboss.org/en/arquillian">Arquillian</a>. If you are not familiar with <a href="http://community.jboss.org/en/arquillian">Arquillian</a>, this is a new JBoss project that handles deployment and test execution for in-container tests. It's an elegant, modern replacement for what we do now with Cactus and Cargo.<br /><br />So going forward, you will be able to run your JSFUnit tests using either <a href="http://community.jboss.org/en/arquillian">Arquillian</a> or Cactus/Cargo. The advantages you will have with <a href="http://community.jboss.org/en/arquillian">Arquillian</a> are:<br /><ul><li>Full JUnit 4 support (yay! we can finally use the @Test annotation!)</li><li>TestNG 5 support (yay! if you prefer TestNG)</li><li>Resource injection into your test classes (stuff like @Inject or @EJB can go right into your test)<br /></li><li>Testing for subsets of your WAR. For instance, if I only want to test two facelets and one managed bean it will package those into a small WAR, deploy it, and run the test. This is great for development because single tests will run much faster without creating the whole giant WAR.</li></ul>The one disadvantage I can think of is that Cargo supports more containers. Arquillian currently supports JBoss AS, Glassfish, Jetty, and Tomcat. But I'm sure more are on the way.<br /><br />So when can you try out the JSFUnit/Arquillian combo? Aslak already has a proof of concept. It looks like we may be ready to let it loose in just a few days. Stay tuned.<br /><br />So long, and thanks for all the fish,<br /><br />Stan<br /><br />P.S. Note that some dependency versions have changed. Check out the <a href="http://www.jboss.org/jsfunit/gettingstarted.html">getting started page</a> for the complete list of jars you need to upgrade.Stan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com0tag:blogger.com,1999:blog-5643789161706320234.post-89850030510047742522010-03-16T13:39:00.002-04:002010-03-16T14:07:20.091-04:00A Patent on JSFUnit... or more precisely, I/we patented one of the key technologies JSFUnit uses. About the same time I was starting the JSFUnit project, Red Hat's lawyers announced a push to get us to file software patents. I did so reluctantly because I think that in the end, software patents are a game that only the lawyers can win. But Red Hat has a good strategy when it comes to patents that I think ultimately benefits everyone. Read below for more on that.<br /><br />So it took over three years to get it done. You can view the patent <a href="http://www.freepatentsonline.com/7680917.pdf">here</a> if you want the gory details.<br /><br /><br /><span style="font-weight: bold;font-size:130%;" >What does the patent say?</span><br />Basically, it just says that we keep the FacesContext alive after the request is done. Without JSFUnit, the JSF Lifecycle would throw it away. That lets us do assertions on the state of the system after each JSF request. If you've been using JSFUnit then you probably know all about that. It's what makes JSFUnit unique among testing tools.<br /><br /><br /><span style="font-weight: bold;font-size:130%;" >What does the patent mean for JSFUnit users?</span><br />Nothing. The software is still open source. We're not looking to make money off of the patent.<br /><br /><br /><span style="font-weight: bold;font-size:130%;" >Why did Red Hat want to patent this in the first place? Doesn't this go against Red Hat's philosophy of openness and freedom?</span><br />Yes and no. Red Hat doesn't really like software patents either. But we see them as a necessary evil until some laws are changed. As I understand it, the <a href="http://www.redhat.com/legal/patent_policy.html">Red Hat Patent Promise</a> says that anyone can use our patents for free as long as you don't file a patent case against us.<br /><br />So long and thanks for all the fish,<br /><br />Stan<br /><br />*<span style="font-weight: bold; font-style: italic;">Disclaimer:</span> I'm not an attorney. The above is my own understanding of this stuff. I'm not even qualified to write this disclaimer.Stan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com0tag:blogger.com,1999:blog-5643789161706320234.post-66635232181657823212010-03-03T17:09:00.003-05:002010-03-03T17:47:23.840-05:00JSFUnit 1.2 Goes FinalWe just put out a <a href="http://labs.jboss.com/jsfunit/downloads.html">new release of JSFUnit</a>. This time besides bug fixes, we have few new features to talk about:<br /><ul><li><span style="font-weight: bold;">JSF Static Analysis Returns</span> - A big thank-you goes to our newest committer, Alexander Jesse. He has updated some of the old JSF static analysis code and made it really easy to test your JSF configuration for common errors. Some of the old static analysis stuff is still there but his ConfigFilesTestSuite looks awesome. <a href="http://community.jboss.org/wiki/StaticAnalysis">Click here to check out the documentation.</a></li><li><span style="font-weight: bold;">New API for working with RichTree components - </span>Of all components, developers using JSFUnit seem to have the most difficulty with RichTree. That's understandable because it is a very complex component. In JSFUnit 1.2.0 the RichFacesClient has new methods for working with RichTree. <a href="http://community.jboss.org/wiki/JSFUnitWithRichFaces">You can read about that here.</a></li><li><span style="font-weight: bold;">Easier Configuration for Servlet 3.0</span> - If you are lucky enough to be using a Servlet 3.0 container such as JBoss AS6, you no longer need to change your web.xml. JSFUnit will add the needed servlets and filters at deploy time.</li><li><span style="font-weight: bold;">JSFUnit Console -</span> This is one of the cooler new features, but it also requires Servlet 3.0. JSFUnit now provides a browser-based console for launching your tests. You don't have to do anything extra. You just need to deploy your app and type <span style="font-family:courier new;"><span style="font-weight: bold;">http://locahost/myjsfapp/jsfunit</span></span> into the browser. <a href="http://community.jboss.org/wiki/UsingJSFUnitwithServlet30">You can read all about it here.</a></li></ul>A note about upgrading. If you are upgrading from JSFUnit 1.1.0 you will need to upgrade some of your jars that you package with the WAR. They are:<br /><ul><li>htmlunit-2.7.jar</li><li>htmlunit-core-js-2.7.jar</li><li>nekohtml-1.9.14.jar</li><li>commons-codec-1.4.jar</li></ul>Also, there have been a few bug fixes in HtmlUnit for RichFaces. So if you run into trouble you can find an HtmlUnit 2.8 snapshot <a href="http://build.canoo.com/htmlunit/buildresults">from the latest build</a> that contains the fixes.<br /><br />As always, thanks to everyone who contributed to this release with patches and feedback.<br /><br />So long and thanks for all the fish,<br /><br />StanStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com2tag:blogger.com,1999:blog-5643789161706320234.post-57527914636307952272009-12-23T13:25:00.008-05:002009-12-23T15:12:30.613-05:00What's a WARlet ???<span style="font-weight: bold;">JSFSpy Progress</span><br />Today I uploaded a new<a href="http://snapshots.jboss.org/maven2/org/jboss/jsfspy/"> snapshot of JSFSpy</a>. BTW, I'm keeping the name JSFSpy. Even though I don't like it that much, it's short and to the point. Thanks to those who had other suggestions earlier this year. JSFSpy is super-easy to install. Just drop the JSFSpy core jar into your WEB-INF/lib and you are ready to go. <a href="http://community.jboss.org/wiki/JSFSpy">Click here for details.</a><br /><br /><span style="font-weight: bold;">What's a WARlet ???</span><br />In short, a WARlet is a WAR plug-in. It provides one or more Facelet views via a WARlet container and some Servlet 3/JSF 2 magic. A WARlet is neatly packaged in its own jar. The jar contains any xhtml, css, images, and classes that it needs. This provides a module of UI and processing logic that you can add to your WAR with zero configuration.<br /><br />If you happened to catch my <a href="http://community.jboss.org/servlet/JiveServlet/download/13736-4-7151/DumpingJSF_1up.pdf">JSFSpy presentation</a> at JSF Summit a couple of weeks ago, you saw a WARlet in action. I'll re-create that demo here. Notice the JSFSpy menu buttons at the top:<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_IuN9-0AAr8A/SzJt7cdtObI/AAAAAAAAABk/gy3CCDd_SIE/s1600-h/JSFSpy1.jpg"><img style="cursor: pointer; width: 320px; height: 131px;" src="http://3.bp.blogspot.com/_IuN9-0AAr8A/SzJt7cdtObI/AAAAAAAAABk/gy3CCDd_SIE/s320/JSFSpy1.jpg" alt="" id="BLOGGER_PHOTO_ID_5418514169700628914" border="0" /></a><br /><br />I took JSFSpy and bundled the WARlet container along with it. Then I took my EL_Evaluator WARlet jar and dropped that into WEB-INF/lib. Redeploy and Viola!! Now an EL Evaluator button appears in my application on the far right.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_IuN9-0AAr8A/SzJvKWMvnYI/AAAAAAAAABs/yp5lmgg82E0/s1600-h/JSFSpy2.jpg"><img style="cursor: pointer; width: 320px; height: 144px;" src="http://1.bp.blogspot.com/_IuN9-0AAr8A/SzJvKWMvnYI/AAAAAAAAABs/yp5lmgg82E0/s320/JSFSpy2.jpg" alt="" id="BLOGGER_PHOTO_ID_5418515525228535170" border="0" /></a><br /><br />The button can launch the EL Evaluator functionality. Here is the EL Evaluator:<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_IuN9-0AAr8A/SzJysKzgA3I/AAAAAAAAAB0/lDwzUtGyuQM/s1600-h/JSFSpy3.jpg"><img style="cursor: pointer; width: 320px; height: 92px;" src="http://1.bp.blogspot.com/_IuN9-0AAr8A/SzJysKzgA3I/AAAAAAAAAB0/lDwzUtGyuQM/s320/JSFSpy3.jpg" alt="" id="BLOGGER_PHOTO_ID_5418519404820300658" border="0" /></a><br /><br />So how does the button get added? JSFSpy doesn't know anything about EL Evaluator. It only knows that one or more WARlets might be present. So the button menu has this markup to display a launch button for any WARlets that happen to be there:<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_IuN9-0AAr8A/SzJ1P1ORsLI/AAAAAAAAACE/CNn-q462CcE/s1600-h/JSFSpy4.jpg"><img style="cursor: pointer; width: 400px; height: 128px;" src="http://1.bp.blogspot.com/_IuN9-0AAr8A/SzJ1P1ORsLI/AAAAAAAAACE/CNn-q462CcE/s400/JSFSpy4.jpg" alt="" id="BLOGGER_PHOTO_ID_5418522216525574322" border="0" /></a><br /><br />So what this all means is that anyone in open-source land can create their own WARlet that plugs into JSFSpy. I'll be posting more about how to create a WARlet in the near future. If you just can't wait to write your own you can <a href="http://anonsvn.jboss.org/repos/jsfspy/trunk/">browse the JSFSpy source, example code, and WARlet container source.</a><br /><br />The only catch is that all this requires Servlet 3.0 and JSF 2.0. Nothing wrong with the bleeding edge, eh?<br /><br />So long, thanks for all the fish, and have a great holiday!<br /><br />StanStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com0tag:blogger.com,1999:blog-5643789161706320234.post-68111679666842253802009-08-29T13:40:00.002-04:002009-08-29T13:42:19.294-04:00JSFUnit Podcast on JSFCentral<span class="postbody">Kito Mann just posted a podcast of yours truly on JSFCentral. It was recorded at a JSF Conference almost a year ago when JSFUnit was still in beta. But you might still find it interesting:<br /><a href="http://www.jsfcentral.com/articles/silvert-08-09.html" target="_blank" class="postlink">http://www.jsfcentral.com/articles/silvert-08-09.html</a><br /><br />I'll be speaking at the conference again this year in Orlando. Hope to see you there.<br /><a href="http://www.jsfsummit.com/" target="_blank" class="postlink">http://www.jsfsummit.com</a><br /><br />So long and thanks for all the fish,<br /><br />Stan<br /></span>Stan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com0tag:blogger.com,1999:blog-5643789161706320234.post-48518778333451295682009-07-16T15:44:00.003-04:002009-07-16T15:57:16.123-04:00JSFUnit 1.1.0.GA is releasedThe latest JSFUnit release is now out. This is primarily a bug-fix release, with several of these fixes related to Seam. The only significant new feature is the ability to <a href="http://www.jboss.org/community/wiki/ParameterizingJSFUnitTests">parameterize your tests</a>.<br /><br />We now recommend using HtmlUnit 2.5 instead of 2.4. Also, everything is updated to the latest beta version of JSF 2. So now you can use JSFUnit with JSF 1.1, JSF 1.2, and JSF 2.0 Beta 2.<br /><br />As for JSF Spy (JSF Eye?), this is not ready for a release. It will probably become its own separate project soon.<br /><br />So long, and thanks for all the fish,<br /><br />StanStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com3tag:blogger.com,1999:blog-5643789161706320234.post-86159023228164153142009-06-05T15:10:00.013-04:002009-06-08T13:10:19.215-04:00Help Me Name My BabyI've got a new baby and I don't know what to name it. It's a new JSF debug/trace/performance tool. If you've ever seen the Facelets or Seam debug page then you've got an idea of what it is. However, this tool goes beyond those to take "state snaps" before and after each phase. And, it keeps all the info from every request and every session, even expired sessions. <br /><br /><a href="http://www.jboss.org/community/wiki/JSFSpy">Pre-alpha documentation and download is here.</a> <br /><br />So now you can debug those nasty AJAX components that do four or five JSF requests with every mouse click. You see all the HttpServletRequest data like params, headers, and cookies. And, you can look at the performance data for each request and each phase.<br /><br />For now, we store this info in memory for you to peruse at your leisure. Later, I'll probably look at other options like saving to a database. That way, it might be a fit tool for production auditing.<br /><br />So right now you are either thinking this is really cool or really nuts. Judge for yourself, and let me know. And if you have a good name for it please let me know that too. Right now I'm calling it JSFSpy, but I really don't like that name.<br /><br />There is no dependency on JSFUnit. Installation just requires dropping a single jar into the WEB-INF/lib of your application. But you can do assertions on the collected data from JSFUnit or you can just browse it with the UI. If you want to use the UI, you'll need to put some xhtml files in your web app. <a href="http://www.jboss.org/community/wiki/JSFSpy">Instructions are here.</a><br /><br />Here are the screen shots that should tell you exactly what it does. There's more stuff to add like Seam scopes, JSF2 scopes, component tree, and FacesMessages. What do you think so far?<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_IuN9-0AAr8A/SilyPsnZbwI/AAAAAAAAAAc/3qYMTswvcbA/s1600-h/index.jpg"><img style="cursor: pointer; width: 320px; height: 182px;" src="http://3.bp.blogspot.com/_IuN9-0AAr8A/SilyPsnZbwI/AAAAAAAAAAc/3qYMTswvcbA/s320/index.jpg" alt="" id="BLOGGER_PHOTO_ID_5343928046851813122" border="0" /></a><br /><span style="font-weight: bold;">Main screen shows all HttpSessions ever created.</span><br /><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_IuN9-0AAr8A/SilysQdKZyI/AAAAAAAAAAk/zQpcVjO_hzk/s1600-h/sessionview.jpg"><img style="cursor: pointer; width: 320px; height: 225px;" src="http://3.bp.blogspot.com/_IuN9-0AAr8A/SilysQdKZyI/AAAAAAAAAAk/zQpcVjO_hzk/s320/sessionview.jpg" alt="" id="BLOGGER_PHOTO_ID_5343928537508898594" border="0" /></a><br /><span style="font-weight: bold;">Request view shows all Http/JSF requests for the selected session.</span><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_IuN9-0AAr8A/Sil1e23vp0I/AAAAAAAAABE/tUYHpKvGLac/s1600-h/scopesview.jpg"><img style="cursor: pointer; width: 320px; height: 175px;" src="http://2.bp.blogspot.com/_IuN9-0AAr8A/Sil1e23vp0I/AAAAAAAAABE/tUYHpKvGLac/s320/scopesview.jpg" alt="" id="BLOGGER_PHOTO_ID_5343931605837653826" border="0" /></a><br /><span style="font-weight: bold;">Scoped Data view shows toString() value of each scoped attribute before and after each phase.</span><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_IuN9-0AAr8A/Sil14-CwhLI/AAAAAAAAABM/b2653jV5nfU/s1600-h/httprequestview.jpg"><img style="cursor: pointer; width: 320px; height: 194px;" src="http://3.bp.blogspot.com/_IuN9-0AAr8A/Sil14-CwhLI/AAAAAAAAABM/b2653jV5nfU/s320/httprequestview.jpg" alt="" id="BLOGGER_PHOTO_ID_5343932054439494834" border="0" /></a><br /><span style="font-weight: bold;font-size:100%;" >HttpServletRequest view shows incoming URL, headers, request params, cookies, etc.</span><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_IuN9-0AAr8A/Sil2Ei-7oJI/AAAAAAAAABU/R6LnH067io0/s1600-h/perfview.jpg"><img style="cursor: pointer; width: 320px; height: 214px;" src="http://1.bp.blogspot.com/_IuN9-0AAr8A/Sil2Ei-7oJI/AAAAAAAAABU/R6LnH067io0/s320/perfview.jpg" alt="" id="BLOGGER_PHOTO_ID_5343932253334118546" border="0" /></a><br /><span style="font-weight: bold;font-size:100%;" >Perf Data View shows which phases completed and how long each one took.</span>Stan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com5tag:blogger.com,1999:blog-5643789161706320234.post-67801299056516491522009-02-24T17:21:00.004-05:002009-02-24T18:27:12.306-05:00JSFUnit goes GAI'm very happy to report that the JSFUnit 1.0.0.GA release is now out!<br /><br />JSFUnit is the only end-to-end BlackBox/WhiteBox testing solution for JSF. Your tests run in-container and out-container at the same time. That is, JSFUnit lets your tests submit real HTTP requests using a headless browser. Then it lets you examine all the artifacts inside the container including the FacesContext, Managed Beans, UIComponent tree, FacesMessages, and much more. And since you are running inside the real container you never need a mock object or stub. You never have to worry about constructing a fake test environment.<br /><br />Most of you reading this blog have heard all that stuff before, so I'll just talk a bit about the GA release. Here are the main changes from the Beta 3 release.<br /><ul><li>The conversion to HtmlUnit is now complete. The old client side API based on HttpUnit is completely gone. Since HtmlUnit is far better at handling javascript, this means that most JSF AJAX libraries will work right out of the box. The notable exception is ICEfaces, and I've been working with ICEfaces team to get support for that as soon as possible.</li><li>We now have a JSFUnit deployer for JBoss AS5. I <a href="http://jsfunit.blogspot.com/2008/10/jsfunit-easy-way.html">blogged about this</a> earlier. This deployer lets you run your JSFUnit tests without making a single change to your WAR. <a href="http://www.jboss.org/community/docs/DOC-10975">Click here for details</a>.</li><li>JSF 2.0 support. I know you are wanting to play around with JSF 2.0, right? Now you don't have to give up test-first development while you explore.</li><li>The last change is a bit of sad news. The two developers who were working on the JSFUnit static analysis tool have moved on to new jobs where they are no longer using JSF. I versioned the code to 1.0 along with everything else, but I do want everyone to be aware that new features and bug fixes for static analysis won't happen until someone else steps up. If you are interested in taking this on let me know. JSF static analysis is really cool stuff and it's a very useful tool.</li></ul>Lastly, I want to thank everyone who helped make JSFUnit happen. This is a new kind of tool that required a lot experimentation before we got it right. It has taken much longer to get here than I expected. The <a href="http://www.jboss.org/index.html?module=bb&op=viewforum&f=269">community feedback</a> has been great and I've gotten tremendous support internally at JBoss/RedHat. So, in no particular order, thanks to Brian, Dennis, Jason, Matt, Shelly, Julien, Kragoth, Wolfgang, Patrick, Dimitris, Farah, Sacha, Kito, Pete, Ed, Ryan, Alexander, Jesper, Neil, Ken, and a bunch of others I've probably forgotten.<br /><br />So long, and thanks for all the fish,<br /><br />StanStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com1tag:blogger.com,1999:blog-5643789161706320234.post-87711667519409508762009-01-05T15:08:00.003-05:002009-01-05T15:32:58.885-05:00JSF 2.0 and the upcoming GA release of JSFUnitI don't work on JSFUnit full time. A big part of my responsibility at JBoss/Red Hat is to make sure that JSF and Seam integrate nicely with the JBoss Application Server.<br /><br />So I've been looking at the <a href="https://javaserverfaces.dev.java.net/nonav/rlnotes/2.0.0/index.html">JSF 2.0 Public Review release</a>. Using JSF 2.0 with JBoss AS 4.2 and AS 5.0 seems to be just a matter of replacing jsf-api.jar and jsf-impl.jar. I'm sure that I'll come across some things that need more/better integration. And when I do, I'll have to implement something new. But for now I'm happy to be able to play with the JSF 2.0 PR release as-is on JBoss AS.<br /><br />To see how much would run without error, I decided to go ahead and upgrade JSFUnit to work with the new JSF 2.0 API. That required adding methods to JSFUnitFacesContext and JSFUnitExternalContext. There were some other code changes, including a change to the Environment class that detects which version of JSF is running. <br /><br />Anyhow, I'm happy to report that JSFUnit now works with JSF 2.0. You can download the <a href="http://snapshots.jboss.org/maven2/org/jboss/jsfunit/">latest JSFUnit snapshot</a> if you'd like to play with it. The part of the JSFUnit test suite that doesn't run is execution of the applications that use Facelets and Ajax4Jsf/RichFaces together. I've filed a bug on it, so hopefully that problem will be resolved soon. Please leave me feedback on the <a href="http://www.jboss.com/index.html?module=bb&op=viewforum&f=269">JSFUnit Forum</a> if you decide to give it a try.<br /><br />Lastly, I've been asked several times when JSFUnit is going to go GA. There is really nothing stopping me now except that I'd like to fix a few more bugs and maybe add support for IceFaces. Look for a release in mid-February.<br /><br />So long and thanks for all the fish,<br /><br />StanStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com5tag:blogger.com,1999:blog-5643789161706320234.post-35811947283322229332008-10-12T14:13:00.003-04:002008-10-12T14:18:32.091-04:00JSFUnit experience requiredThe JSFUnit project has reached a new milestone. This is the first job posting I've seen where JSFUnit experience is required.<br /><br /><a href="http://www.bidtowork.com/2008/10/09/java-test-engineer-with-jsfunit-and-httpunit-experience-odesk/">http://www.bidtowork.com/2008/10/09/java-test-engineer-with-jsfunit-and-httpunit-experience-odesk/</a><br /><br />So long and thanks for all the fish,<br /><br />StanStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com0tag:blogger.com,1999:blog-5643789161706320234.post-448361784565552972008-10-02T09:26:00.003-04:002008-10-02T09:54:04.655-04:00JSFUnit the Easy Way!!JSFUnit tests are easy to write and understand. This comes across clearly whenever I talk about it at a conference and I see faces light up. They "get it". However, it's also clear that the hardest part of JSFUnit is <a href="http://www.jboss.org/jsfunit/gettingstarted.html">getting started</a>. Once you get over that hump, developers really like the tool. But until now, setting up JSFUnit for the first time required quite a bit of work.<br /><br />Enter the new <a href="http://wiki.jboss.org/wiki/JSFUnitWithASMicrocontainer">JSFUnit deployer for JBoss AS 5</a>. Now, here is all you need to do to set up JSFUnit for testing:<br /><span class="wikiContent"><ol><li> Copy jboss-jsfunit-microdeployer.jar to <jboss>/server/default/deployers </jboss></li><li> Rename your war with a "-jsfunit" suffix (such as "mywar-jsfunit.war") </li><li> Add your test classes to the WAR or put them in <jboss>/server/default/jsfunitTests </jboss></li><li> Restart JBoss AS 5 and <a href="http://wiki.jboss.org/wiki/RunningJSFUnit">run your tests</a>. </li></ol>That's it. In fact, with a simple edit to the <a href="http://wiki.jboss.org/wiki/JSFUnitWithASMicrocontainer">deployer's descriptor</a> you can even get rid of step 2.<br /><br />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.<br /><br />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.<br /></span><br />So long, and thanks for all the fish,<br /><br />StanStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com5tag:blogger.com,1999:blog-5643789161706320234.post-12527083542221042122008-08-29T12:22:00.002-04:002008-08-29T12:28:39.301-04:00JSFUnit Beta 3 is out. Seam support and more!<span class="postbody">JSFUnit Beta 3 is now released. Special thanks to our new committer Brian Gregory for helping with the conversion from HttpUnit to HtmlUnit as our client side technology (see previous post). Also, the HtmlUnit team has been very helpful with answering questions and providing bug fixes.<br /><br />Click <a href="http://wiki.jboss.org/wiki/JSFUnitBeta3Changes" target="_blank" class="postlink">http://wiki.jboss.org/wiki/JSFUnitBeta3Changes</a> for details on new features. Unlike Beta 2, there are many goodies in this release, including support for Seam conversation scope!<br /><br /><span style="font-style: italic;"> <span style="font-weight: bold;">If you are a Beta 2 user it is very important that you click the above link and read about the deprecated APIs that will be removed before GA.</span> </span> The next planned release will be 1.0.0.GA which should be out before the end of the year.<br /><br />See this page for download information: <a href="http://www.jboss.org/jsfunit/downloads.html" target="_blank" class="postlink">http://www.jboss.org/jsfunit/downloads.html</a>. </span><span class="postbody">Keep all the valuable feedback coming. It is greatly appreciated!</span><br /><span class="postbody"><br />See you at JSFOne next week. <br /><br />So long, and thanks for all the fish,<br /><br />Stan<br /></span>Stan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com0tag:blogger.com,1999:blog-5643789161706320234.post-69299123730120071012008-08-08T13:10:00.002-04:002008-08-08T14:32:42.668-04:00Another JSFUnit Beta Coming Soon<span style="font-weight: bold; font-style: italic;">And why we dumped HttpUnit for HtmlUnit<br /><br /></span>We will release JSFUnit Beta 3 before the start of JSFOne on Septemeber 4th. If all goes well, it will probably be out a week or so before that.<br /><br />Originally, I planned to have the GA release out by now. But the opportunity to improve the JSFUnit tool was too great to pass up. That opportunity came in the form of HtmlUnit. HtmlUnit bills itself as "a headless browser". This is exactly what I've been searching for. That is, a way to truly simulate a user interacting with a JSF application - even one that includes AJAX components.<br /><br />Up until now, JSFUnit used HttpUnit to submit client requests. And HttpUnit is good at that. But HttpUnit is old, and it's mostly a dormant project. It doesn't support the latest DOM specs. And worst of all, its javascript support is dismal. This makes testing JSF/AJAX applications very difficult. In fact, the javascript support was so bad I had to just turn it off. When testing a JSF/AJAX component I would have to simulate the javascript using Java and then formulate the resulting HTTP request myself. It became clear that it would be too hacky and time-consuming to keep doing things that way.<br /><br />So for JSFUnit Beta 3, I've written a new version of the JSFClientSession class that uses HtmlUnit instead. With HtmlUnit, we can execute javascript and let that javascript submit to the server. No fuss, no muss.<br /><br />HtmlUnit is still pretty new, so we've found our share of bugs along the way. But unlike HttpUnit, HtmlUnit has an active core of developers who are working closely with the JSFUnit team to fix problems quickly as possible. Thus, we're doing one last beta release instead of the planned GA.<br /><br />For Beta 3, you can still use the old HttpUnit-based JSFClientSession and things will work fine. This allows our early adopters to migrate their tests to the new client one at a time. But HttpUnit will be completely gone from JSFUnit for GA. So you do need to migrate before then. The new stuff is in its own package called org.jboss.jsfunit.jsfsession. This replaces the old code in org.jboss.jsfunit.facade.<br /><br />That's all the news for now. So long, and thanks for all the fish.<br /><br />Stan<br /><span style="font-weight: bold; font-style: italic;"><span style="font-style: italic;"><span style="font-weight: bold;"></span></span><br /></span>Stan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com0tag:blogger.com,1999:blog-5643789161706320234.post-1104691106702263552008-06-21T18:21:00.003-04:002008-06-21T18:39:47.183-04:00More JSFUnit on the Road<span style="font-weight: bold;font-size:100%;" >First Up, Jazoon '08</span><br />JSFUnit is hitting the road once again, but this time, it's not me doing all the hitting. Alexander Jesse of Credit Suisse will be giving a JSFUnit introduction at Jazoon next week in Zurich. If you are in Zurich on Tuesday, June 24th be sure to check it out. Jazoon offers one-day passes.<br /><a href="http://jazoon.com/jazoon08/en/conference/speakerdetails.html?type=author&detail=Alexander_Jesse">Click Here for More Details</a><br /><br /><span style="font-weight: bold;font-size:100%;" >Second Up, JSF One '08</span><br />I'll be doing at least one talk on JSFUnit at JSF One. This is the first dedicated JSF conference in North America. So if you are into JSF, you won't want to miss it. This is scheduled for September 4th in Vienna, VA (close to Washington, D.C.). And, you get two for the price of one because admission to JSF One also gets you into The Rich Web Experience conference.<br /><a href="http://www.jsfone.com/show_session_view.jsp?presentationId=11073&showId=166">Click Here for More Details</a> or visit <a href="http://www.jsfone.com/">www.jsfone.com</a>.<br /><br />By the time JSF One rolls around, we should have a GA version of JSFUnit out. But more on that later.<br /><br />So long, and thanks for all the fish,<br /><br />StanStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com1tag:blogger.com,1999:blog-5643789161706320234.post-49829581095505983412008-04-15T15:25:00.002-04:002008-04-15T15:40:31.646-04:00Cactus 1.8 is releasedCongratulations to Petar Tachiev on the release of Cactus 1.8. This is the first release of Cactus in over 3 years. Thanks to Petar for taking over as project lead and getting a new release out the door. This release appears to cover mostly bug fixes and Cargo integration, which allows support of more containers.<br /><br />He's also updated the build so that both Cactus and its <a href="http://jakarta.apache.org/cactus/index.html">web site</a> are built using Maven.<br /><br />See the <a href="http://jakarta.apache.org/cactus/index.html">Cactus Site</a> for details.<br /><br />If you've been following <a href="http://www.jboss.org/jsfunit/">JSFUnit</a>, you know that it is built on Cactus, so I'm very happy to see that project come back to life. <br /><br />Life goes on for <a href="http://www.jboss.org/jsfunit/">JSFUnit</a> as well. The <a href="http://www.jboss.com/index.html?module=bb&op=viewforum&f=269">JSFUnit forum</a> has been very popular lately and folks have been anxious to get their hands on a new release. So I'm planning a second beta release for next week. This will be mostly bug fixes, but it will include some new features as well.<br /><br />Unfortunately, major new features like Seam support will have to wait for 1.0 final. We've made some progress, but it's not ready for prime time. Also, if you have a new feature that you really need in <a href="http://www.jboss.org/jsfunit/">JSFUnit</a>, make it known in the forum thread <a href="http://www.jboss.com/index.html?module=bb&op=viewtopic&t=133560">here</a>. I'll do my best to make sure that new features are community-driven.<br /><br />So long, and thanks for all the fish,<br /><br />StanStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com0tag:blogger.com,1999:blog-5643789161706320234.post-10414379907029418892007-11-30T12:11:00.000-05:002007-12-02T14:33:42.796-05:00JSFUnit Beta 1 is Released !!!As I write this I look at the title and wonder how many exclamation points I should have used. What I thought would be a tiny little framework has grown into a full-fledged project with a real beta release. <a href="http://labs.jboss.com/jsfunit/demo.html">We even have live demos.</a><br /><br />JBoss JSFUnit is the first open source community dedicated to testing JSF applications. With this release, it is not one, but three different tools:<br /><ul><li><span style="font-weight: bold;">In-container Testing framework</span> This is for testing both client and server side JSF artifacts. Test scope ranges from fine-grained tests of individual classes to full-fledged integration testing of a running JSF application. This is done with no mock objects, so you know you are getting reliable real-world behavior in your tests.<br /></li><li><span style="font-weight: bold;">Framework for JSF Static Analysis testing</span> This allows you to test your JSF configuration so that you find config problems early.<span style="font-weight: bold;"></span></li><li><span style="font-weight: bold;">JSFTimer for performance testing of the JSF lifecycle</span> This shows you how long each phase of the JSF lifecycle took for a given request. Of course, it also gives you total JSF lifecycle time. The JSFTimer allows you to write threshold tests that fail whenever a use case doesn't meet your performance standards.</li></ul>If you want more info, read the other posts in this blog and then take a look at <a href="http://www.jsfunit.org/">www.jsfunit.org</a>.<br /><br />But now a few more words about the release itself. First, it's called Beta 1. To me, that implies a few things. The first implication is that it's useful. Even before a downloadable release was ready, many developers built the project from subversion and started using it. So I know it meets my main criteria for a beta, which is that it fills a need. It's useful, so by all means, feel free to use it.<br /><br />The second thing about being a beta release is that it's not done. That is, we know some features are missing. Mainly, JSFUnit needs support for more Ajax components and it needs more deployment tools.<br /><br />The last thing I want to say about the release is "Thank You". First, thanks goes to Dennis Byrne of ThoughtWorks and Matt Wringe of JBoss. These guys contributed code to the project and continue to be active. We need more help as demand for bug fixes and new features has ballooned even before we ever released. So if you want to help out just send me an email or post on this blog and let me know how you'd like to get involved.<br /><br />Second, I want to thank Julien Viet, JBoss Portal lead, and Patrick McDonald, my manager at JBoss/Red Hat. These guys have given the high level support that made it possible for me to work on the project in the first place.<br /><br />Lastly, thanks to all who have been the early, early, early adopters. Your feedback on the JSFUnit forums and through email have been invaluable.<br /><br />So try it out. Let me know what you think.<br /><br />So long, and thanks for all the fish,<br /><br />Stan Silvert<br /><a href="http://www.jsfunit.org/">www.jsfunit.org</a>Stan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com0tag:blogger.com,1999:blog-5643789161706320234.post-90409657210133302192007-11-05T09:26:00.000-05:002007-11-05T11:42:20.358-05:00JSFUnit and Grey-box testingAn anonymous viewer posted a question about the nature of JSFUnit. I was going to reply directly to the comment, but I felt that the answer needed its own top-level post since it is so fundamental to the nature of JSFUnit.<br /><br />Anonymous asks,<br /><blockquote><span style="font-style: italic;">Why do you want to implement another testing framework? Why do you not consider WebTest http://webtest.canoo.com ?</span></blockquote>The answer is that frameworks like WebTest, HttpUnit, HTMLUnit, etc. only test the client side. These are pure black-box frameworks for web apps.<br /><br />With JSFUnit, you get both client side and server side testing in one test. Some call this grey-box testing.<br /><br />Plus, the JSFUnit API is written specifically for ease of testing everything you would want to know about a JSF application.<br /><br />For instance, with JSFUnit I can not only submit data on a form, I can also make sure that managed beans were properly updated (using EL expressions).<br /><br />I can make sure that my component tree on the server side is correct using the actual server-side objects created by JSF. Checking the server-side component tree has three distinct advantages that you don't get with just checking the HTML:<br /><ol><li>It's much easier as I can make simple JSF API calls instead of checking raw text or the contents of the client-side DOM.<br /></li><li>I don't have to rewrite my test when the HTML changes.</li><li>I can validate components where rendered=false. In this case, the component is not rendered on the client side, but still has state on the server side.</li></ol>With access to the FacesContext, I can test navigation from the server side with a simple check of the viewID. If you are only testing the client side, you have to infer the viewID and that inference may become wrong as the application evolves. Again, the test breaks simply because you changed the HTML, not because you changed the application logic.<br /><br />I could go on and on about server side testing. There is a lot more to be validated such as database state, security state, and even memory usage.<br /><br />If I want to do the client side (black box) testing, JSFUnit gives full access to the HttpUnit API and the client-side DOM. So that is covered as well. And again, I can even do both black box and white box testing in the same test if I want.<br /><br />Lastly, JSFUnit includes static analysis tests that do validation of your configuration beyond what JSF itself provides. This lets you know about problems specific to JSF that you can catch long before they show up in some obscure use case at run-time.<br /><br />Good question Anonymous. So long, and thanks for all the fish,<br /><br />StanStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com3tag:blogger.com,1999:blog-5643789161706320234.post-42594000958377699502007-10-30T18:21:00.000-04:002007-11-03T13:46:05.760-04:00Introducing JSFUnitA few months ago, Julien Viet, creator of JBoss Portal, sends me an email. He says, "Hey JSF guy, why are there no good testing tools for JSF? I need a tool for this. Maybe you can help?"<br /><br />I took a look and he was (mostly) right. There are a couple of mock object frameworks for JSF as part of Shale and Seam but they are there primarily for testing artifacts you might create for those frameworks. They are really not general testing tools for JSF applications. And they don't help with integration testing at all.<br /><br />So I started thinking up what a general JSF testing tool might look like. Here is what I came up with:<br /><ul><li><span style="font-weight: bold;">No mock objects!!!</span> I really hate mocks. I hate writing mocks. I hate maintaining mocks. And I hate knowing that my mocks don't simulate the environment well enough. But most of all, I hate it when I have to add stupid init() methods to my application code - just for the mocks. And sooner or later I know my tests will fail because of the mocks! <span style="font-size:85%;"><a href="http://jakarta.apache.org/cactus/mock_vs_cactus.html">BTW, here is a saner discussion of Mock vs. In-Container testing.</a></span></li><li><span style="font-weight: bold;">Leverage the JSF API </span>JSF provides tons of information about a running application. If I want to assert that my JSF application state is correct, I should be able to just ask JSF.</li><li><span style="font-weight: bold;">Use plain old JUnit </span>If I want anybody else to use the tool, they shouldn't need to learn how to write tests all over again. JUnit has stood the test of time. It works well and everybody knows how to use it.</li><li><span style="font-weight: bold;">Allow navigation testing</span> A big part of validating JSF is validating that a given user input will navigate to the proper page view.<br /></li><li><span style="font-weight: bold;">Test a JSF App as it is really deployed and run </span>I suspect that this is why nobody has built a full JSF testing framework yet. A real JSF request might start with an AJAX component that fires an HTTP request, then pass through servlet filters, hit the FacesServlet, the JSF lifecycle, a myriad of PhaseListeners, do magic Seam stuff at every turn, and then all get rendered with Facelets. How can you possibly test all that stuff together with a mock framework?</li></ul>So it has to be an in-container thing like Apache Cactus. But Cactus would have me instantiate a FacesServlet and call it directly. That won't quite cut it. What I really need is something that runs in the browser to do real HTTP requests and some kind of JUnit test on the server that lets me do asserts when the request is done. Why not a JUnit test that does both at the same time in the same JVM? Then I can assert that the server side state is correct and the client state is correct - all in the same test.<br /><br /><span style="font-weight: bold;">JSFUnit is done</span><br />I just combine Cactus and HttpUnit and I'm done, right? It took six classes to tie it all together. Cactus lets me run JUnit tests in-container. I can make real HTTP calls with HttpUnit, then test the HTML that comes back. And with a few FacesContext tricks, I have access to all the real server-side JSF objects for navigation, managed beans, EL, the component tree, etc. So I can do real JSF requests, test the real HTML that comes back, and test the real state of the real server-side objects.<br /><br />For real. All in one JUnit test.<br /><br />Only six classes. All that and only six little classes! Julien will really like it.<br /><br /><span style="font-weight: bold;">Julien hates it</span><br />"Stan, this sucks." OK, he didn't exactly say that. At JBoss, they don't just come out and tell you your code sucks. They use a lot more cuss words and throw in an SMD or two.<br /><br />He told me it needed a simpler API and he was right. I wrote some Facade classes and got a Hello World test down to about five or six lines of code:<br /><br /><span style="font-size:85%;"><span style="color: rgb(51, 51, 255);font-family:courier new;" >JSFClientSession client = new JSFClientSession("/hello.jsf");</span><br /><span style="color: rgb(51, 51, 255);font-family:courier new;" >JSFServerSession server = new JSFServerSession(client);</span><br /><span style="color: rgb(51, 51, 255);font-family:courier new;" >client.setParameter("name", "Stan");</span><br /><span style="color: rgb(51, 51, 255);font-family:courier new;" >client.submit();</span><br /><span style="color: rgb(51, 51, 255);font-family:courier new;" >assertEquals("Stan", server.getManagedBeanValue("#{myBean.name}"));</span><br /><span style="color: rgb(51, 51, 255);font-family:courier new;" >assertTrue(client.getWebResponse().getText().contains("Hello, Stan"));</span><br /></span><br /><span style="font-weight: bold;">JSFUnit is just getting started</span><br />So now I'm done? Actually, that was just the beginning. It turns out that AJAX components need special handling so I've added support for most <a href="http://labs.jboss.com/jbossrichfaces/">RichFaces</a> components. Matt Wringe of the JBoss Portal team added Ant integration. Then Dennis Byrne from ThoughtWorks and MyFaces came on board to work on <a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=StaticAnalysis">JSF static analysis tools</a>. This is getting big and broad real fast.<br /><br />There is still a lot to be done. We need to finish the support for the last few <a href="http://labs.jboss.com/jbossrichfaces/">RichFaces</a> components and then move on to other popular component libraries. We need better Maven integration so that it is on par with the Ant tool (JSFUnit tests itself with JSFUnit and Maven. So you can run your tests from Maven, but it needs to be easier). Dennis has lots of good ideas for improving the JSF static analysis. Who knows, at some point maybe we'll even add mocks (maybe not).<br /><br /><span style="font-weight: bold;">JSFUnit Beta 1</span><br />No matter what, we are doing our first Beta release on November 30. Right now you have to download JSFUnit source and build it yourself with Maven. Even so, we've got a lot of folks out there who have done that and are already finding JSFUnit to be a useful tool. So to me, as long as it passes the usefulness test, it's time for Beta. Stay tuned for details.<br /><br />In the mean time, check out <a href="http://www.jsfunit.org/">http://www.jsfunit.org</a>.<br /><br />So long, and thanks for all the fish,<br /><br />Stan SilvertStan Silverthttp://www.blogger.com/profile/15448185150356520608noreply@blogger.com7