User: danch
Date: 01/10/28 16:04:27
Modified: src/main/org/jboss/test/readahead/ejb Tag: Branch_2_4
CMPFindTestSession.java
Log:
test ordered findAll
Revision Changes Path
No revision
No revision
1.1.2.2 +25 -18
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.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- CMPFindTestSession.java 2001/07/09 01:06:05 1.1.2.1
+++ CMPFindTestSession.java 2001/10/29 00:04:26 1.1.2.2
@@ -2,6 +2,7 @@
import java.util.Iterator;
import java.util.Collection;
+import java.text.Collator;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.ejb.EJBException;
@@ -15,17 +16,17 @@
/**
* 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.1 2001/07/09 01:06:05 starksm Exp $
- *
+ * @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() {
@@ -37,23 +38,23 @@
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();
@@ -62,7 +63,7 @@
for (int i=0;i<DATASET_SIZE;i++) {
String key = Long.toString(System.currentTimeMillis());
CMPFindTestEntityRemote rem = home.create(key);
- rem.setName("Name");
+ rem.setName("Name"+i);
rem.setRank("Rank");
rem.setSerialNumber("123456789");
//give him an address
@@ -78,12 +79,12 @@
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;
@@ -100,12 +101,12 @@
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;
@@ -125,15 +126,21 @@
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();
- rem.getName();
+ 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();
@@ -141,12 +148,12 @@
} 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;
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development