Archive
Update: JUnit Articles
My first series of articles on JUnit have all been updated with complete source code, which is now housed in my Google Code repository.
Adobe Acrobat: Reading Untagged Document
Are you plagued by Acrobat’s “Reading Untagged Document” dialog, or by extremely slow page renderings as Adobe attempts to “read” pages? Well, thanks to this suggestion, I finally have a solution.
Read more…
FreeMarker, JSP Taglibs outside WAR
Whether you are trying to integration test your controllers from within an IDE or using FreeMarker to generate content outside of a WAR, getting access to your JSP tag libraries can be difficult. You are probably faced with an error such as ‘JspTaglibs["..."] is undefined’. FreeMarker is kind of hard-headed about JSP tag libraries. Let me show you how to get around it.
Update (Sep 6, 2011): I believe this issue has been resolved (here and here) in FreeMarker 2.3.18. If you have a chance to test it, please comment on your success.
Spring, SiteMesh, and FreeMarker
Both Spring and SiteMesh have built-in support for FreeMarker. However, combining the three technologies without duplicating configuration can seem nearly impossible on the surface. In fact, one can easily find several attempts on the Internet. Fortunately, things have improved dramatically in recent years and with a little understanding of how SiteMesh works, we can achieve bliss with very little work.
Spring MVC: Integration Testing Controllers
One of the greatest benefits of Spring MVC is that it removes your dependency on a servlet container. In theory, you should be able to test your controllers, and your entire web stack, from a testing harness like JUnit. In reality, you become just as dependent on the wonderful services offered by DispatcherServlet and a complete WebApplicationContext (request parameter binding, validation, model attributes, request mappings, and aspects such as Spring Security). In this article, I will show you how to create a mock servlet context and WebApplicationContext from within JUnit.
Moving Source to Google Code
I have established a project at Google Code to host the examples and resources developed in this blog. Generally, each post will link directly to related resources. But, you are welcome to visit the project at http://code.google.com/p/ted-young/. Over the next few weeks, I will be revising my previous posts. Hopefully this move will make them easier to read.
JUnit: Generating Tests at Runtime (Part 4: Test Data)
JUnit has become the defacto standard for unit testing in Java. This series will explore how we can extend JUnit to better facilitate the development of reusable tests; reducing the effort required to achieve complete code coverage while minimizing test code maintenance and ensuring quality testing. In this fourth part we extend our factory runner with support for testing runtime generated data.
Leonard Susskind Lectures Update
I have updated my collection of Leonard Susskind lectures:
- I added links to a new three-quarter sequence entitled “New Revolutions in Particle Physics”,
- Fixed the names and order of the two-quarter sequence on Theoretical Physics.
- Added iTunes links.
Enjoy!
Media Centers, Set-Top Boxes, Media-Centric Parties
I wanted to throw a party oriented around movies, music, and web-based video. The new market of set top boxes is starting to offer some promising solutions. But, they currently fall short. Let me show you how I set up a full-blown media center capable of keeping up with the high expectations and limited patience of my party guests.
Registering Custom Type Converters in Spring MVC 3
If you use annotated controllers in Spring MVC 3, you probably will agree with me that request parameter binding is an amazing feature:
@RequestMapping("url")
public String handler(@RequestParam String name, @ModelAttribute DomainObject object) {
...
}
In such a case, Spring will automatically populate name and the properties of the DomainObject based on the data sent along with the request (URL parameters, post data).
But, what if you want to map request data (Strings) to something other than the types supported by Spring (String, primitives, wrappers, Date, etc.)? Because of sweeping changes in how this was done since version 2.5, a correct answer is hard to come by. I will put the issue to rest here (and hopefully someone will find it).