February 2010
8 posts
2 tags
Using Grails's JSON support with HTTPBuilder
I am currently working on a set of JSON over HTTP web services APIs between Grails applications. Producing JSON content in Grails applications is ridiculously trivial, but the story on consuming content is not so clear. I am using Tom Nichol’s HTTPBuilder for consumption. It’s a great library, but does take a little getting used to. Fortunately, the documentation is excellent. ...
Feb 24th
2 tags
Automatically packaging inline plugins in Grails...
Working with module Grails applications via in-place plugins is currently not as convenient as it could be. One of the major sticking points is the need to package-plugin all of your inline plugins manually before using them in your application’s build. If you try to build your app without packaging your in-place plugins first you will see something like… The inplace plugin at [«plugin...
Feb 22nd
2 tags
Instantiating the right class in Groovy dynamic...
I just came across some Groovy code that essentially looks like this… def installConstructor(Class clazz) { clazz.metaClass.constructor = { Map params -> def instance = clazz.newInstance() // do some stuff with params instance } } Looks innocent at first right? Consider this… class Parent {} class Child extends Parent { String name...
Feb 20th
2 tags
Brute force fixture cleanup in Grails
I am currently working on establishing a suite of functional tests. I am using the functional test features of the spock plugin to do this, which I’ll be writing more on in the near future. Naturally, I am using the fixtures plugin to load my test data in the functional tests. However, the plugin provides no support for tearing down data. You generally don’t need to worry about this...
Feb 18th
2 tags
Integration Testing Grails Filters
Grails currently doesn’t ship with any support for testing filters, other than via a functional test. It’s pretty easy to roll your own filter integration tests though. Here is an example: import grails.util.GrailsWebUtil class MyFilterTests extends GroovyTestCase { def filterInterceptor def grailsApplication def grailsWebRequest def request(Map params,...
Feb 15th
2 tags
Dealing with common test support across test types
Grails ships with several different test superclasses to make your testing life easier. This is great, but what if you have your own common testing bits that you want to provide in a superclass? Even worse, what if you are using the Spock plugin and have a completely different class hierarchy to work with? The current project I am working on has a mix of Spock and JUnit tests of different types....
Feb 15th
1 tag
Panic! At The Disco: Pretty Odd
A very underrated album that kind of slipped past without much fanfare. I despised these guys from their first single. It dropped around the same time My Chemical Romance were getting airplay and there was way too much guyliner and mascara going on. Shitty Emo fashion aside the first album was ok. Not great, but ok. This one really shines though. It plays like a modern day Sgt. Peppers with...
Feb 12th
2 tags
Providing non-domain validateables in Grails...
Grails now (1.2+) supports making arbitrary classes validateable. This is easy enough, but what if you have a plugin with a non-domain class that needs to be validateable? What you might try is adding the necessary config into the Config.groovy in your plugin. This is not going to work though because that’s not going to be sourced when your plugin is deployed into an application. So...
Feb 9th