Embracing the Messiness in Search of Epic Solutions

Tag: Groovy

  • Java + Groovy: Creating Immutable List

    Java: Mutable List Java: Immutable List Java: Immutable List using Guava Groovy: Immutable List Read More…

  • Spock: Reading Test Data from CSV File

    Following up on my recent post about creating a Spock specification to read the test data from a CSV file without loading all the data into the memory, I created a CSVReader that implements Iterable that allows me to pull this off. You may download the source code here. With this implementation, I can now… Read More…

  • Maven: Unable to Execute Spock Specs

    PROBLEM When running mvn clean test, Maven Surefire Plugin doesn’t pick up *Spec.groovy test files. SOLUTION By default, Maven Surefire Plugin is configured to execute test files with the following patterns: **/Test*.java, **/*Test.java and **/*TestCase.java. To fix this, we need to modify the inclusion list for this plugin. Since both Java and Groovy files get… Read More…

  • Comparing Disassembled Java Class From JVM Languages

    All JVM languages come with some degrees of syntactic sugar to make the code easier to read and write. To satisfy my curiosity, I decided to run javap command to disassemble the bytecode inside the class file generated from several JVM languages. The chosen languages are Java, Groovy, Scala, JRuby and Rhino. I left out… Read More…

  • Java: Programmatically Compile and Unit Test Generated Groovy Source Code

    My previous post shows how you can programmatically compile and unit test the generated Java source code. In this example, we will programmatically compile and unit test the generated Groovy source code. Let’s assume we have the following service class that generates Groovy source code as one big String:- To unit test the generated Groovy… Read More…

  • Groovy: java.lang.StackOverflowError When Implementing equals()

    PROBLEM While migrating a portion of my Java code to Groovy code, I got bitten by the Groovy operator loading feature that I should have known better… and my pride hurts, but hey, I admit I write shitty code. Consider this simple POGO with custom equals() and hashCode(), both implemented using Google Guava libraries:- What… Read More…