How can i resolve a scenario in ejb unittest where in service bean there is a persist for an object and later i need to get the persisted object back? The issue is ejb unit test does not really persist the object in the database where when it comes to get back the persisted object from the service class there is no such object persisted know?
Harshana,
Is this a unit test (mock objects) or an integration test (database) ? For the former, you mock out what you expect to be returned. For the later, why wouldn't the object be there later?
Jeanne Boyarsky wrote:Harshana,
Is this a unit test (mock objects) or an integration test (database) ? For the former, you mock out what you expect to be returned. For the later, why wouldn't the object be there later?
Its the Unit test (using eclipse)..well the methods returns a Dto with full of data..im assert that object(dto) not null(i guess that is what mock out means right?)
But the problem is inside the service class method body their is a scenario where it persist the object and after few lines it takes back the object.
So with Ejb unit test persist object doesn't really persist in the database.(may be its save somewhere until the time of unit test ).
But the problem arise when the method reach to the line where it retrieve the object back..where the test case fails saying no such entity found for query.
In the ejb unit framework looks for real database persist objects which are in the database when we retrieve the object (using a select query). you got the problem Jeanne?
She's saying you mock it, like with MockEJB or something.
Harshana Dias
Ranch Hand
Joined: Jun 11, 2007
Posts: 325
posted
0
David Newton wrote:She's saying you mock it, like with MockEJB or something.
No. I am uning Ejb3Unit. I extend the BaseSessionBeanFixture which is the base class for all JUnit test - testing stateless/statefull SessionBeans in my test class.
No. I'm saying that I think you have a hybrid. You have the unit part where you expect the database will not be updated and the integration part where you expect the data to be in the database.