Sunday, August 19, 2007

"What's Wrong With Java" as OpenOffice Document

Since my presentation at the Jazoon is only available as a PDF (and it looks horrible, too), I've uploaded the source OpenOffice presentation to my own website. It includes all the additional comments which are missing in the PDF. You can find it here.

For all those who couldn't attend my talk: This document summarizes a few weaknesses of Java which are solved in Python and Groovy and why I think that Java is now at it's peak. From now on, it's going down. Not overnight, of course, and there is no need to rush into any kind of action. But in ten years from now, Java will be where C is today: Something you don't want to build your career on (that's Java, the language, not Java, the VM).

Unit Testing jsp:include

If you're stuck with some JSPs and need to test them with MockRunner, you'll eventually run in the problem to test jsp:include. MockRunner doesn't come with built-in support for this, but this itch can be scratched with a few lines of code:

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;

import com.mockrunner.mock.web.MockRequestDispatcher;
import com.mockrunner.servlet.ServletTestModule;

/**
 * Allow to use jsp:include in tests.
 */
public class NestedMockRequestDispatcher extends MockRequestDispatcher
{
    public ServletTestModule servletTestModule;
    public HttpServlet servlet;

    public NestedMockRequestDispatcher (
            ServletTestModule servletTestModule,
            Class servletClass)
    {
        this.servletTestModule = servletTestModule;
        servlet = servletTestModule.createServlet(servletClass);
    }

    @Override
    public void include (ServletRequest request, ServletResponse response)
            throws ServletException, IOException
    {
        servlet.service(request, response);
    }
}

In your test case, add this method:

    public void prepareInclude(Class servletClass, String path)
    {
        NestedMockRequestDispatcher rd = new NestedMockRequestDispatcher (createServletTestModule(), servletClass);

        getMockRequest().setRequestDispatcher(path, rd);
    }

The path is absolute but without the servlet context. So if the included JSP is named "foo.jsp" and the context is "/webapp", then path is "/foo.jsp". If that doesn't work, print the result of getMockRequest().getRequestDispatcherMap() after the test and you'll see the paths which are expected.

All that's left is to call this method in setUp() for all JSPs that you need to test. If you forget one, the jsp:include just won't do anything (i.e. you won't get an error). To make sure you don't miss any includes (especially ones which you lazy co-workers added after you wrote the test), I suggest that you check the map after the test run for entries which aren't instances of NestedMockRequestDispatcher.

Saturday, August 18, 2007

Blender Tutorials by Montage Studio

I've uploaded the four tutorials from Montage Studio (http://www.montagestudio.org/) on Vuze:

JWilliamson+-+Modeling+the+Female+Face JWilliamson+-+Modeling+an+Eye JWilliamson+-+Modeling+the+Human+Ear JWilliamson+-+Modeling+a+Lowpoly+Character

Unfortunately, the audio on the first one is a bit bad (you can hear the guy working on his keyboard as he speaks).

Monday, August 13, 2007

Demos Have Come a Long Way

I'm a long fan of demos, that is real-time computer animated demonstrations of skill. Or, as the guys themselves would probably say: I can do more pixels per frame than anyone else! (And in 16 colors, too!)

Ah, the good old Amiga times. Of course today, demos are more like music videos or even movies and no one has to worry anymore that Denise would eat too many cycles. Today, the main problem is probably to raise the money for the production ;-) Just check this one out:

Andromeda+Software+Development+-+Lifeforce

"Lifeforce" by Andromeda Software Development, a well deserved rank #1 in the combined demo competition at Assembly 2007. Congrats!