1 18 package org.objectweb.speedo.runtime.basic; 19 20 import org.objectweb.speedo.SpeedoTestHelper; 21 import org.objectweb.speedo.pobjects.basic.BasicA; 22 import org.objectweb.util.monolog.api.BasicLevel; 23 24 import java.util.Calendar ; 25 import java.util.Iterator ; 26 27 import javax.jdo.Extent; 28 import javax.jdo.PersistenceManager; 29 30 34 public class TestBigExtent extends SpeedoTestHelper { 35 36 public TestBigExtent(String s) { 37 super(s); 38 } 39 40 protected String getLoggerName() { 41 return LOG_NAME + ".rt.basic.TestBigExtent"; 42 } 43 44 public void testCreateObjects(int NBOBJ) { 45 logger.log(BasicLevel.WARN, "Creating " + NBOBJ + " objects ..."); 46 PersistenceManager pm = pmf.getPersistenceManager(); 47 pm.currentTransaction().begin(); 48 for(int i=0; i<NBOBJ; i++) { 49 BasicA ba = new BasicA(); 50 ba.writeF1("testBigExtent_" + NBOBJ); 51 pm.makePersistent(ba); 52 } 53 pm.currentTransaction().commit(); 54 pm.evictAll(); 55 pm.close(); 56 } 57 58 public void test1CreateObjects1000() { 59 testCreateObjects(1000); 60 } 61 62 public void test2BigExtent() { 63 logger.log(BasicLevel.WARN, "Using the extent ..."); 64 PersistenceManager pm = pmf.getPersistenceManager(); 65 pm.evictAll(); 66 long t = Calendar.getInstance().getTimeInMillis(); 67 Extent e = pm.getExtent(BasicA.class, false); 68 Iterator it = e.iterator(); 69 int i= 0; 70 while(it.hasNext()) { 71 BasicA ba = (BasicA) it.next(); 72 logger.log(BasicLevel.DEBUG, ba.readF1()); 73 } 74 e.closeAll(); 75 pm.close(); 76 t = Calendar.getInstance().getTimeInMillis() - t; 77 logger.log(BasicLevel.WARN, "Time: " + t + "ms"); 78 } 79 80 public void testRemoveObject(int NBOBJ) { 81 logger.log(BasicLevel.WARN, "Removing " + NBOBJ + " objects ..."); 82 PersistenceManager pm = pmf.getPersistenceManager(); 83 pm.currentTransaction().begin(); 84 Extent e = pm.getExtent(BasicA.class, false); 85 Iterator it = e.iterator(); 86 int i= 0; 87 while(it.hasNext()) { 88 assertTrue("More object than expected, expected=" 89 + NBOBJ + ", found " + (i + 1), i < NBOBJ); 90 BasicA ba = (BasicA) it.next(); 91 pm.deletePersistent(ba); 92 logger.log(BasicLevel.DEBUG, ba.readF1()); 93 i++; 94 } 95 e.closeAll(); 96 pm.currentTransaction().commit(); 97 pm.close(); 98 } 99 100 public void test3RemoveObject1000() { 101 testRemoveObject(1000); 102 } 103 } 104 | Popular Tags |