Grails

NPE when attempting to create a GrailsMock

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.1.1
  • Fix Version/s: 1.2.1, 1.3-M1
  • Component/s: Testing
  • Labels:
    None

Description

java.lang.NullPointerException
at grails.test.GrailsMock$_createMock_closure1.doCall(GrailsMock.groovy:94)
at EventGroupsAPIController$_closure2.doCall(EventGroupsAPIController.groovy:30)
at EventGroupsAPIController$_closure2.doCall(EventGroupsAPIController.groovy)
at EventGroupsAPIControllerTests.testFireTest(EventGroupsAPIControllerTests.groovy:71)
at _GrailsTest_groovy$_run_closure4.doCall(_GrailsTest_groovy:203)
at _GrailsTest_groovy$_run_closure4.call(_GrailsTest_groovy)
at _GrailsTest_groovy$_run_closure2.doCall(_GrailsTest_groovy:147)
at _GrailsTest_groovy$_run_closure1_closure19.doCall(_GrailsTest_groovy:113)
at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:96)
at TestApp$_run_closure1.doCall(TestApp.groovy:66)
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:344)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:334)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.processTargets(Gant.groovy:495)
at gant.Gant.processTargets(Gant.groovy:480)

Activity

Hide
JR Boyens added a comment -

Looks like the mock is also being called with a [org.codehaus.groovy.runtime.wrappers.PojoWrapper@1ec1ee3e] and no args.

Show
JR Boyens added a comment - Looks like the mock is also being called with a [org.codehaus.groovy.runtime.wrappers.PojoWrapper@1ec1ee3e] and no args.
Hide
Graeme Rocher added a comment -

Attach an example that reproduces the problem

Show
Graeme Rocher added a comment - Attach an example that reproduces the problem
Hide
Martin Schonaker added a comment -

I got this exception in 1.2. Here's a minimum version of the unit test I was executing:

void testSomething() {

def messageSourceControl = mockFor(org.springframework.context.MessageSource)
def messageSource = messageSourceControl.createMock();

messageSourceControl.demand.getMessage(0..1) { String code, Object[] args, Locale locale -> assertNotNull code assertNotNull args assertNotNull locale }

messageSource.getMessage("somesString", [] as Object[], new Locale('en'))

messageSourceControl.verify()
}

Regards.

Show
Martin Schonaker added a comment - I got this exception in 1.2. Here's a minimum version of the unit test I was executing: void testSomething() { def messageSourceControl = mockFor(org.springframework.context.MessageSource) def messageSource = messageSourceControl.createMock(); messageSourceControl.demand.getMessage(0..1) { String code, Object[] args, Locale locale -> assertNotNull code assertNotNull args assertNotNull locale } messageSource.getMessage("somesString", [] as Object[], new Locale('en')) messageSourceControl.verify() } Regards.

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: