How can i resolve a scenario in ejbunit test 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?
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?