Issue Details (XML | Word | Printable)

Key: GRAILS-4448
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Critical Critical
Assignee: Graeme Rocher
Reporter: Robert Fletcher
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Grails

Dynamic finders created by mockDomain are not torn down properly

Created: 18/Apr/09 07:00 AM   Updated: 01/May/09 11:44 AM   Resolved: 01/May/09 11:44 AM
Return to search
Component/s: Testing
Affects Version/s: 1.1
Fix Version/s: 1.1.1

Time Tracking:
Not Specified

File Attachments: 1. GZip Archive weirdness.tar.gz (129 kB)

Environment: Ubuntu Linux 8.10 / OSX Leopard, Java 6, Grails 1.1

Testcase included: yes


 Description  « Hide

Dynamic finders created by mockDomain in a unit test are sometimes still getting invoked somehow in subsequent tests even though they should have been removed in the tearDown phase of the relevant test. This can even go as far as bleeding over into integration tests if run together with the unit tests, even though integration tests should have 'real' dynamic finders in place.

I've attached an example app showing the behaviour in a single unit test case. It shows the dynamic finder being used correctly by the class under test, then not working (as expected) when called directly from a subsequent test, then mysteriously still working when called by a new instance of the class under test in a third test despite mockDomain only having been used in the first test.



Robert Fletcher added a comment - 18/Apr/09 07:02 AM

May be related to http://jira.codehaus.org/browse/GRAILS-4271 although the specifics of the effect are a little different.


Robert Fletcher added a comment - 18/Apr/09 07:11 AM

I should mention this specifically seems to be a problem with mockDomain using methodMissing to implement the finders (not that I think that's theoretically the wrong approach, but it seems to be the root of the problem). If I stop using mockDomain and instead implement a finder directly (Thing.metaClass.static.findByName = { x } for example) the tear down works correctly (assuming I've used registerMetaClass(Thing) obviously), however if I try to implement a simplified version of what mockDomain does (e.g. Thing.metaClass.static.methodMissing = {name, args -> x }) the same problem occurs.


Burt Beckwith added a comment - 18/Apr/09 09:46 AM

This is related to callsite caching. Graeme reported this bug http://jira.codehaus.org/browse/GROOVY-3433 and using the Groovy 1.6.1 jar fixes this problem too. Note that because of hard-coded jar names, you need to rename groovy-all-1.6.1.jar to groovy-all-1.6.0.jar in $GRAILS_HOME/lib