The Holy Java

Building the right thing, building it right, fast

Archive for June, 2011

Most interesting links of June

Posted by Jakub Holý on June 30, 2011

Recommanded Readings

  • Empirical Studies Show Test Driven Development Improves Quality – brief summary of two researche papers comparing TDD/non-TDD, one paper with 1 case study from IBM and 3 from Microsoft (get PDF; conclusion: The pre-release defect density of the four products, measured as defects per thousand lines of code, decreased between 40% and 90% relative to the projects that did not use TDD. The teams’ management reported subjectively a 15–35% increase in initial development time for the teams using TDD, though the teams agreed that this was offset by reduced maintenance costs.), one older summarizing 13 case studies (conclusion: TDD seems to improve software quality, [...] there were indications that TDD does not necessarily decrease the developer productivity or extend the project leadtimes: In some cases, significant productivity improvements were achieved [...] However, in both of those studies the quality was improved.).
  • Quantum computers are reality: World’s first commercial quantum computer sold to Lockheed Martin – this means that hard and NP-hard problems become solvable or at least much easier to solve (this means incredibly lot, just think about optimization problems, scientific computations and simulations, …) and that current security measures are becoming obsolete. It has “only” 128 qubits, which sounds small but is a big thing (competitive regime for quantum comp. is about 100).
  • Fit co-author says acceptance testing costs more then it is worth (i.e. there are better alternatives) – it’s always good to learn from failures; the author, James Shore, has several pleas against A.T.: “[..] customers (a) weren’t interested in doing that, and (b) often couldn’t understand and didn’t trust tests that were written by others. [..] Furthermore, acceptance testing tools are almost invariably used to create end-to-end integration tests, which are slow and brittle. Fit works best for targeted tests that describe the domain, but that’s not how it’s used. Also, tools like Fit [JH: which is based on HTML] don’t work with refactoring tools.“, summarized: non-participation of customers and maintenance burden. Gojko Adzic opposes that we can avoid the pitfalls while retaining the benefits – I guess his Specification by Example book is quite lot about this, as well as the last month mentioned post Top 10 reasons why teams fail with AT

Favourite Quotes

Unit tests, [..], are so coupled to the low-level API that it is often hard for the developers to avoid the trap of proving that the solution works in a particular way, rather than asserting that is solves a particular problem.

- from the book Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation, published in an InformIT article

Posted in General, Testing, Top links of month | Tagged: | Comments Off

Validating JSF EL Expressions in JSF Pages with static-jsfexpression-validator

Posted by Jakub Holý on June 22, 2011

Update: Version 1.0 was released in March 2012
Update: Version 0.9.9 with finished basic support for Facelets
(autodetection of annotated beans, handling of ui:repeat) is available
Update: Version 0.9.7 with experimental Facelets support and a fix of method binding validation released in Nov. (Not mentioning 0.9.5 and .6.) Always check the latest version available! The text below would need to be updated for the new API, which will be done by the end of 2011.
Update: Version 0.9.3 with new group/artifactId released
on 7/25 including native support for JSF 1.2 (reflected below in the pom snippet).
Update: Version 0.9.4 with function tolerance for JSF 1.2 released on 7/28 (it doesn’t check functions are OK but checks their parameters etc.)

static-jsfexpression-validator is utility for verifying that EL expressions in JSF pages, such as #{bean.property}, are correct, that means that they don’t reference undefined managed beans and nonexistent getters or action methods. The purpose is to make JSF-based web applications safer to refactor as the change of a method name will lead to the detection of an invalid expression without need for extensive manual UI tests. It can be run statically, for example from a test. Currently it builds on the JSF implementation v. 1.1 but can be in few hours (or days) modified to support newer version of JSF. How does it work?

Read the rest of this entry »

Posted in j2ee, Languages, Tools | Tagged: , , | 3 Comments »

How to Fix Empty “Show all bookmarks” in Firefox 4

Posted by Jakub Holý on June 20, 2011

Since recently I was unable to edit my bookmarks because Bookmarks -> Show all bookmarks displayed en empty list of bookmarks, though the bookmarks were under the bookmarks menu, B. toolbar etc. The Bookmarks side panel was also empty though.

The solution was to create a backup of my bookmarks (in the json format), stop FF, delete places.sqlite from my profile, start FF and restore bookmarks from the backup.

Read the rest of this entry »

Posted in General | Tagged: , | Comments Off

Hacking Jasper to Get Object Model of a JSP Page

Posted by Jakub Holý on June 10, 2011

To perform some checks and statistical analysis on my JSPs I needed a DOM-like, hierarchical model of elements contained in them. But parsing JSP pages isn’t trivial and is best left to a tool that excels in it – the Jasper JSP compiler used by Tomcat, Jetty, GlassFish and likely also by all others. There is an easy way to tweak it to produce whatever output you need nad to transform a JSP into whatever form you want, including an object model of the page:

  1. Define a Node.Visitor subclass for handling the nodes (tags etc.) of a JSP
  2. Write a simple subclass of Compiler, overriding its generateJava() to invoke the visitor
  3. Subclass the compiler executor JspC overriding its method getCompilerClassName() to return the class of the Compiler of yours

Let’s see the code.

Read the rest of this entry »

Posted in j2ee, Languages, Tools | Tagged: , , , , | 1 Comment »

Version hell with JSFUnit, Arquillian, and (embedded) Glassfish and other containers

Posted by Jakub Holý on June 7, 2011

JSFUnit and the JBoss Arquillian test framework for JavaEE look very promissing, but according to my experience there are good reasons why they are only beta and alpha versions. May be you can get them working but you must pick the right version of each dependency – for many things change between individual versions at this point – and be lucky to hit one of the “happy paths”. At the end I nearly got JSFUnit 1.0.0.Beta1 running with Arquillian 10.0.0.Alpha4 and glassfish-embedded 3.0.1 but failed to deploy due to a strange parse exception of an arquillian’s web fragment. I record this failure to help those who are struggling with this too.

There are the following fatal constraints:

Read the rest of this entry »

Posted in j2ee, Languages, Testing | Tagged: | 2 Comments »