« Return to Thread: JMock noob with jmock DAO woes

Re: JMock noob with jmock DAO woes

by David Brown-48 :: Rate this Message:

Reply to Author | View in Thread

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


 « Return to Thread: JMock noob with jmock DAO woes