CtsBmp anotherBean = null;
CtsBmp differentBean = null;
try {
CtsBmpHome home = getHome();
AccountPK pk = new AccountPK(BEAN_PK_007);
getLog().debug("Create a bean...");
bean = doEjbCreate(pk, BEAN_NAME);
getLog().debug("OK");
getLog().debug("Now query based on the 'PersonsName': " +
BEAN_NAME + "...");
Collection clct = home.findByPersonsName(BEAN_NAME);
getLog().debug("OK");
getLog().debug("Verify result set not empty...");
assertTrue(!clct.isEmpty());
getLog().debug("OK");
getLog().debug("Bean result set:");
for (Iterator itr=clct.iterator(); itr.hasNext();)
{
anotherBean = (CtsBmp)itr.next();
getLog().debug("Use 'isIdentical()' to compare beans");
assertTrue(anotherBean.isIdentical(bean));
getLog().debug( "beans match..OK" );
}
getLog().debug("Make a bean that doesn't match..");
AccountPK anotherPK = new AccountPK("123");
differentBean = doEjbCreate(anotherPK, "SomeOtherGuy");
getLog().debug("OK");
getLog().debug("Use 'isIdentical()' to verify different beans...");
assertTrue(!differentBean.isIdentical(bean));
getLog().debug("OK...beans are different!");
getLog().debug("Test the Primary Keys...");
AccountPK beansPK = (AccountPK)bean.getPrimaryKey();
AccountPK anotherBeansPK = (AccountPK)anotherBean.getPrimaryKey();
assertTrue(beansPK.equals(anotherBeansPK));
getLog().debug("OK...they're the same");
getLog().debug("Compare different keys...");
assertTrue(!beansPK.equals(anotherPK));