Category Archives: Groovy

Multiple test configurations with TestNG

I use TestNG for automated testing as it has a number of features that JUnit doesn’t have. One of its strengths is the power and flexibility of configuring tests and supplying parameters to them, for which there are two methods: … Continue reading

Posted in Groovy, Testing | Tagged , | Leave a comment

Cool Groovy features 6 – XML parsing

Groovy offers a number of features to make XML processing easier: Building XML using a concise syntax and the MarkupBuilder class. XMLSlurper – allows you to read XML and use GPath, similar to XPath, to query the document. XMLParser – … Continue reading

Posted in Groovy | Tagged | Leave a comment

Cool Groovy features 5 – integration with Ant

The Ant build tool provides a number of really useful features, but when coding in Java it isn’t particularly easy to invoke Ant from your code. Groovy includes Ant and an AntBuilder class that allows you to access it, which … Continue reading

Posted in Groovy | Tagged | Leave a comment

Cool Groovy features 4 – Mixins

A mixin is a way of inheriting methods from a class without the problems associated with multiple inheritance. Groovy supports both compile time and runtime mixins. Compile time mixins Supported with the @Mixin annotation. First define the class that will … Continue reading

Posted in Groovy | Tagged | Leave a comment

Gradle – Groovy based build system

An interesting new build system, based on Groovy: http://www.gradle.org/overview.html  

Posted in Groovy, Java | Tagged , | Leave a comment

Running Struts 1 actions from Spring

I’ve now successfully updated our app so that the Struts 1 actions can be run from Spring. The method was pretty much as I originally described, but there are a few gotchas, so I’ll detail it: Use the Spring ContextLoaderPlugin … Continue reading

Posted in Groovy, Spring | Tagged , | Leave a comment

Groovy performance for file IO

As part of the work I’m doing trying to automate a migration from Struts to Spring MVC, I’ve been writing a Groovy script to process the struts config file. I need to add a couple of lines to the file. … Continue reading

Posted in Groovy | Tagged | Leave a comment

Migrating from Struts to Spring MVC – using Groovy!

To migrate from Struts 1 to Spring MVC, the easiest route is: Add the Spring ContextLoaderPlugin to your struts-config file. This plugin will load your bean definitions file. Update struts-config so that rather than using the default Struts request processor … Continue reading

Posted in Groovy, Spring | Tagged , | Leave a comment

Cool Groovy features 3 – ConfigSlurper

In Java configuration properties can only be key-value pairs e.g. Wouldn’t it be nice to be able to group configuration properties? This is exactly what you can do in Groovy using the ConfigSlurper class. It allows you to write config … Continue reading

Posted in Groovy | Tagged | Leave a comment

Groovy – real life example

In my job we often have spreadsheets of data that we want to quickly turn into SQL scripts. (Yes, I know there are plenty of ways of importing spreadsheets into databases, but our DBAs want SQL scripts!) This is fairly … Continue reading

Posted in Groovy | Tagged | Leave a comment