View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3821861#3821861
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3821861 After switching from JBoss 3.2.1 to 3.2.3, a jUnit test for equivalence between two stateless session beans is now failing. (Code at bottom!) Previously, under 3.2.1, this assertion test passed: assertEqual("catalog same", catalog, newCatalog); // TRUE as do these: assertTrue("catalog same", newCatalog.equals(catalog)); // TRUE assertTrue("catalog same", newCatalog.isIdentical(catalog)); // TRUE But under 3.2.3 (& 3.2.2) none of the following evaluate to true (...unless we change the session beans to stateful): assertEqual("catalog same", catalog, newCatalog); assertTrue("catalog same", newCatalog.equals(catalog)); assertTrue("catalog same", newCatalog.isIdentical(catalog)); After brushing up on EJB equivalence rules, I can understand why 'equals()' fails (although, I'm now uncertain why it works under 3.2.1) , but as far as I can tell, these two stateless beans should be Identical. Code snippits: The Action Class public class EventListAction extends ProtectedAction { LocalEventCatalog eventCatalog; /** Initializes the servlet. */ public LocalEventCatalog getCatalog() { if ( eventCatalog == null ) { try { Context ctx = new InitialContext(); LocalEventCatalogHome home = (LocalEventCatalogHome)ctx.lookup("java:comp/env/EventCatalog"); eventCatalog = home.create(); } catch ( NamingException ne ) { throw new ServletException( "naming exception looking up LocalEventCatalogHome", ne ); } catch ( CreateException ce ) { throw new ServletException( "create exception creating LocalEventCatalog", ce ); } } return eventCatalog; } ... The Test Class public class TestEventListAction extends ServletTestCase { ... public void testGetCatalog() { EventListAction action = new EventListAction(); LocalEventCatalog catalog = action.getCatalog(); assertNotNull( "catalog not null", catalog ); LocalEventCatalog newCat = action.getCatalog(); assertNotNull( "new cat not null", newCat ); assertEquals( "catalog same", catalog, newCat ); // FAILS! assertTrue( "catalog same", newCat.equals(catalog)); // FAILS! assertEquals( "catalog same", newCat.isIdentical(catalog)); // FAILS! } ... We've alse tried (for testing purposes) pre-creating the Bean in the Action, along with a simplified getCatalog() method to return it: public LocalEventCatalog getCatalog() { return this.eventCatalog; } and then changing the Test Class to make successive calls to the Action: LocalEventCatalog catalog = action.getCatalog(); LocalEventCatalog newCat = action.getCatalog(); But even this evaluates to FALSE equality in all three cases. Only when we change the Bean to "stateful" do they all evaluate to TRUE, under JBoss 3.2.2+ And this appears to be at direct odds with the EJB spec, for the case of stateless beans. Are we missing something here? -Logan ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user