Groovy: split string and avoid getting IndexOutOfBoundsException
If you use Groovy for scripting or other similar tasks you probably faced a situation where you get an input as a text and you need to process it e.g. split by some delimiter and continue working with extracted values. In this post I will show you how to do it in 3 different ways.
Ratpack: register SessionModule in handler unit test
Unit testing Ratpack handlers has many benefits. In the previous post we have learned how to mock Session object to use it with
GroovyRequestFixture. Today instead of mocking we will register
SessionModule and then we will use a real session object.
Ratpack: mocking Session object in GroovyRequestFixture test
Ratpack allows you unit test handlers using
GroovyRequestFixture class. The good thing about this approach is that it does not require running the whole application and you can quickly test if the handler does what you expect. However, if you retrieve objects from Raptack’s registry you will run into a problem - registry in this case is empty.
Groovy script: closure does not modify @Field annotated variable
Recently I have answered a few questions on Stack Overflow related to Groovy scripts and how they work in combination with closures and delegated objects. Some of use cases may not be intuitive and today I’m gonna show you one of them and explain what happens under the hood.
Why "grails package" executes Config.groovy file?
This blog post is inspired by one of my recent Stack Overflow answers to following question: Grails: why is the Config.groovy file executed during compilation?. Here I’m going to show you step by step what makes
grails package command executing
Config.groovy script and how I’ve managed to find the answer to that question.