Package org.jboss.test.hibernate.ejb.interfaces

Examples of org.jboss.test.hibernate.ejb.interfaces.ProfileService


      // Do some work
      try
      {
         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() );
            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() );
         user.setHandle("myHandle");

         Long savedUserId = service.storeUser( user ).getId();
         try
         {
            getLog().info("User created with id = " + savedUserId );

            List users = service.listUsers();
            assertNotNull( users );
            assertEquals( "Incorrect result size", 1, users.size() );
         }
         finally
         {
            getLog().info("About to delete user with id = " + savedUserId);
            service.deleteUser(savedUserId);
            getLog().info("User with id = " + savedUserId + " successfully deleted.");
         }
      }
      catch( Throwable t )
      {
         // it is possible for the initial code block (b4 the redeploy) and this
         // (after redeploy) to fail for the same reason, which would not indicate
         // a redeployment issue per-se; but how to detect that?
         if ( initialThrowable == null )
         {
            fail( "Getting new exceptions after redeploy [" + t + "]" );
         }

         if ( !t.getClass().getName().equals( initialThrowable.getClass().getName() ) )
         {
            fail( "After redploy failing for different cause [" + t + "]" );
         }
      }
      finally
      {
         if ( service != null )
         {
            try
            {
               service.remove();
            }
            catch( Throwable t )
            {
            }
         }
View Full Code Here


   }

   public void testCurrentSession() throws Throwable {

      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() );
         user.setHandle("myHandle");

         Long savedUserId = service.storeUser( user ).getId();
         getLog().info("User created with id = " + savedUserId );

         List users = service.listUsers();
         assertNotNull( users );
         assertEquals( "Incorrect result size", 1, users.size() );

         Long userId = ( ( User ) users.get( 0 ) ).getId();
         assertEquals( "Saved used not returned", savedUserId, userId );

         user = service.loadUser( savedUserId );
         assertNotNull( user );
      }
      finally
      {
         if ( service != null )
         {
            try
            {
               service.remove();
            }
            catch( Throwable t )
            {
               // ignore
            }
View Full Code Here

TOP

Related Classes of org.jboss.test.hibernate.ejb.interfaces.ProfileService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.