Grails API Functional Testing
July 15th, 2014
Examples of testing Grails APIs with Grails Rest Client Builder, Groovy Http Builder, and Apache Http Client
A static site generator is software that translates content from a text format into HTML and creates consistant look and feel across all the pages. These HTML pages can be copied to any basic webserver. Usually the base format is Markdown or AsciiDoc which is then converted into an HTML snippet, and then put into a larger HTML page. After generation, those files are copied to a basic webserver that serves the plain HTML.
Static site generators are popular with the technical crowd. It takes the complexity off of the server (no database! no caching!) and puts it on our local machine. Most have some sort of command-line system that runs rsync to copy the updated files to the web server. Having just plain HTML makes the site more secure than traditional blogging platforms. It’s hard to do a Bobby Tables if there is no database, and you don’t have to worry about the latest PHP security updates — it’s all just plain o’ HTML, CSS, and JavaScript.
There are lots of different static site generators, usually multiple ones for each programming language. Groovy’s relatively new entry in to this world is Grain. The developers of Grain decided not to reinvent the wheel, but instead implement other technolgies in their software. For example, Grain will automatically generate CSS from SASS or SCSS sources. But instead of implementing their own SASS parser in Groovy, it attempts to use Ruby on your system and, failing that, it installs JRuby into it’s sandbox and runs the SASS gem from there. This is automatic — no user configuration is necessary for this to occur. Of course you can set a default if you want.
Other great things about Grain:
Best yet — it’s distributed under the Apache license.
To get started with Grain, you can grab one of the pre-built themes as a starting point. Then you can read the docs yourself. But after the initial setup, my workflow for a blog post is usually:
grain create-post <post name>
— creates a Markdown file under content/blog
grain preview
— starts the preview servergrain generate
— generates the HTML filesgrain deploy
— run rsync on my generate files to the serverExamples of testing Grails APIs with Grails Rest Client Builder, Groovy Http Builder, and Apache Http Client
Groovy has a limitation that restricts multiple assignment to simple variables. However, by using with(), we may be able to work around that.
Review of material and presentations from Gradle Summit 2014, Santa Clara, California.
Mike has almost 20 years of experience in technology. He started in networking and Unix administration, and grew into technical support and QA testing. But he has always done some development on the side and decided a few years ago to pursue it full-time. His history of working with users gives Mike a unique perspective on writing software.