background preloader


Facebook Twitter

Testing Grails – A Collection of Useful Resources. Gmetrics & Codenarc Script For Grails - Christian Oestreich. I really wanted to get our project working with sonar and grails.

Gmetrics & Codenarc Script For Grails - Christian Oestreich

After some searching I found very few people that had this working. Actually I only found one here. I tried doing this by adding the pom.xml and invoking the mvn sonar:sonar target. Maven got to the end and threw an exception. I spent the better part of a day working on this and poking around at the pom file and finally gave up. Setting Up The Environment All the source code for this can be found at GitHub. Git clone Grails Performance Framework - Christian Oestreich. I built a relatively simple framework to do performance testing of code using redis, jesque and executor.

Grails Performance Framework - Christian Oestreich

It uses some jQuery and ajax on the front end and provides a relatively simple administrative UI. The code is currently availabe on github. The overhead of the perf runner is relatively light and extremely fast as it is using redis as its storage mechanism for queues, jobs, statistics, and status. If you would like to change where or how the results are saved you could certainly hack the code in the ResultsService. Update 2/7/12 I have made some slight changes to the framework and have updated this post and docs to illustrate the changes. Stuff I Learned from Grails Consulting. I don’t do much Grails consulting since I work for the Engineering group, and we have an excellent group of support engineers that usually work directly with clients.

Stuff I Learned from Grails Consulting

I do occasionally teach the 3-day Groovy and Grails course but I’ve only been on two onsite consulting gigs so far, and one was a two-week engagement that ended last week. As is often the case when you teach something or help someone else out, I learned a lot and was reminded of a lot of stuff I’d forgotten about, so I thought it would be good to write some of that down for future reference. SQL Logging There are two ways to view SQL output from queries; adding logSql = true in DataSource.groovy and configuring Log4j loggers. La persistance polyglotte avec Grails. La persistance polyglotte Le terme de persistance polyglotte (cf.

La persistance polyglotte avec Grails

Polyglot Persistence) a été introduit par Scott Leberknight dans le milieu des années 2000. Il tire son nom de la programmation polyglotte (cf. Polyglot Programming), un principe qui consiste à choisir le langage approprié pour répondre à une problématique spécifique. Ce principe sous-entend donc, la coexistence de différents langages dans une même application, en tirant profit des forces de chacun d'entre eux. La persistance polyglotte ressemble en tout point à la programmation polyglotte sauf qu’elle se concentre non pas sur les langages de programmation mais sur les bases de données.

Fixing Grails Tests That Pass in Isolation but Fail When Run as a Suite - Ted Naleid - Waterfox. If you’ve got a test that passes when run by itself but fails when run with the rest of the tests in your test suite, you’ve almost definitely got a test pollution problem.

Fixing Grails Tests That Pass in Isolation but Fail When Run as a Suite - Ted Naleid - Waterfox

Test pollution happens when the results of one test live past the tearDown of a test and impact the results of subsequent tests. This can happen in any kind of environment that has side-effects, but in Groovy and Grails programming, is most often caused by making changes to a metaClass or singleton instance that you forget to remove when the test is done. One other place where test pollution often rears it’s head is when a set of tests run fine in development, but when pushed to an integration server it fails. Often, this is because the developer is working on OSX, but the build server is on Linux and those platforms run the tests in a different order. Grails Best Practices. I work at IntelliGrape, a company which specializes in Groovy & Grails development.

Grails Best Practices

This article is a basic list of best practices that our Grails projects follow, gathered from mailing lists, Stack Overflow, blogs, podcasts and internal discussions at IntelliGrape. They are categorized under controller, service, domain, views, taglibs, testing and general. The advice here is specifically for Grails 2.0, although much of it is generally applicable. Controller Don’t allow the controller to take over another role. Grails Best Practices. Grails is designed to be an interactive agile based rapid development framework which advocates convention not configuration.

Grails Best Practices

This article explained the usage and best practices around the Grails. Domain-driven design Always use domain-driven design: First create your basic domain model classes, and then use scaffolding to get them online. This will help you stay motivated and understand your domain better. Grails Design Best Practices. Grails is designed to be an interactive agile based rapid development framework which advocates convention not configuration.

Grails Design Best Practices

This article explained the usage and best practices around the Grails. Domain-driven design Always use domain-driven design: First create your basic domain model classes, and then use scaffolding to get them online. This will help you stay motivated and understand your domain better.Use Test Driven Approach: Domain model test cases provide a great way of experimenting testing out your validations.Validate: Use validators to keep your domain objects in order. Leverage Spring Security to Handle Mobile Access to Your Grails App. Now that I have an AWESOME little mobile version of my grails appliction, why do I put myself through the pain of logging in through the standard login page?

Leverage Spring Security to Handle Mobile Access to Your Grails App

It gets to be a lot of pinch-zooming and thumb dragging (2x’s if I accidently mis-type your credentials with my fat fingers). What I was looking to implement, was when a mobile browser came to my site (unauthorized), I wanted to show them a mobile login screen. Upon successful login, take them to a mobile landing page. From there, I will have links to the rest of the mobile site, as well as some links to the ‘standard’ view of the app as well.

Custom Authentication with the Grails Spring Security Plugin. @burtbeckwith did a great job making Spring Security easily customizable and cake to work with in Grails via the Spring Security Core Plugin.

Custom Authentication with the Grails Spring Security Plugin

