Importing CSV file data into an in-memory H2 database with Groovy

There are times when you just need a quick database loaded with test data and don't want to persist, set up, or install anything. Well, this is where the in-memory mode of the H2 database engine can come in handy (http://www.h2database.com/)!

Getting ready

Before using the H2 database, we need to download its JAR and add it to SoapUI's classpath. You can get the latest H2 JAR from http://mvnrepository.com/artifact/com.h2database/h2/ (I took version 1.4.181). Then, add it to <SoapUI Installation Directory>/java/app/bin/ext/.

You'll also need some headed CSV data. Amazingly, the script might be able to handle any valid CSV structure (see http://www.h2database.com/html/functions.html#csvread ...

Get SoapUI Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.