Reputation: 2332
I'm currently programming against a junit test (school assignment)
The Task is to create a stateful session bean which handles job assignments
The submitAssignments method should discard the session bean so that the junit test works
jobManagementBean.submitAssignments();
// check if the bean was discarded after submitAssignments() was
// called successfully!
try {
jobManagementBean.getCache();
fail(NoSuchEJBException.class.getName() + " expected!");
} catch (NoSuchEJBException e) {
// Expected
}
How can I discard the bean?
Upvotes: 1
Views: 520
Reputation: 11602
You can apply @Remove
annotation over a method in the stateful bean, the container will remove the bean after the completion of that method.
Annotation Type Remove : Applied to a business method of a stateful session bean class. Indicates that the stateful session bean is to be removed by the container after completion of the method.
Upvotes: 5