User: danch   
  Date: 02/04/16 16:06:03

  Modified:    src/main/org/jboss/test/readahead/ejb Tag: Branch_2_4
                        CMPFindTestSession.java
  Log:
  Fixed a bug that was causing tests to error out - seems we're fast enough to insert 
> 1 entity in the windows currentTimeMillis resolution
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +172 -172  
jbosstest/src/main/org/jboss/test/readahead/ejb/CMPFindTestSession.java
  
  Index: CMPFindTestSession.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/readahead/ejb/CMPFindTestSession.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- CMPFindTestSession.java   29 Oct 2001 00:04:26 -0000      1.1.2.2
  +++ CMPFindTestSession.java   16 Apr 2002 23:06:03 -0000      1.1.2.3
  @@ -1,172 +1,172 @@
  -package org.jboss.test.readahead.ejb;
  -
  -import java.util.Iterator;
  -import java.util.Collection;
  -import java.text.Collator;
  -import javax.naming.InitialContext;
  -import javax.naming.NamingException;
  -import javax.ejb.EJBException;
  -import javax.ejb.SessionBean;
  -import javax.ejb.SessionContext;
  -import org.jboss.test.readahead.interfaces.AddressHome;
  -import org.jboss.test.readahead.interfaces.AddressRemote;
  -import org.jboss.test.readahead.interfaces.CMPFindTestEntityHome;
  -import org.jboss.test.readahead.interfaces.CMPFindTestEntityRemote;
  -
  -/**
  - * Implementation class for session bean used in read-ahead finder
  - * tests
  - *
  - * @author <a href="mailto:[EMAIL PROTECTED]";>danch (Dan Christopherson</a>
  - * @version $Id: CMPFindTestSession.java,v 1.1.2.2 2001/10/29 00:04:26 danch Exp $
  - *
  - * Revision:
  - */
  -public class CMPFindTestSession implements SessionBean {
  -   private static final int DATASET_SIZE = 100;
  -
  -   private SessionContext sessionContext;
  -
  -   public void ejbCreate() {
  -   }
  -   public void ejbRemove() {
  -   }
  -   public void ejbActivate() {
  -   }
  -   public void ejbPassivate() {
  -   }
  -   public void setSessionContext(SessionContext context) {
  -      sessionContext = context;
  -   }
  -
  -   public void removeTestData() {
  -      try {
  -         InitialContext ctx = new InitialContext();
  -         CMPFindTestEntityHome home = 
(CMPFindTestEntityHome)ctx.lookup("CMPFindTestEntity");
  -
  -         Collection coll = home.findAll();
  -         Iterator iter = coll.iterator();
  -         while (iter.hasNext()) {
  -            CMPFindTestEntityRemote rem = (CMPFindTestEntityRemote)iter.next();
  -
  -            rem.remove();
  -         }
  -      } catch (Exception e) {
  -      }
  -   }
  -
  -   public void createTestData() {
  -      try {
  -         InitialContext ctx = new InitialContext();
  -         CMPFindTestEntityHome home = 
(CMPFindTestEntityHome)ctx.lookup("CMPFindTestEntity");
  -         AddressHome addrHome = (AddressHome)ctx.lookup("Address");
  -         for (int i=0;i<DATASET_SIZE;i++) {
  -            String key = Long.toString(System.currentTimeMillis());
  -            CMPFindTestEntityRemote rem = home.create(key);
  -            rem.setName("Name"+i);
  -            rem.setRank("Rank");
  -            rem.setSerialNumber("123456789");
  -            //give him an address
  -            if ((i % 2) ==0) {
  -               addrHome.create(rem.getKey(), "1", "123 east st.", "Eau Claire", 
"WI", "54701");
  -            } else {
  -               addrHome.create(rem.getKey(), "1", "123 east st.", "Milwaukee", 
"WI", "54201");
  -            }
  -         }
  -      } catch (Exception e) {
  -         System.out.println("Exception caught: "+e);
  -         e.printStackTrace();
  -         throw new EJBException(e.getMessage());
  -      }
  -   }
  -
  -   public void addressByCity() {
  -      try {
  -         InitialContext ctx = new InitialContext();
  -         AddressHome home = (AddressHome)ctx.lookup("Address");
  -
  -         long startTime = System.currentTimeMillis();
  -         Collection coll = home.findByCity("Eau Claire");
  -         int count = 0;
  -         Iterator iter = coll.iterator();
  -         while (iter.hasNext()) {
  -            AddressRemote rem = (AddressRemote)iter.next();
  -            rem.getCity();
  -//            System.out.println("Name: "+rem.getName()+" Rank: "+rem.getRank());
  -            count++;
  -         }
  -         long endTime = System.currentTimeMillis();
  -         System.out.println("called "+count+" beans in "+(endTime-startTime)+" 
ms.");
  -      } catch (Exception e) {
  -         System.out.println("Caught "+e);
  -      }
  -   }
  -
  -   public void testByCity() {
  -      try {
  -         InitialContext ctx = new InitialContext();
  -         CMPFindTestEntityHome home = 
(CMPFindTestEntityHome)ctx.lookup("CMPFindTestEntity");
  -
  -         long startTime = System.currentTimeMillis();
  -         Collection coll = home.findByCity("Eau Claire");
  -         int count = 0;
  -         Iterator iter = coll.iterator();
  -         while (iter.hasNext()) {
  -            CMPFindTestEntityRemote rem = (CMPFindTestEntityRemote)iter.next();
  -            rem.getName();
  -//            System.out.println("Name: "+rem.getName()+" Rank: "+rem.getRank());
  -            count++;
  -         }
  -         long endTime = System.currentTimeMillis();
  -         System.out.println("called "+count+" beans in "+(endTime-startTime)+" 
ms.");
  -      } catch (Exception e) {
  -      }
  -   }
  -   public void testFinder() {
  -      try {
  -         InitialContext ctx = new InitialContext();
  -         CMPFindTestEntityHome home = 
(CMPFindTestEntityHome)ctx.lookup("CMPFindTestEntity");
  -
  -         long startTime = System.currentTimeMillis();
  -         Collection coll = home.findAll();
  -         int count = 0;
  -         Iterator iter = coll.iterator();
  -         String lastName = "0";
  -         Collator collator = Collator.getInstance();
  -         while (iter.hasNext()) {
  -            CMPFindTestEntityRemote rem = (CMPFindTestEntityRemote)iter.next();
  -            String thisName = rem.getName();
  -            if (collator.compare(lastName,thisName)>=0)
  -               throw new EJBException("Ordering of findAll failed: 
"+lastName+"<"+thisName);
  -//            System.out.println("lastName=<"+lastName+">, 
thisName=<"+thisName+">");
  -//            System.out.println("Name: "+rem.getName()+" Rank: "+rem.getRank());
  -            lastName = thisName;
  -            count++;
  -         }
  -         long endTime = System.currentTimeMillis();
  -         System.out.println("called "+count+" beans in "+(endTime-startTime)+" 
ms.");
  -      } catch (Exception e) {
  -      }
  -   }
  -
  -   public void testUpdates() {
  -      try {
  -         InitialContext ctx = new InitialContext();
  -         CMPFindTestEntityHome home = 
(CMPFindTestEntityHome)ctx.lookup("CMPFindTestEntity");
  -
  -         long startTime = System.currentTimeMillis();
  -         Collection coll = home.findAll();
  -         int count = 0;
  -         Iterator iter = coll.iterator();
  -         while (iter.hasNext()) {
  -            CMPFindTestEntityRemote rem = (CMPFindTestEntityRemote)iter.next();
  -            rem.getName();
  -            rem.setRank("Very");
  -            count++;
  -         }
  -         long endTime = System.currentTimeMillis();
  -         System.out.println("called "+count+" beans in "+(endTime-startTime)+" 
ms.");
  -      } catch (Exception e) {
  -      }
  -   }
  -}
  \ No newline at end of file
  +package org.jboss.test.readahead.ejb;
  +
  +import java.util.Iterator;
  +import java.util.Collection;
  +import java.text.Collator;
  +import javax.naming.InitialContext;
  +import javax.naming.NamingException;
  +import javax.ejb.EJBException;
  +import javax.ejb.SessionBean;
  +import javax.ejb.SessionContext;
  +import org.jboss.test.readahead.interfaces.AddressHome;
  +import org.jboss.test.readahead.interfaces.AddressRemote;
  +import org.jboss.test.readahead.interfaces.CMPFindTestEntityHome;
  +import org.jboss.test.readahead.interfaces.CMPFindTestEntityRemote;
  +
  +/**
  + * Implementation class for session bean used in read-ahead finder
  + * tests
  + *
  + * @author <a href="mailto:[EMAIL PROTECTED]";>danch (Dan Christopherson</a>
  + * @version $Id: CMPFindTestSession.java,v 1.1.2.3 2002/04/16 23:06:03 danch Exp $
  + *
  + * Revision:
  + */
  +public class CMPFindTestSession implements SessionBean {
  +   private static final int DATASET_SIZE = 100;
  +
  +   private SessionContext sessionContext;
  +
  +   public void ejbCreate() {
  +   }
  +   public void ejbRemove() {
  +   }
  +   public void ejbActivate() {
  +   }
  +   public void ejbPassivate() {
  +   }
  +   public void setSessionContext(SessionContext context) {
  +      sessionContext = context;
  +   }
  +
  +   public void removeTestData() {
  +      try {
  +         InitialContext ctx = new InitialContext();
  +         CMPFindTestEntityHome home = 
(CMPFindTestEntityHome)ctx.lookup("CMPFindTestEntity");
  +
  +         Collection coll = home.findAll();
  +         Iterator iter = coll.iterator();
  +         while (iter.hasNext()) {
  +            CMPFindTestEntityRemote rem = (CMPFindTestEntityRemote)iter.next();
  +
  +            rem.remove();
  +         }
  +      } catch (Exception e) {
  +      }
  +   }
  +
  +   public void createTestData() {
  +      try {
  +         InitialContext ctx = new InitialContext();
  +         CMPFindTestEntityHome home = 
(CMPFindTestEntityHome)ctx.lookup("CMPFindTestEntity");
  +         AddressHome addrHome = (AddressHome)ctx.lookup("Address");
  +         for (int i=0;i<DATASET_SIZE;i++) {
  +            String key = Long.toString(System.currentTimeMillis())+"-"+i;
  +            CMPFindTestEntityRemote rem = home.create(key);
  +            rem.setName("Name"+i);
  +            rem.setRank("Rank");
  +            rem.setSerialNumber("123456789");
  +            //give him an address
  +            if ((i % 2) ==0) {
  +               addrHome.create(rem.getKey(), "1", "123 east st.", "Eau Claire", 
"WI", "54701");
  +            } else {
  +               addrHome.create(rem.getKey(), "1", "123 east st.", "Milwaukee", 
"WI", "54201");
  +            }
  +         }
  +      } catch (Exception e) {
  +         System.out.println("Exception caught: "+e);
  +         e.printStackTrace();
  +         throw new EJBException(e.getMessage());
  +      }
  +   }
  +
  +   public void addressByCity() {
  +      try {
  +         InitialContext ctx = new InitialContext();
  +         AddressHome home = (AddressHome)ctx.lookup("Address");
  +
  +         long startTime = System.currentTimeMillis();
  +         Collection coll = home.findByCity("Eau Claire");
  +         int count = 0;
  +         Iterator iter = coll.iterator();
  +         while (iter.hasNext()) {
  +            AddressRemote rem = (AddressRemote)iter.next();
  +            rem.getCity();
  +//            System.out.println("Name: "+rem.getName()+" Rank: "+rem.getRank());
  +            count++;
  +         }
  +         long endTime = System.currentTimeMillis();
  +         System.out.println("called "+count+" beans in "+(endTime-startTime)+" 
ms.");
  +      } catch (Exception e) {
  +         System.out.println("Caught "+e);
  +      }
  +   }
  +
  +   public void testByCity() {
  +      try {
  +         InitialContext ctx = new InitialContext();
  +         CMPFindTestEntityHome home = 
(CMPFindTestEntityHome)ctx.lookup("CMPFindTestEntity");
  +
  +         long startTime = System.currentTimeMillis();
  +         Collection coll = home.findByCity("Eau Claire");
  +         int count = 0;
  +         Iterator iter = coll.iterator();
  +         while (iter.hasNext()) {
  +            CMPFindTestEntityRemote rem = (CMPFindTestEntityRemote)iter.next();
  +            rem.getName();
  +//            System.out.println("Name: "+rem.getName()+" Rank: "+rem.getRank());
  +            count++;
  +         }
  +         long endTime = System.currentTimeMillis();
  +         System.out.println("called "+count+" beans in "+(endTime-startTime)+" 
ms.");
  +      } catch (Exception e) {
  +      }
  +   }
  +   public void testFinder() {
  +      try {
  +         InitialContext ctx = new InitialContext();
  +         CMPFindTestEntityHome home = 
(CMPFindTestEntityHome)ctx.lookup("CMPFindTestEntity");
  +
  +         long startTime = System.currentTimeMillis();
  +         Collection coll = home.findAll();
  +         int count = 0;
  +         Iterator iter = coll.iterator();
  +         String lastName = "0";
  +         Collator collator = Collator.getInstance();
  +         while (iter.hasNext()) {
  +            CMPFindTestEntityRemote rem = (CMPFindTestEntityRemote)iter.next();
  +            String thisName = rem.getName();
  +            if (collator.compare(lastName,thisName)>=0)
  +               throw new EJBException("Ordering of findAll failed: 
"+lastName+"<"+thisName);
  +//            System.out.println("lastName=<"+lastName+">, 
thisName=<"+thisName+">");
  +//            System.out.println("Name: "+rem.getName()+" Rank: "+rem.getRank());
  +            lastName = thisName;
  +            count++;
  +         }
  +         long endTime = System.currentTimeMillis();
  +         System.out.println("called "+count+" beans in "+(endTime-startTime)+" 
ms.");
  +      } catch (Exception e) {
  +      }
  +   }
  +
  +   public void testUpdates() {
  +      try {
  +         InitialContext ctx = new InitialContext();
  +         CMPFindTestEntityHome home = 
(CMPFindTestEntityHome)ctx.lookup("CMPFindTestEntity");
  +
  +         long startTime = System.currentTimeMillis();
  +         Collection coll = home.findAll();
  +         int count = 0;
  +         Iterator iter = coll.iterator();
  +         while (iter.hasNext()) {
  +            CMPFindTestEntityRemote rem = (CMPFindTestEntityRemote)iter.next();
  +            rem.getName();
  +            rem.setRank("Very");
  +            count++;
  +         }
  +         long endTime = System.currentTimeMillis();
  +         System.out.println("called "+count+" beans in "+(endTime-startTime)+" 
ms.");
  +      } catch (Exception e) {
  +      }
  +   }
  +}
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to