Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4341534
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:29:53+00:00 2026-05-21T11:29:53+00:00

I’m learning grails from the book Grails In Action and I’m trying to run

  • 0

I’m learning grails from the book “Grails In Action” and I’m trying to run integration tests from the examples. In the book it says that each integration test function should roll back its operations as each test finishes. It is NOT rolling back each transaction (as when I finish the database is dirty). I tried to find out why and found found a property called “transactional”. Allegedly you set this property to true and it will make the test case transactional, but it doesn’t appear to change the behavior. I have included the code for the unit tests below.

I’m using grails 1.3.7 and connecting to a MySql database. The tests run successfully, it just doesn’t rollback. Am I doing something wrong in this integration test that it skips the rollback?

UserIntegrationTests.groovy:

package com.grailsinaction

import framework.TestTools

class UserIntegrationTests extends GroovyTestCase {
    static transactional = true

    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testCreateUser() {
        TestTools.banner(log, "testCreateUser()")

        def user = new User(userId:"joe", password:"secret")
        assertNotNull user.save()
        assertNotNull user.id

        def foundUser = User.get(user.id)
        assertEquals 'joe', foundUser.userId
    }

    void testSaveAndUpdate() {
        TestTools.banner(log, "testSaveAndUpdate()")

        def user = new User(userId:"joe2", password:"secret")
        assertNotNull user.save()

        def foundUser = User.get(user.id)
        foundUser.password = 'sesame'
        foundUser.save()

        def editedUser = User.get(user.id)
        assertEquals 'sesame', editedUser.password
    }

    void testSaveThenDelete() {
        TestTools.banner(log, "testSaveThenDelete()")

        def user = new User(userId: 'joe3', password: 'secret')
        assertNotNull user.save()

        def foundUser = User.get(user.id)
        foundUser.delete()
        assertFalse User.exists(foundUser.id)
    }

    void testValidation() {
        TestTools.banner(log, "testValidation()")

        def user = new User(userId: 'chuck-norris', password: 'tiny')
        assertFalse user.validate()
        assertTrue user.hasErrors()

        def errors = user.errors
        assertNotNull errors

        errors.allErrors.each {
            log.info("field: ${it.field}, code=${it.code}, rejected=${it.rejectedValue}")
        }
    }
}

User.groovy

package com.grailsinaction

class User {
    String userId
    String password
    Date dateCreated
    Profile profile

    static constraints = {
        userId(size: 3..20, unique: true)
        password(size: 6..8, validator: {password, user ->
            return (password != user.userId)
        })
        dateCreated()
        profile(nullable: true)
    }

    static mapping = {
        profile lazy: false
    }

    static hasMany = [posts : Post]
}

Test Execution Log

Testing started at 8:28 PM ...
Welcome to Grails 1.3.7 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: C:\Users\jmquigley\workspace\apps\Grails\grails-1.3.7
Base Directory: C:\Users\jmquigley\workspace\samples\lang-grails\hubbub
Resolving dependencies...
Dependencies resolved in 963ms.
Running script C:\Users\jmquigley\workspace\apps\Grails\grails-1.3.7\scripts\TestApp.groovy
Environment set to test
  [groovyc] Compiling 1 source file to C:\Users\jmquigley\workspace\samples\lang-grails\hubbub\target\classes
    [mkdir] Created dir: C:\Users\jmquigley\workspace\samples\lang-grails\hubbub\target\test-reports\html
    [mkdir] Created dir: C:\Users\jmquigley\workspace\samples\lang-grails\hubbub\target\test-reports\plain
Starting integration test phase ...
  [groovyc] Compiling 1 source file to C:\Users\jmquigley\workspace\samples\lang-grails\hubbub\target\classes
  [groovyc] Compiling 1 source file to C:\Users\jmquigley\workspace\samples\lang-grails\hubbub\target\classes
[INFO ]20110417@20:28:42,959:grails.spring.BeanBuilder: [RuntimeConfiguration] Configuring data source for environment: TEST
  [groovyc] Compiling 1 source file to C:\Users\jmquigley\workspace\samples\lang-grails\hubbub\target\test-classes\integration
-------------------------------------------------------
Running 4 integration tests...
Running test com.grailsinaction.UserIntegrationTests...
--Output from testCreateUser--
[INFO ]20110417@20:28:46,897:groovy.util.GroovyTestCase: Test Case: testCreateUser()
--Output from testSaveAndUpdate--
[INFO ]20110417@20:28:47,534:groovy.util.GroovyTestCase: Test Case: testSaveAndUpdate()
--Output from testSaveThenDelete--
[INFO ]20110417@20:28:47,568:groovy.util.GroovyTestCase: Test Case: testSaveThenDelete()
--Output from testValidation--
[INFO ]20110417@20:28:47,642:groovy.util.GroovyTestCase: Test Case: testValidation()
[INFO ]20110417@20:28:47,668:groovy.util.GroovyTestCase: field: password, code=size.toosmall, rejected=tiny
null
PASSED
Tests Completed in 1173ms ...
-------------------------------------------------------
Tests passed: 4
Tests failed: 0
-------------------------------------------------------
[junitreport] Processing C:\Users\jmquigley\workspace\samples\lang-grails\hubbub\target\test-reports\TESTS-TestSuites.xml to C:\Users\JMQUIG~1\AppData\Local\Temp\null90011239
[junitreport] Loading stylesheet C:\Users\jmquigley\workspace\apps\Grails\grails-1.3.7\lib\junit-frames.xsl
[junitreport] Transform time: 415ms
[junitreport] Deleting: C:\Users\JMQUIG~1\AppData\Local\Temp\null90011239
Tests PASSED - view reports in target\test-reports
Application context shutting down...
Application context shutdown.

Process finished with exit code 0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:29:53+00:00Added an answer on May 21, 2026 at 11:29 am

    Tests (and services) are transactional by default so you only typically specify the static transactional property when it’s false. If you haven’t specified the Dialect it’s probably auto-detecting MySQL but then the tables are created using the default engine which is probably MyISAM. MyISAM tables which are not transactional. Be sure to specify the InnoDB dialect whenever you use MySQL, e.g.

    test {
       dataSource {
          dialect= org.hibernate.dialect.MySQLInnoDBDialect
          driverClassName = 'com.mysql.jdbc.Driver'
          username = '...'
          password = '...'
          url = '...'
          dbCreate = 'update'
       }
    }
    

    or if you’re using MySQL for all environments, you can move it to the top-level, e.g.

    dataSource {
       pooled = true
       dialect = org.hibernate.dialect.MySQLInnoDBDialect
       driverClassName = 'com.mysql.jdbc.Driver'
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.