April 2012
1 post
3 tags
Gr8Conf EU, now with more me
I’m excited to be presenting a GR8Conf EU this year. This will be my first time at GR8 Conf and I’m looking forward to meeting some of the Groovy community that I’ve not had the opportunity to meet before.
I’ll be presenting on Geb, as both an introduction for the uninitiated and to discuss the new features that have appeared in the last few months. It will be an...
November 2011
1 post
2 tags
In response to Rob's post on functional testing.
Rob, a Geb committer and all around cool dude, recently posted some thoughts on function testing.
The following is what I intended to be a comment on Rob’s blog, but it became too long so I decided to post it here. You’ll notice that the language is a bit weird as in some places I am addressing Rob directly. It should make sense (no guarantees) if you pretend you are reading it as a...
June 2011
1 post
2 tags
Geb Modules and isDisplayed()
A question recently came up on the Geb user mailing list about checking to see if a module is displayed on a page. It turns out the concept of displayed could do with some exploration.
Say we have the following html…
<p class="a" style="display:none"/>
<p class="b"/>
The following assertions will pass…
def a = $("p.a")
def b = $("p.b")
def c = $("p.c")
assert a &&...
May 2011
2 posts
2 tags
Using Grails tags where you can't use Grails tags
Sometimes in a Grails app, you need to call a tag where you can’t call a tag. This is usually indicative of a bad design in your application so do use the following with caution, but should you absolutely need to… the following is how you can.
In this example, we are going to add the ability to call tags to a filter to workaround GRAILS-6814. We want to call the createLink tag.
Note...
2 tags
Always developing Grails apps with https and...
In response to a number of bugs creeping through to production due to classpath differences and ssl issues, I went about setting up my culprit grails app to always functionally test as a war and with https in both development and testing. Here’s how to do it.
It turns out that there are two bugs/issues with the current grails tomcat plugin that get in the way of this objective, so...
March 2011
1 post
3 tags
Decorating Constructors with Groovy
I recently put out a new plugin for Grails that brings something like view models to Grails applications. An interesting feature of this plugin is that it supports direct object instantiation with implicit autowiring. You might think that Grails already support this, but it doesn’t. Currently, you can directly instantiate domain objects and get autowiring but you can’t write a...
February 2011
1 post
2 tags
Spock's @AutoCleanup feature
You may have missed this little gem that was added to Spock in the 0.5 release…
import spock.lang
class InputStreamSpec extends Specification {
@AutoCleanup
def input = new FileInputStream("myfile.txt")
def "some input stream tests"() {
// …
}
}
The spock.lang.AutoCleanup annotation works via Spock’s extension mechanism.
Let’s have a look at the...
January 2011
1 post
2 tags
Disabling Grails plugin upgrade confirmation
Quick one…
If you want to permanently disable plugin version change confirmations (e.g. when another developer has changed a plugin version in BuildConfig.groovy), simply add this to your scripts/_Events.groovy:
def resolveDependenciesWasInteractive = false
eventResolveDependenciesStart = {
resolveDependenciesWasInteractive = isInteractive
isInteractive =...
October 2010
2 posts
3 tags
Spock's new matching support
Spock has an interesting new feature coming in 0.5 (but its available now in recent builds of 0.5-SNAPSHOT) integrating the Hamcrest matching library, which is an API for testing that something meets certain criteria. It’s always been possible to use Hamcrest with Spock but there is now a more convenient syntax. The expressiveness of Groovy generally makes Hamcrest not quite as generally...
2 tags
Getting more out of Property Override...
The “Property Override Configuration” feature is an extremely useful technique for Grails applications. It allows you to specify the values for bean properties in your application configuration, which can be done externally and/or in an environment sensitive manner.
For example, we could easily control the number of simultaneous connections a particular service is allowed to make to a particular...
August 2010
2 posts
3 tags
Painless Page Identification with Geb & Grails
This will be a discussion of a handy pattern to use to make page identification simple and easy when working with Geb and Grails.
Geb and Page Identification
Geb supports (and encourages) using the Page Object Pattern. An aspect of this is having someway of being able to verify that the page object actually does represent the page that the browser is at. Consider filling out a form. When you...
1 tag
Annotation Driven Extensions With Spock
The following is an introduction to writing extensions with everybody’s favourite testing tool Spock. Like all things in Spock, extensions are easy to use and require little ceremony. We are going to build an extension that times various parts of test execution and blindly writes the times to standard out.
Please note that the API we are going to go through should not be considered...
June 2010
2 posts
2 tags
Proposal: Grails Plugin Collective
The following is a proposal for, and a request for comment on, the idea of a semi-structured combination of social and technological systems and norms to initiate, develop and maintain Grails plugins.
The Problem Being Addressed
Typically, a plugin is born through inspiration or necessity. It’s not uncommon that the original author at some point stops maintaining or developing a...
May 2010
2 posts
2 tags
Putting the Artefact API to work in your Grails...
I haven’t seen many cases of people putting the Grails’ artefact API to use in their application. It’s likely that most Grails’ users aren’t aware that it exists, which in many ways is a good thing… it is after all an implementation concern.
You can however put it to work in your own application.
What is it?
Perhaps it’s best to discuss what an artefact is...
2 tags
Forwarding/Chaining and models in Grails
I recently hit the case where I need to forward a request in Grails to a second action, but that action needed access to the model generated by the first (note that this is different to params). The Grails documentation doesn’t mention the ability to pass models when forwarding at all, but if you check the source code you can see that the capability is there.
What’s also missing is...
3 tags
Custom Grails Test Types/Phases
Recently there was a query on the grails-user mailing list asking how to create a separate test suite (in the poster’s terminology). In Grails’ terminology, what the poster wanted was a separate test type that could be run separately.
The following is an expansion on the solution offered in the thread.
There are two core concepts in the test system; types and phases.
Test Phases
...
March 2010
3 posts
2 tags
Grails, WebTest and JQuery.
The recently released grails-webtest 2.0.2 now installs WebTest via dependency resolution.
This allows you to work around the HTMLUnit 2.4 incompatibility with JQuery. WebTest 3.0 depends on HTMLUnit 2.4, but we can force the use of HTMLUnit 2.5 which works with JQuery.
Simply add it as a dependency in your app.
grails.project.dependency.resolution = {
inherits "global"
log "warn"
...
2 tags
Scoped Services & Proxies in Grails
Update: I have released a plugin that makes working with scoped proxies a little bit easier.
Grails has supported “scoping” services for as long as I have been working with it. Surprisingly, you very rarely here of people using this feature. For my money, it’s one of the lowest cost techniques available to avoid the inherent spaghetti in referencing the session and request (for all intents...
2 tags
Configuration based Spring bean definition with...
I released a new version of the Grails JMS plugin (0.5) over the weekend. This release features completely rewritten internals to expose every configuration aspect of the underlying Spring JMS classes. JMS is a complicated topic with lots of setup and configuration options so this level of access is necessary.
What’s novel about the approach is that it allows users to configure the...
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.
...
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...
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...
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...
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,...
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....
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...
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...
September 2009
2 posts
2 tags
TextMate Interactive Input and Snow Leopard
I had some fun today upgrading tm_interactive_input.dylib to make it work with Snow Leopard. Previously, it was busted in a pretty decent way.
I can’t be exactly sure, but it seems that malloc() on Snow Leopard calls read() for some strange reason. Since our overloaded read() implementation does quite a few things, including a lot of malloc()ing we have a problem. The end result was that...
1 tag
Reclaim your home life with AppleScript
Anyone using Mail.app to both work and home combined with MobileMe sync is probably like me and unable to avoid reading work email when at home because you just can’t resist taking a look when you see something new there. A co-worker came up with a good solution to this problem: stop Mail.app from checking for new email in your work account during non work hours.
Here is a simple...
January 2009
1 post
1 tag
Why I do Open Source
(This was inspired by Andres Almiray)
I did not have a lot of exposure to Open Source software during my formative computing years. I come from a Classic Mac OS (I saw the last few releases of 7) background and was blissfully ignorant to Linux. The move to OS X exposed me to a plethora of previously unavailable software and during this time I was becoming interested in coding. As a student...
December 2008
1 post
2 tags
Gldapo Validation
I am about to commit the new GORM inspired validation mechanism to Gldapo. Here is what it is going to look like…
Declaring your constraints
Instead of a DSL like GORM, we are using annotations…
import gldapo.schema.annotations.
class Person {
@GldapoNamingAttribute
String uid
@Required
String sn
@Required
@Matches(/[A-Z]./)
String givenName
} Plugging in your...
September 2008
2 posts
1 tag
Grails TextMate bundle is being improved
I am working on a grails app (more info to come), as such I am making some long needed improvements to the Grails TextMate bundle. If you are using this, you might want to subscribe to the bundle changes feed.
I have made two changes already; a snippet for the tag in GSPs, and a command to run a single test case (the currently open file in TM).
Gldapo 0.7.1 Released
This release has only one change which fixes an issue with password attributes.
August 2008
1 post
Gldapo 0.7 Released
Gldapo 0.7 (and a corresponding grails plugin) is now available.
This release primarily fixes some bugs with password attributes and brings the following major features/improvements:
The addition of an LDAP filter DSL (thanks to Siegfried Puchbauer)
Drastic improvement to the API for creating and moving objects.
JavaDoc for commonly used classes (thanks to new GMaven features)
Release...
July 2008
3 posts
2 tags
New Java and JavaDoc TextMate bundles
Finally, I got the new Java and JavaDoc TM bundles up to scratch and got them promoted from review.
If you are using TM for Java, you’ll want to update your bundle.
Moving/Replacing entries with Gldapo 0.7
Following on from the previous post, Gldapo 0.7 makes dealing with the location of LDAP objects much easier. This impacts the move() and replace() methods. I’ll focus on replace() here, but pretty much everything applies to move().
0.7 introduces a new signature of replace(String namingValue, Object parent). Let’s look at some usage then I’ll explain.
What we want to do here...
@GldapoNamingAttribute
I’ve been working on making the way you define the location of an entry object better.
In Gldapo 0.6, this is a bit cumbersome. Let’s look at some examples. Here is our schema class in 0.6…
class Person
{
String cn
String sn
} So let’s create one of these people in an ou called people…
def p = new Person(
cn: "Luke"
sn: "Daley"
rdn:...
June 2008
6 posts
The warm blanket of test coverage
A recent email identified that Gldapo struggles to work with password type attributes. I suspected this was going to be the case, but had pushed it aside in the hope that no one would hit the problem until I had time to look at it. Passwords are a bit of a funny case as they aren’t really read/write, but there are cases when you do want to read the encrypted password hash.
It turns out...
Gldapo Support Email
I never thought I would say this… but I kinda like getting support email. Before my colleagues at work read this and start dumping all support cases on me, I am referring to Gldapo support.
Since it’s still a new project really in terms of adoption (first commit was on 07 July 2007 out of interest), support emails are a kind of vindication as they let you know that it is actually being...
Behavioural Dominance
As part of a course I am doing through work, I recently took part in a DISC behaviour assessment.
What?
From that link…
DISC is a group of psychological inventories developed by John Geier and based on the 1928 work of psychologist William Moulton Marston.
Not too helpful. Further into the article we get a bit more help…
DISC is the four quadrant behavioral model based on the work of...
TextMate Bundles svn win
» svn log http://macromates.com/svn/Bundles -r 10000
------------------------------------------------------------------------
r10000 | ldaley | 2008-06-21 12:33:40 +1000 (Sat, 21 Jun 2008) | 3 lines
• Update GroovyMate to TextMate::Executor.run()
(winnah)
------------------------------------------------------------------------
That’s right bitches.
Gldapo (0.6) now hosted @ Codehaus
Codehaus were kind enough to approve my request to have Gldapo hosted there. I have now released 0.6 which lives at new home of http://gldapo.codehaus.org.
This gives me some great stuff I sorely needed. Like an issue tracker and a CI and distribution in the central maven repo.
Now it feels like a real project.
A case for Maven (making Gldapo testing easier)
Gldapo uses Maven which, for those uninitiated, is a new generation build system based on that ever popular idea of “convention over configuration”.
There is a lot of maven hate about the intertubes. I am not going to get into that now (I’m on the pro side if you are wondering). What I do want to show is how I was able to add a really cool set of tests to the Gldapo build with very little...
April 2008
3 posts
Gldapo 0.5.2
I have released Gldapo 0.5.2. The 0.5 release saw the addition of support for write operations to the directory. It’s a bit of a milestone release as Gldapo is now functional enough to be used in a real world project. In fact, I have received a few emails from users and potential users.
Marco Mornetti submitted a patch which allowed Gldapo to be used to authenticate users with ease which I...
Java TextMate Bundle
I have finally started on reworking the Java bundle for TM (it’s currently sitting in review).
The old grammar had some serious problems, so I started completely from scratch. The old grammar seriously broke down on a few constructs, one of the most prominent being anonymous inner classes. I am proud to say that the new grammar handles them quite gracefully. I am sure there are lurking...
Maven TextMate Bundle
Some time ago, my Maven bundle for TextMate went live into the main repository. I encourage anybody working with Maven on Mac OS to check it out. I couldn’t live with out it now.
My favourite feature would have to be the scoping of Groovy source in your POM if you use the Groovy plugin and specify an inline script. This makes all the snippets and niceties of the Groovy bundle available to...
March 2008
1 post
Closures for readability
This is really just common sense and all the cool kids are probably already doing it, but I just had a mini revelation. If your programming language supports closures (or code blocks, whatever) then you can create local closures that implement some kind of test to clean up your logical branching.
I had the situation recently where a particular bit of code was getting hard to follow. The problem...
January 2008
1 post
Gldapo 0.4
I released a new version of Gldapo over the holidays. The new version contains a slew of backend improvements and general refactorings. The code base is taking shape. Adding new features should be trivial moving forward.
As an aside, for small (one man) teams Maven is an absolutely indispensable tool. I now have a completely repeatable release procedure that does everything I need it to (and...