Tuesday, November 11, 2008

Clover Test Optimization

The new Clover 'Test Optimization' feature seems pretty appealing.  Using coverage data, Clover can determine which tests need to be run to cover the changes you've made, and then run these (or run these first), such that you can get your testing done faster and/or fail faster. 

Thursday, November 6, 2008

Google AppEngine Syntax Errors with CRLFs under Cygwin

I've had a frustrating patch using Google App Engine lately.  Trying to use minidom under Windows was giving me an import error -- possibly I needed to find a way to install expat?  I installed python via cygwin to see if that was any better, in part because I could see that libexpat was a viable option under cygwin, and in part because I was sick of Python not understanding my Bash-style paths.


That solved the problems with Minidom, but then I suddenly started getting syntax errors on perfectly reasonable (and previously operational) import statements, which was pretty frustrating.  After a few false starts, I discovered that some Mac/Python users ran into similar errors when using GAE on Python scripts that had Windows-style CRLFs instead of simple line feeds.  I switched the line terminators in Eclipse, and voila, problem went away.

The issue report I found is closed, but i've commented in the hopes that the fix can make it into GAE for Windows for those of us using Cygwin.  i'm looking forward to replacing this half-dead laptop with something better that will run Linux or OS X in the near future.

Sunday, November 2, 2008

Google App Engine: REST, Frameworks, Lock-In and Agency Work

I've been doing a little experimentation with Google App Engine for a minor side project, and in the process of so doing, I've been discovering that App Engine seems reasonably well-suited for delivering a RESTful application.  I'm not ready to talk specifics or open-source the codebase for further examination, but I may get there.


In some ways, App Engine seems lower-level than I'd thus far; simple things like binding a URL to a template can't be done without a bit of code.  It seems like there's room for the framework to get a little thicker to cover the most common cases.  In essence, if enough people were going to use App Engine, I think there'd be some value in an App Engine framework.

Unfortunately, the primary problem is still this one: if you're building a long-term application that you expect to use and maintain, then doing it on someone else's infrastructure over which you have very limited control is a risky strategy -- you're making Google a silent partner in your business.   Google's a better partner than most vendors, I imagine, but it's still a pretty big leap of faith.

I'm curious App Engine would work in an agency environment where you're developing relatively short-term projects, where the infrastructure is rarely under your control, and where tying the ongoing costs to actual usage might make a lot of sense.  It's possible that this kind of approach might even be a differentiator for some agency work.  Anyone doin' it?

Friday, October 31, 2008

Configuring Cargo/Tomcat with Maven2

Commenting on my last post, Rob Sinner asked, "Can you post the pom.XML your using to launch cargo[?]"  I haven't had the problem he described, but I don't mind sharing the configuration I use.


Basic Cargo/Tomcat Configuration
A basic cargo/tomcat configuration adds the cargo plugin to your build plugins. If you place this within a WAR module, the module in which the cargo plugin is defined will be automatically deployed with no extra work on your part:

<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0-beta-1</version>
<configuration>
<container>
<containerId>tomcat5x</containerId>
<zipUrlInstaller>
<url>http://www.apache.org/dist/tomcat/tomcat-5/v5.5.27/bin/apache-tomcat-5.5.27.zip</url>
</zipUrlInstaller>
</container>
<configuration>
<home>${project.build.directory}/tomcat5x/</home>
<properties>
<cargo.servlet.port>${servlet.port}</cargo.servlet.port>
</properties>
</configuration>
</configuration>
</plugin>
To fire up cargo, simply enter:
mvn cargo:start
To exit, press Ctrl-C.

Integration Tests
You can configure Cargo to start before the integration test phase and shut down after the integration test phase. This is useful if you have automated integration tests that you'd like to run against your in-container application. It's as simple as binding the cargo goals to the correct lifecycle phases:

<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<wait>false</wait>
</configuration>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>

Deploying Other Modules
In some cases, you'll want to deploy one or more modules that aren't the project you're in. In this case, you'll want to define deployables explicitly inside the cargo configuration:

<deployables>
<deployable>
<groupId>com.mycompany.myproject</groupId>
<artifactId>myproject-alpha</artifactId>
<type>war</type>
<properties>
<context>alpha</context>
</properties>
</deployable>
<deployable>
<groupId>com.mycompany.myproject</groupId>
<artifactId>myproject-beta</artifactId>
<type>war</type>
<properties>
<context>beta</context>
</properties>
</deployable>
</deployables>
Debugging
If you want the option of connecting a remote debugger to tomcat after firing it up via Maven/Cargo, I'd suggest a profile.  This is what we typically use:

<profile>
<id>cargo-debug</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0-alpha-6</version>
<configuration>
<configuration>
<properties>
<cargo.jvmargs><![CDATA[-Xdebug -Xrunjdwp:transport=dt_socket,address=15102,server=y,suspend=n]]></cargo.jvmargs>
</properties>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
</profile>

You can invoke this using:
mvn cargo:start -Pcargo-debug

Alternatives
There's also a Maven Jetty Plugin which has a pretty good reputation.  Unfortunately, there are currently two plugins with the jetty prefix, one in the mojo repository, and the other from mortbay.  The former takes precedence for me, whicih makes using the Mortbay version painful.