User: schulze 
  Date: 00/10/25 16:08:37

  Modified:    src/main/org/jboss/test/testbean/test Main.java
  Log:
  added the BMP test to this test class
  (deploys additional the bmp.jar package now)
  
  Revision  Changes    Path
  1.4       +103 -2    jbosstest/src/main/org/jboss/test/testbean/test/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jbosstest/src/main/org/jboss/test/testbean/test/Main.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Main.java 2000/10/09 17:54:56     1.3
  +++ Main.java 2000/10/25 23:08:36     1.4
  @@ -37,12 +37,18 @@
   import org.jboss.test.testbean2.interfaces.AllTypesHome;
   import org.jboss.test.testbean2.interfaces.MyObject;
   
  +import org.jboss.test.bmp.interfaces.BMPHelperSession;
  +import org.jboss.test.bmp.interfaces.BMPHelperSessionHome;
  +import org.jboss.test.bmp.interfaces.SimpleBMP;
  +import org.jboss.test.bmp.interfaces.SimpleBMPHome;
   
  +
  +
   /**
   * Sample client for the jboss container.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
  -* @version $Id: Main.java,v 1.3 2000/10/09 17:54:56 salborini Exp $
  +* @version $Id: Main.java,v 1.4 2000/10/25 23:08:36 schulze Exp $
   */
   public class Main 
      extends junit.framework.TestCase
  @@ -66,7 +72,7 @@
                        int loop = 0;
                        
                        while (true) {
  -                             char[] result = "xxxxxxxx".toCharArray();
  +                             char[] result = "xxxxxxxxx".toCharArray();
                                
                                long start = System.currentTimeMillis();
                                
  @@ -78,6 +84,7 @@
                                try { main.testBeanManagedTransactionDemarcation(); } 
catch (Exception e) { result[5] = ' '; }
                                // try { main.testAllTypesBean(); } catch (Exception 
e) { result[6] = ' '; }
                                try { main.testTxSession(); } catch (Exception e) { 
result[7] = ' '; }
  +                             try { main.testRealBMP(); } catch (Exception e) { 
result[8] = ' '; }
   
                                long end = System.currentTimeMillis();
                                
  @@ -99,6 +106,99 @@
                }
        }
        
  +    public void testRealBMP() 
  +             throws Exception
  +   {
  +      
  +      System.out.println();
  +      System.out.println("Test Real BMP (load/passivation/...");
  +      System.out.println("===================================");
  +      System.out.println();
  +      
  +      BMPHelperSessionHome sessionHome = (BMPHelperSessionHome)new InitialContext 
().lookup ("bmp.BMPHelperSession");
  +      BMPHelperSession session = sessionHome.create ();
  +      
  +      System.out.println ("looking up table:");
  +      if (!session.existsSimpleBeanTable ())
  +      {
  +         System.out.println ("table does not exist.");
  +         System.out.print ("create it...");
  +         session.createSimpleBeanTable();
  +         System.out.println ("done.");
  +      }
  +      
  +      SimpleBMPHome home = (SimpleBMPHome)new InitialContext ().lookup 
("bmp.SimpleBMP");
  +
  +      System.out.println(++test+"- "+"create bean1: 1, Daniel");
  +      SimpleBMP b1 = home.create (1, "Daniel");
  +      System.out.println ("getName (): "+b1.getName ());
  +      
  +      System.out.println(++test+"- "+"create bean2: 2, Robert");
  +      b1 = home.create (2, "Robert");
  +      System.out.println ("getName (): "+b1.getName ());
  +      
  +      try
  +      {
  +         System.out.println(++test+"- trying to create one with same primkey: 1, 
Patrick");
  +         b1 = home.create (1, "Patrick");
  +      }
  +      catch (Exception _e)
  +      {
  +         System.out.println (_e.toString ());
  +      }
  +      
  +      System.out.println(++test+"- create some more dummys:");
  +      for (int i = 0; i < 50; ++i)
  +         home.create (i + 3, ("Dummy "+i));
  +      
  +      try
  +      {
  +         System.out.println(++test+"- trying to find Robert again");
  +         b1 = home.findByPrimaryKey (new Integer (2));
  +         System.out.println ("getName (): "+b1.getName ());
  +      }
  +      catch (Exception _e)
  +      {
  +         System.out.println (_e.toString ());
  +      }
  +      
  +      try
  +      {
  +         System.out.println(++test+"- trying to find an not existing bean");
  +         b1 = home.findByPrimaryKey (new Integer (0));
  +         System.out.println ("getName (): "+b1.getName ());
  +      }
  +      catch (Exception _e)
  +      {
  +         System.out.println (_e.toString ());
  +      }
  +      
  +      System.out.println(++test+"- rename Daniel to Maria: 1, Daniel");
  +      b1 = home.findByPrimaryKey (new Integer (1));
  +      System.out.println ("name old: " + b1.getName ());
  +      b1.setName ("Maria");
  +      System.out.println ("name new: " + b1.getName ());
  +      
  +      System.out.println(++test+"- find all beans:");
  +      Iterator it = home.findAll ().iterator ();
  +      while (it.hasNext ())
  +      {
  +         System.out.println ("found:"+((SimpleBMP)it.next ()).getName ());
  +      }            
  +      
  +      System.out.println(++test+"- Now trying from within the Session bean (to be 
able to rollback):");
  +      System.out.println (session.doTest ());
  +      
  +      System.out.println(++test+"- removing all beans");
  +      it = home.findAll ().iterator ();
  +      while (it.hasNext ())
  +         ((SimpleBMP)it.next ()).remove ();
  +
  +      System.out.print ("drop table...");
  +      session.dropSimpleBeanTable();
  +      System.out.println ("done.");
  +   }
  +
        
       public void testStatelessBean() 
                throws Exception
  @@ -916,6 +1016,7 @@
         System.out.println();
         System.out.print("Deploying test beans...");
          System.out.flush();
  +      new org.jboss.jmx.client.Deployer().deploy("../deploy/bmp.jar");
         new org.jboss.jmx.client.Deployer().deploy("../deploy/testbean.jar");
         new org.jboss.jmx.client.Deployer().deploy("../deploy/testbean2.jar");
         deployed = true;
  
  
  

Reply via email to