Hello Nat, thanks for the speedy and informative reply. That worked. I found in the JMock 1 doco:
http://www.jmock.org/jmock1-dispatch.html the foundation for your answer. I'm not sure I would have fixed this myself even with the doco find. I have yet another API to learn (YAATL). Thanks much, David.
----- Original Message -----
From: "Nat Pryce" <
nat.pryce@...>
To:
user@...
Sent: Friday, June 19, 2009 1:37:05 AM GMT -06:00 US/Canada Central
Subject: Re: [jmock-user] JMock noob with jmock DAO woes
I think you need to specify an int value to be returned from
deleteByPrimaryKey. Something like:
mockDao.expects(once()).method("deleteByPrimaryKey").with(eq(new Long(1)))
.will(returnValue(1)); // or whatever the appropriate value is.
--Nat
2009/6/18 David Brown <
dbrown@...>:
> Hello Steve thanks for the speedy reply. The Expectations block and the whole JMock setup is more like the JMock 1 doco example:
>
> mockDao = new Mock(BullmasterDAO.class);
> bmgr.setBullmasterManagerDAO((BullmasterDAO) mockDao.proxy()); // bmgr: instance of bullmastermanager class
>
> ***** failing part ******
> mockDao.expects(once()).method("deleteByPrimaryKey").with(eq(new Long(1)));
> bmgr.deleteByPrimaryKey((long)1);
> mockDao.verify(); // never gets here or not needed because of testcase error (not failure)
>
>
>
>
> ----- Original Message -----
> From: "Steve Freeman" <
steve@...>
> To:
user@...
> Sent: Thursday, June 18, 2009 1:41:16 AM GMT -06:00 US/Canada Central
> Subject: Re: [jmock-user] JMock noob with jmock DAO woes
>
> Not quite sure what's going on here, but don't panic.
>
>> org.jmock.core.DynamicMockError: mockBullmasterDAO: tried to return
>> null value from method returning int
>> Invoked: mockBullmasterDAO.deleteByPrimaryKey(<1L>)
>
>
> what this says is that you're calling a method deleteByPrimaryKey()
> that should return an int, but that it's been set up to return a null.
>
> In the expectations block, is there a line that looks like:
>
> context.checking(new Expectations() {{
> one(mockBullmasterDAO).deleteByPrimaryKey(1);
> }};
>
>
> S
>
> Steve Freeman
> Winner of the Agile Alliance Gordon Pask award 2006
>
>
http://www.m3p.co.uk>
> M3P Limited.
> Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ.
> Company registered in England & Wales. Number 03689627
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>
http://xircles.codehaus.org/manage_email>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>
http://xircles.codehaus.org/manage_email>
>
>
--
http://www.natpryce.com---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email