1 18 package org.objectweb.speedo.runtime.collection; 19 20 import org.objectweb.speedo.SpeedoTestHelper; 21 import org.objectweb.speedo.pobjects.collection.AMMB; 22 import org.objectweb.speedo.pobjects.collection.BMMB; 23 import org.objectweb.util.monolog.api.BasicLevel; 24 25 import javax.jdo.PersistenceManager; 26 27 import junit.framework.Assert; 28 29 import java.util.Collection ; 30 import java.util.Iterator ; 31 32 36 public class TestLoadMNB extends SpeedoTestHelper { 37 38 public TestLoadMNB(String s) { 39 super(s); 40 } 41 42 protected String getLoggerName() { 43 return LOG_NAME + ".rt.collection.TestLoadMNB"; 44 } 45 46 public void test1() { 47 PersistenceManager pm = pmf.getPersistenceManager(); 48 pm.currentTransaction().begin(); 49 Object oid = pm.newObjectIdInstance(AMMB.class, "1230"); 50 Assert.assertNotNull("null oid !", oid); 51 AMMB a = (AMMB) pm.getObjectById(oid, false); 52 Assert.assertNotNull("null AMMB object", a); 53 Collection bs = a.getBs(); 54 Assert.assertNotNull("null collection of BMMB", bs); 55 Iterator it = bs.iterator(); 56 while(it.hasNext()) { 57 BMMB b = (BMMB) it.next(); 58 Assert.assertNotNull("null element collection of BMMB", b); 59 logger.log(BasicLevel.DEBUG, "idb: " + b.getIdb()); 60 it.remove(); 61 b.getAs().remove(a); 62 pm.deletePersistent(b); 63 } 64 pm.deletePersistent(a); 65 pm.currentTransaction().commit(); 66 pm.close(); 67 } 68 } 69 | Popular Tags |