However, authentication requirements can emerge that don’t fit any of its current implementations, so it’s nice to know what’s going on under the hood so you can plug in your own. The Smart Notes Application To demonstrate custom authentication with the plugin, I’ll build an incredibly simple note-taking application for a scientist and all his friends, called “Smart Notes”. The reason this needs to be custom made – He doesn’t care who accesses this application, as long as they are smart enough.

Instead of managing usernames/passwords for everyone, he just wants to prompt the user with a very hard math problem, and if they get it right they’re in. I’ll show snippets of some of the code, but the whole project is out on my github for following along. - NOTICE: For the sake of time, I wrote minimum viable code to get this application working. Making Grails Apps Native in a Microsoft Environment « Glen Smith. Posted by Glen on Mar 7, 2012 in Grails, Groovy | 3 comments It’s a little-known fact that I’m a part-owner of one of the most uncool Grails startups in the known world.

We don’t have Webscale issues, we don’t have staff beanbags, in fact we don’t even offer a cloud-based solution. We install Grails-based software on hosts inside corporate environments. We do compliance software. Like Health and Safety and IT Security stuff. Lots of our customers are “Microsoft Shops” from soup to nuts – SQL Server, Active Directory, Internet Explorer – you know the drill. Groovy & Grails eXchange 2012: Robert Fletch. Pessimistic Locking With Grails. By default grails uses optimisic locking with versioning.

In a nutshell this means that each of your domain objects is blessed with a version field and hibernate throws an exception if you ever try to update or lock an object with an old version number. For scenarios where you are happy to handle the exception, or just report the error to the user via a UI this is fine, however when this behaviour isn't ok you need to switch to pessimistic locking. This is where the fun begins. Groovy & Grails eXchange 2012: Stuart Willia. Caelyf 0.1, a lightweight Groovy toolkit for Cloud Foundry. I'm very happy to announce the release of Caelyf 0.1, a lightweight Groovy toolkit for Cloud Foundry. Caelyf is inspired by the Gaelyk project, and actually borrows most of its code base. Its goal is to let you write apps using Groovy scripts and templates, and then deploy them on the Cloud Foundry platform.

Caelyf is Open Source, released under the Apache 2 license. Which means you will also be able to use the issue tracker from GitHub to file bugs or feature requests. And of course, if you want to contribute to the project, you're just one pull request away! We're using Google groups for interacting with our upcoming users. Caelyf is obviously very young (ie. that's its first release), so it might be rough around the edges, and I'd appreciate if you provide me with some feedback as you delve into the project and deploy your first applications.

Closure Caching For Increased Performance (.memoize()) « Intelligrape Groovy. Download Sources for SpringSource Tool Suite and Grails 1.3.7 at ClickOnChris. Videos and slides of Groovy / Grails eXchange 2011. Speed up your Grails / Spring Security Development with an Auto Login Bookmarklet - Ted Naleid. When you’re doing dev on your website, how often do you log in with the same username and password?

I bet it’s 20+ of times a day when you’re actively developing. Having to log in manually impedes development speed. DRYer Grails views? Learn less.css, backbone.js, twitter bootstrap and more @ 2GX « Glen Smith. Hibernate & postgreSQL with Grails. Grails & Hudson / Jenkins Part 6: Sonar. Sonar is an open source code quality management tool – this requested addition to the Grails & Hudson / Jenkins series gives a quick run through of how to set up Sonar to analyse Grails code from a Jenkins job.

Sonar Download the latest version of Sonar (currently 2.9) from The installation instructions are here, but for speed of evaluation you can just unpack the zip. Before we start up Sonar, we’ll need to install the Groovy support. Sonar Groovy Plugin Download the latest version of the jar (currently 0.3) and copy this to $SONAR_HOME/extensions/plugins. Groovy: Few ways to convert string into enum « Intelligrape Groovy. GORM Gotchas (Part 2) In part 1 of this series, I introduced you to some of the subtleties associated with persisting domain instances with GORM. This time, I'm going to tackle relationships with particular focus on hasMany and belongsTo.

GORM provides only a few basic elements for defining relationships between domain classes, but they are sufficient to describe most needs. When I give training courses on Grails, it always surprises me how few slides cover relationships. As you can imagine, this apparent simplicity does hide some subtle behaviour that can trip up the unwary. Bobby Warner » Getting Started With Grails. User - Pagination with HQL.

[#GRAILS-2672] Return PagedResultList in case list* methods are provided with max and offset param - Grails JIRA. Directories. Debugging DSLD Scripts. Not too long ago, I introduced DSL descriptors (DSLDs) for Groovy-Eclipse. DSLDs are Groovy scripts that provide rich editing support (content assist, navigation, etc.) for Groovy projects in your Eclipse workspace. User - Best practice/tips and tricks for deployment of Grails app on Tomcat 6? Werkzeug debugger for grails. MongoDB with Spring Data project. All of us are observing the explosion of NoSql solutions these days.

Groovy DSL - A Simple Example. Domain Specific Languages (DSLs) have become a valuable part of the Groovy idiom. DSLs are used in native Groovy builders, Grails and GORM, and testing frameworks. To a developer, DSLs are consumable and understandable, which makes implementation more fluid as compared to traditional programming. Better DSL support in Groovy-Eclipse. Grails and Artifactory Online Collaboration - Community Wins! Rapport sur LA conférence Groovy européenne : la GR8Conf.

Grails custom XML Marshaller « J-Wicz Blog. Using Grails links from JavaScript: a micropattern « Glen Smith. Displaying Hibernate statistics in a Grails app.