import spock.lang.Specification
import grails.testing.web.controllers.ControllerUnitTest
class HelloControllerTests extends Specification implements ControllerUnitTest<HelloController> {
void "Test message action"() {
when:"The message action is invoked"
controller.message()
then:"Hello is returned"
response.text == 'Hello'
}
}
1.1 What's new in Grails 3.3?
Version: 3.3.2
Table of Contents
1.1 What's new in Grails 3.3?
This section covers all the new features introduced in Grails 3.3.
1.1.1 GORM 6.1
Grails 3.3 comes with GORM 6.1, which includes the following new features:
-
Multi-Tenancy AST Transforms
-
Rewritten
@Transactional
and@Rollback
transformations -
Common Services like
TenantService
andTransactionService
-
Data Services Concept - Implement interfaces automatically!
-
Bean Validation API Support
-
JPA Annotation Support
-
Package Scanning and Easy Unit Testing
-
Neo4j Bolt 1.2 Driver Support
-
MongoDB 3.4 Driver Support
There are so many new features and novelties in GORM that we had to write its own independent What’s New Guide!
1.1.2 New Events API
The Grails Async Framework has been extracted from Grails and moved to a separate project.
This allows the Async support to evolve independent of the framework itself in a fast moving and evolving area.
In order to support multiple different asynchronous and reactive frameworks Grails 3.3 has been decoupled from Reactor 2.x and an abstract EventBus
notation added.
The EventBus interface provides the foundation and multiple implementations including GPars and RxJava.
A new set of annotations usable in services classes and regular Spring beans can be leveraged to publish and consume events:
-
Publisher - A transformation that transforms a method ensuring the return value is published as an event
-
Subscriber - A transformation that transforms a method to listen for an event.
For more information see the new documentation.
1.1.3 New Testing Framework
Grails 3.3 includes a new Trait-based testing framework that replaces the existing @TestMixin
based framework with a simpler implementation that is easier to debug, provides better code completion and is easier to extend.
An example hello world test can be seen below:
1.1.4 JSON Views 1.2
Version 1.2 of the JSON Views plugin is included with Grails 3.3’s "rest-api" profile and includes a number of new features. Below are some of the highlights:
-
Support for the JSON API specification
-
Ability to register custom converters
-
Multiple configuration options for date formatting, unicode escaping, etc
1.1.5 Updated Dependencies
Grails 3.3 ships with the following dependency upgrades:
-
Hibernate 5.1.5 (now the default version of Hibernate for new applications)
-
Spring Framework 4.3.9
-
Spring Boot 1.5.4
-
Gradle 3.5 (Grails 3.3 is also compatible with Gradle 4.x)
-
Spock 1.1
1.1.6 Other Novelties
Cache Plugin Rewritten
The Cache Plugin has been rewritten and no longer use proxies which improves startup time and performance. The plugin is also now Multi-Tenant aware, ensuring that cached data is not seen by other tenants.
Converters plugin now Separate
With JSON Views now being the recommended way to render JSON. The converters plugin has been split out from core into a separate project.