Package org.jboss.test.bmp.interfaces

Examples of org.jboss.test.bmp.interfaces.SimpleBMPHome


      try
      {
         getLog().debug ("done.");
        
         getLog().debug ("start playing with bmp beans.");
         SimpleBMPHome home = (SimpleBMPHome)new InitialContext ().lookup ("bmp.SmallCacheBMP");
         SimpleBMP[] beans = new SimpleBMP[10];
         for (int i = 0; i < 10; ++i)
         {
            getLog().debug ("create bean " + i);
            beans[i] = home.create (i, "Bean " + i);
            getLog().debug ("getName (): "+ beans[i].getName ());
         }

         Thread.sleep(10000);
        
         for (int i = 0; i < 10; ++i)
            assertEquals(beans[i].getPrimaryKey(), beans[i].getIdViaEJBObject());

         getLog().debug ("removing all beans:");
         Iterator it = home.findAll ().iterator ();
         while (it.hasNext ())
            ((SimpleBMP)it.next ()).remove ();
      }
      finally
      {
View Full Code Here


      try
      {
         getLog().debug ("done.");
        
         getLog().debug ("start playing with bmp beans.");
         SimpleBMPHome home = (SimpleBMPHome)new InitialContext ().lookup ("bmp.SimpleBMP");
         getLog().debug ("create bean1: 1, Daniel");
         SimpleBMP b1 = home.create (1, "Daniel");
         getLog().debug ("getName (): "+b1.getName ());

         getLog().debug ("create bean2: 2, Robert");
         b1 = home.createMETHOD (2, "Robert");
         getLog().debug ("getName (): "+b1.getName ());

         try
         {
            getLog().debug ("trying to create one with same primkey: 1, Patrick");
            b1 = home.create (1, "Patrick");
         }
         catch (Exception _e)
         {
            getLog().debug (_e.toString ());
         }
        
         getLog().debug ("create some more dummys:");
         for (int i = 0; i < 50; ++i)
            home.create (i + 3, ("Dummy "+i));

         try
         {
            getLog().debug ("trying to find Robert again");
            b1 = home.findByPrimaryKey (new Integer (2));
            getLog().debug ("getName (): "+b1.getName ());
         }
         catch (Exception _e)
         {
            getLog().debug (_e.toString ());
         }

         try
         {
            getLog().debug ("trying to find an not existing bean");
            b1 = home.findByPrimaryKey (new Integer (0));
            getLog().debug ("getName (): "+b1.getName ());
         }
         catch (Exception _e)
         {
            getLog().debug (_e.toString ());
         }
        
        
         getLog().debug ("rename Daniel to Maria: 1, Daniel");
         b1 = home.findByPrimaryKey (new Integer (1));
         getLog().debug ("name old: " + b1.getName ());
         b1.setName ("Maria");
         getLog().debug ("name new: " + b1.getName ());
       
        
         getLog().debug ("find all beans:");
         Iterator it = home.findAll ().iterator ();
         while (it.hasNext ())
         {
            getLog().debug ("found:"+((SimpleBMP)it.next ()).getName ());
         }           


         getLog().debug ("*******Now trying from within the Session bean (to be able to rollback):");
         getLog().debug (session.doTest ());
         getLog().debug ("Getting the name after a rollback:");
         getLog().debug (session.doTestAfterRollback ());

         getLog().debug ("removing all beans:");
         it = home.findAll ().iterator ();
         while (it.hasNext ())
            ((SimpleBMP)it.next ()).remove ();
        
         SimpleBMP b2 = home.create(200, "Dave");
         assertFalse("ejbStore() should not be invoked during ejbPostCreate()", b2.isEjbStoreInvoked());
      }
      finally
      {
         getLog().debug ("table exists.");
View Full Code Here

   {
      log.debug ("ejbPostCreate (int, String) called");
     
      tempEjbStoreInvoked = false;
      // Do a find all to see whether ejbStore gets invoked
      SimpleBMPHome home = (SimpleBMPHome) ctx.getEJBHome();
      try
      {
         home.findAll();
      }
      catch (FinderException e)
      {
         throw new RemoteException("Unexpected error invoking findAll", e);
      }
View Full Code Here

   {
      StringBuffer sb = new StringBuffer ();
      SimpleBMP b;
      try
      {
         SimpleBMPHome home = (SimpleBMPHome) new InitialContext ().lookup ("java:comp/env/bean");
         b = home.findByPrimaryKey(new Integer (1));
      }
      catch (Exception _ne)
      {
         throw new EJBException ("couldnt find entity: "+_ne.getMessage ());
      }
View Full Code Here

   {
      StringBuffer sb = new StringBuffer ();
      SimpleBMP b;
      try
      {
         SimpleBMPHome home = (SimpleBMPHome) new InitialContext ().lookup ("java:comp/env/bean");
         b = home.findByPrimaryKey(new Integer (1));
      }
      catch (Exception _ne)
      {
         throw new EJBException ("couldnt find entity: "+_ne.getMessage ());
      }
View Full Code Here

         getLog().debug ("create it...");
         session.createSimpleBeanTable();
         getLog().debug ("done.");
      }

      SimpleBMPHome home = (SimpleBMPHome)new InitialContext ().lookup ("bmp.SimpleBMP");

      getLog().debug(++test+"- "+"create bean1: 1, Daniel");
      SimpleBMP b1 = home.create (1, "Daniel");
      getLog().debug ("getName (): "+b1.getName ());

      getLog().debug(++test+"- "+"create bean2: 2, Robert");
      b1 = home.create (2, "Robert");
      getLog().debug ("getName (): "+b1.getName ());

      try
      {
         getLog().debug(++test+"- trying to create one with same primkey: 1, Patrick");
         b1 = home.create (1, "Patrick");
         fail("Was able to create duplicate SimpleBMP");
      }
      catch (Exception _e)
      {
         getLog().debug (_e.toString ());
      }

      getLog().debug(++test+"- create some more dummys:");
      for (int i = 0; i < 50; ++i)
         home.create (i + 3, ("Dummy "+i));

      getLog().debug(++test+"- trying to find Robert again");
      b1 = home.findByPrimaryKey (new Integer (2));
      getLog().debug ("getName (): "+b1.getName ());

      try
      {
         getLog().debug(++test+"- trying to find an not existing bean");
         b1 = home.findByPrimaryKey (new Integer (0));
         assertTrue("findByPrimaryKey(0) should fail", b1 == null);
      }
      catch (Exception _e)
      {
         getLog().debug (_e.toString ());
      }

      getLog().debug(++test+"- rename Daniel to Maria: 1, Daniel");
      b1 = home.findByPrimaryKey (new Integer (1));
      getLog().debug ("name old: " + b1.getName ());
      b1.setName ("Maria");
      assertTrue("getName == Maria", "Maria".equals(b1.getName ()));

      getLog().debug(++test+"- find all beans:");
      Iterator it = home.findAll ().iterator ();
      while (it.hasNext ())
      {
         getLog().debug ("found:"+((SimpleBMP)it.next ()).getName ());
      }

      getLog().debug(++test+"- Now trying from within the Session bean (to be able to rollback):");
      getLog().debug (session.doTest ());

      getLog().debug(++test+"- get name after rollback ");
      getLog().debug (session.doTestAfterRollback ());

      getLog().debug(++test+"- removing all beans");
      it = home.findAll ().iterator ();
      while (it.hasNext ())
         ((SimpleBMP)it.next ()).remove ();

      getLog().debug ("drop table...");
      session.dropSimpleBeanTable();
View Full Code Here

TOP

Related Classes of org.jboss.test.bmp.interfaces.SimpleBMPHome

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.