{
service = home.create();
User user = new User();
user.setEmail("nobody@nowhere.com");
user.setName( new Name() );
user.getName().setFirstName("John");
user.getName().setInitial( new Character('Q') );
user.getName().setLastName("Public");
user.setPassword("password");
user.setTimeOfCreation( new GregorianCalendar() );
user.setHandle("myHandle");
Long savedUserId = service.storeUser( user ).getId();
getLog().info("User created with id = " + savedUserId );
// make *sure* it gets loaded into cache. This is to check
// that JBossCache as 2nd-level cache is properly releasing
// resources on SF shutdown; I have manually verified this is
// the case w/o JBossCache as the 2nd-level cache (i.e. this
// test case passes w/o JBossCache in the mix).
List users = service.listUsers();
assertNotNull( users );
assertEquals( "Incorrect result size", 1, users.size() );
}
finally
{
if ( service != null )
{
try
{
service.remove();
}
catch( Throwable t )
{
}
}
}
}
catch( Throwable t )
{
// ignore; does not really matter if this stuff fails/succeeds
// simply store the original failure so that we can use it later
initialThrowable = t;
}
// force a redeploy
delegate.redeploy( "hib-test.ear" );
// then, do some more work...
ProfileServiceHome home = ProfileServiceUtil.getHome();
ProfileService service = null;
try
{
service = home.create();
User user = new User();
user.setEmail("nobody@nowhere.com");
user.setName( new Name() );
user.getName().setFirstName("John");
user.getName().setInitial( new Character('Q') );
user.getName().setLastName("Public");
user.setPassword("password");
user.setTimeOfCreation( new GregorianCalendar() );