Monthly Archives: January 2013

Testing DropWizard Applications with Spock and Groovy

DropWizard is a really cool framework / library that allows you to quickly build production-ready HTTP+JSON REST services. It is built on mature libraries like Jetty, Jersey, Jackson and Metrics.

The framework bring together a lot of neat ideas for API monitoring like Health checks and simple application metrics via Metrics. DropWizard is very performant, claiming to be able to handle 15,000-20,000 requests per second. There is a pretty good video hailing the benefits of  DropWizard here. The MongoDB-DropWizard slideshow is also very good to see what is possible with the framework.

Compared to Grails, DropWizard feels slightly more lightweight and perfect for services that don’t really have much of a front-end. DropWizard and JavaScript fat clients is the new black.

In this post, I will share how you can use Spock and Groovy instead of the Java / JUnit / Mockito examples provided by the DropWizard User Manual.

If you are not familiar with DropWizard or the testing of DropWizard applications, I suggest reading their Quick Start Guide and User Manual. I will use the Representations and Resources in the Testing DropWizard chapter of their user guide as the basis for this post.

Continue reading

Nested dynamic attributes with Grails Mongodb Plugin

Of the cool features of the Grails MongoDB gorm plugin is dynamic attributes – the ability to define properties in domain classes in an ad-hoc manner. This is actually quite cool since you can have very light domain classes in grails and keep your schemas fairly flexible.

In this post, I will show you how to use nested dynamic attributes with the grails mongodb plugin. Continue reading

Geb Quickie: Automatically download drivers for Chrome and Internet Explorer

A common error encountered by Geb beginners using Webdriver with Chrome or Internet Explorer is that they forget to download and properly configure chromedriver / iedriver.

In this post, I will show you how to set up your project so that it ensures that your driver file is available for your tests. ( Credit Marcin Erdmann for initial implementation ).

Continue reading

Grails 2.x update gotcha – your logging has changed

When updating your application to grails 2.x from the 1.3.x branches, you might notice that your logging no longer works.

This is due to changes in the logging by convention. While this is mentioned in the user guide (under Logging By Convention Changes), it is not very clear what this means.

In our update, we found that we needed to change our Log4J configuration from:

 info 'grails.app.controller',
      'grails.app.task',
      'grails.app.service',
      'grails.app.tagLib',
      'grails.app.bootstrap.BootStrap'

to:

info 'grails.app.controllers',
     'grails.app.jobs',
     'grails.app.services',
     'grails.app.taglib',
     'grails.app.conf.BootStrap'

While this might look trivial, it’s a fairly important breaking change.

Additionally, if you have Quartz jobs in your application, the logging convention changes from task to jobs. This is not mentioned in the grails documentation.

Happy upgrading.