The next example illustrates the different options to map an enum. Given the next code: For enumType `ordinal` The enum will be mapped in the database as: ID VERSION NAME STATUS 1 0 Grails 3 – Step by Step 0 2 0 Grails 3 – A practical guide to application development 1 3 0 Falando […]
Add a new Maven Url entry to your dependencies block:
Do you know you can run a Grails generated WAR with `gradle assemble` with `java -jar`?. Let me show you:
Grails documentation talks about Understanding Plugin Load Order and controlling it with the use of loadBefore and loadAfter properties. It is easy to debug the plugin load order as well. Add this line to your grails-app/conf/logback.groovy file. logger(‘grails.plugins.DefaultGrailsPluginManager’, INFO, [‘STDOUT’], false)
Thanks to Spock IgnoreIf annotation it is easy to ignore a specification running in Travis CI.
This blog post is a translation of @daniel_sun‘s post, originally posted in Chinesse. The next section will focus on the new parser “Parrot” features coming to Groovy 3. If you wish to be able to get yourself back and forth, follow the steps below to start Groovy 3’s groovy console to try these new features: […]
The European Commision offers a web application to validate a VAT Number
Yesterday I joined OCI Grails team. I am thrilled!. What better place to continue developing my Grails career. But let me reflect how I got here. 6th of July, 2011. This was the first time I heard about Grails. I was organizing a local meetup called Iniciador Guadalajara. We had the pleasure to be joined […]
Lets say you have a class which depends on another component. The component ( for example a remote call ) sometimes fails. You want to execute a method with a number of retries. Groovy supports parameters with default values and we are going to leverage that capability and recursion to achieve a retry functionality. I […]
Yesterday I talked at Madrid Groovy User Groovy about scraping with Geb. Thanks for everyone who attended.
This post explains how to open a Grails 3 App with IntelliJ as described in the Grails 3 IntelliJ Quickcast by Jeff Scott Brown First, force IntelliJ to run Grails tests in the test environment.
This post explains how to debug a Grails 3 App with IntelliJ as described in the Grails 3 IntelliJ Quickcast by Jeff Scott Brown Checkout IntelliJ IDEA Debug documentation. Remote Debugger Alternatively, you can run your app with –debug-jvm flag and then attach a remote debugger to it. In order to attach IntelliJ as a […]
This post explains how to run a Grails 3 App with IntelliJ as described in the Grails 3 IntelliJ Quickcast by Jeff Scott Brown Using Application.groovy It is easy to run a Grails 3 App directly from IntelliJ. Execute the main method in Application.groovy. Just click the green arrow. Please, make sure you turn off […]
This post explains how to open a Grails 3 App with IntelliJ as described in the Grails 3 IntelliJ Quickcast by Jeff Scott Brown Lets assume you already have a folder which contains a Grails 3 app. For example you cloned a Grails 3 project from a git repository or you created an app from […]
Lets say we visit the Codemotion agenda; an upcoming Conference in Spain. We can check whether the website stores any cookies. As shown below it does: Let say we want to access those cookies with Geb. Web Driver to the rescue. Geb builds on the WebDriver browser automation library, which means that Geb can work […]
Getting started Swift types Int Integer, whole number that does not containing any floating point information. Float 32bit number with floating point information Double 64bit number with floating point information Bool true or false String represents text Character Single unicode character There are more types but those are the most common in Swift. Type Naming […]
Add Groovy dependency to build.gradle Add Gradle wrapper add Geb, Selenium, Drivers and Spock depependencies to build.gradle Create a test src/test/groovy/gebwebbot/greach/LegalSpec.groovy We are going to create a Geb.Config file to leverage Geb environment sensitivity. vi src/test/resources/GebConfig.groovy Pass Java system properties from the command-line to the gradle test task. In order to do that modify our […]
Groovy is a great language for scripting. As a JVM language, it allows us to use many Java libraries already available. In this project we are going to start and stop a EC2 instance from a Spock test. Lets create a Gradle project with the Groovy plugin. Add Spock dependencies and AWS Java SDK. Lets […]
Geb manual: Geb builds on the WebDriver browser automation library, which means that Geb can work with any browser that WebDriver can. With WebDriver is easy to obtain the page source. Lets do a test to verify it. Lets start by creating a Gradle project with Groovy Add Groovy dependency to build.gradle Add Gradle wrapper […]
I am fan of restricting my Grails 3 Controller’s actions to certain HTTP methods. If an action does not modify the database let use GET, if an action inserts a new row in the database lets use POST, if an action deletes a row form the database lets use DELETE and so on. With Grails […]
Create a grails app with the rest profile: Create a controller grails-app/controllers/lognongrailsartifact/TestController.groovy Create a Groovy Class src/main/groovy/lognongrailsartifact/NonGrailsArtifact.groovy; not a grails artifact. Note: Grails artefacts get log auto-injected. You will need to inject it manually in this class. Edit grails-app/conf/logback.groovy Run the app Invoke the controller And you will see the log statement: Soeren Glasius pointed […]
Create an app with the default web profile. Enter the grails console Create a domain class Add a couple of properties to the domain class In grails-app/init/BootStrap.groovy add a couple of domain class instances. The BootStrap init closure runs when the app starts. Create a controller This is the controller content: Several things about the […]
Craig Atkinson‘s talk at GR8Conf US Intro to Spock and Geb claimed the next about Spock Cleanup / Inheritance. Might have a hierarchy of test classes for DRY common test code Spock runs the base class setup first Then goes down the inheritance chain cleanup is the reverse, starting at test class then going up […]
Lets say we have an HTML page with content hidden until we place the mouse over it. It will look like this: And this is the html If I try to fetch the content with Geb, it will fail because it is hidden. Next test fails. We have several alternatives: A. Call a JS method […]
As often happens on the internet there is already a website to answer your question. If you would like to know what’s your user agent just visit whatsmyuseragent.com If you run Geb with PhantomJs your user agent will identify you as running PhantomJs. You may be blocked because of that. Fortunately it is easy to […]
Lately, I am coding a lot Webbots. Sometimes you need to split the load between different machines. Actual physical machines. Lets same you you have 6 machines at your disposal. Also, lets assume you know the total size of the elements which you want to process in parallel. For this example lets say 50 items […]
If you are developing your Geb programms with Firefox or Chrome driver, they will probably be running in a traditional desktop resolution. You may be puzzled when your tests fail in PhantomJS driver. Why? After further investigation you will probably realise that the tests are failing because the code you developed will only work when […]
I originally saw this tip in an Andrés Almiray‘s talk. There is a Gradle forum thread where it is discussed too. Sometimes you want to run your program in a machine with Java 1.6. How to ensure source and target compatibility in a build.gradle file:
El pasado martes 14 de Junio tuve la suerte de dar una charla en Madrid GUG. El grupo de usuario de Madrid de Groovy. Probablemente uno de los grupos de usuarios de Groovy en el mundo con mayor afluencia del mundo. Se lo trabajan mucho sus organizadores. No éramos muchos en la charla pero de […]
It is easy to ignore a test only if the test is run in a particular environment thanks to the @IgnoreIf Spock annotation. If you run your tests in Jenkins, it is probable that the tests are being run by a user called jenkins. Thus, you can ignore a test in a Jenkins Job easily: […]
The folks from GR8Day Warsaw have been so kind to post the video of my talk You can checkout the slides here.
The next example shows how to use a Trait to output a CSV string for any Class which implements the trait The next Spock test will pass: This Trait can be used for any class which you wish to output as a comma separated value. Useful to export information to be sued in Excel or […]
Las siguientes capturas de pantalla muestra como importar un archivo CSV en Excel 2010. CSV es el acrónimo en inglés de Comma Separated Value. En español se suele utilizar el termino archivo separado por comas. 1. El primer paso es descargar el archivo CSV en un directorio fácilmente localizable de nuestro ordenador. 2. Ejecutar Excel […]
Do you like to read about Groovy/Grails development? Yes, then Subscribe to Groovy Calamari a weekly curated email newsletter about the Groovy ecosystem which I write
This post is a transcript of this video: How Synctatic Sugar helps simplify common tasks in Grails Programming? | Grails Conf 2015 from TO THE NEW Digital on Vimeo. Passing false to sort will not modify the original list and return a new sorted list instead. This is the result: We can base a closure […]
If you are trying to hit a non HTTPS server from your iOS app you will get this error: You can add a settings to your project plist file to remove this security check.
Sometimes you need to configure the exact server url (via domain name or ip address) of your Grails app. It is easy do it with a small configuration in your grails-app/conf/application.yml Do you like to read about Groovy/Grails development? Yes, then Subscribe to Groovy Calamari a weekly curated email newsletter about the Groovy ecosystem which I write
The default welcome screen is shown: Add a message code at the bottom of grails-app/i18n/messages.properties Add a message code at the bottom of the Spanish properties file: grails-app/i18n/messages_es.properties Edit the file grails-app/views/index.gsp. Replace the line: with: If you start the app now, you will still the same html as before. Edit the file grails-app/conf/spring/resources.groovy and […]
Updated to 3.2.8 Back in February I wrote a post about multi-project build. Since then, Graeme Rocher did a great Quickcast where he explains it much better. Because of that I have reviewed this post to include all the points covered in the video. Feel free to view the video or follow the post. Creating […]
This post continues with the code generated in the post: how to use a Trait to encapsulate Spring Security core functionality in a Grails 3 app First lets add the dependency to the Spring Security REST for Grails plugin to build.gradle Run the app grails run-app and you will be able to login and get […]
Add one dependency to your build.gradle as shown below to install Spring Security Core Plugin Lets create the security-related domain classes: Add a default user to grails-app/init/BootStrap.groovy Create a Controller which will return the name of the logged user: The controller code could be something like this: If we start the app and hit the […]
By default a Grails 3 app will start in the port 8080. It is easy however to configure a different port. Edit grails-app/conf/application.yml and add the next snippet at the bottom of the file. Next time you run the app, it will listen in the port 8090.
For this post I will continue reusing the code I created in the How to use Spring Security Core to Secure your Grails 3 app post In this post we are going to expose our app product announcements as JSON API and secure it with Spring Security REST for Grails plugin. Lets create a service […]
Spring Security Core plugin is probably the most famous security plugin in the Grails ecosystem. Lets create a simple app to publish product announcements: I create a domain class to store the product announcements. I add a message field to store the announcement and a dateCreated field to use Grails autoTimestamp capabilities. Add some ProductAnnouncement […]
I add a message field to my domain class since I need to announce stuff. Add some ProductAnnouncement messages when the application starts. To do that modify grails-app/init/BootStrap.groovy Now If I start the app, I don’t see any SQL output. I guess the .save() call did an insert but I have no visibility. How can […]