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 24 import javax.jdo.PersistenceManager; 25 import java.util.Collection ; 26 import java.util.ArrayList ; 27 28 import junit.framework.Assert; 29 30 31 35 public class TestMMB extends SpeedoTestHelper { 36 37 public TestMMB(String s) { 38 super(s); 39 } 40 41 protected String getLoggerName() { 42 return LOG_NAME + ".rt.collection.TestMMB"; 43 } 44 45 public void test1() { 46 AMMB[] as = new AMMB[3]; 47 BMMB[] bs = new BMMB[3]; 48 for(int i=0; i<as.length; i++) { 49 as[i] = new AMMB(i); 50 bs[i] = new BMMB(i); 51 } 52 Collection as0 = new ArrayList (2); 53 as0.add(bs[0]); 54 as0.add(bs[1]); 55 as[0].setBs(as0); 56 Collection as1 = new ArrayList (3); 57 as1.add(bs[0]); 58 as1.add(bs[1]); 59 as1.add(bs[2]); 60 as[1].setBs(as1); 61 Collection as2 = new ArrayList (2); 62 as2.add(bs[1]); 63 as2.add(bs[2]); 64 as[2].setBs(as2); 65 66 Collection bs0 = new ArrayList (2); 67 bs0.add(as[0]); 68 bs0.add(as[1]); 69 bs[0].setAs(bs0); 70 Collection bs1 = new ArrayList (3); 71 bs1.add(as[0]); 72 bs1.add(as[1]); 73 bs1.add(as[2]); 74 bs[1].setAs(bs1); 75 Collection bs2 = new ArrayList (2); 76 bs2.add(as[1]); 77 bs2.add(as[2]); 78 bs[2].setAs(bs2); 79 80 PersistenceManager pm = pmf.getPersistenceManager(); 81 pm.currentTransaction().begin(); 82 pm.makePersistent(as[0]); 83 pm.currentTransaction().commit(); 84 Object [] a_ids = new Object [3]; 85 Object [] b_ids = new Object [3]; 86 for(int i=0; i<as.length; i++) { 87 a_ids[i] = pm.getObjectId(as[i]); 88 b_ids[i] = pm.getObjectId(bs[i]); 89 } 90 as = null; 91 bs = null; 92 pm.close(); 93 94 pm = pmf.getPersistenceManager(); 95 for(int i=0; i<a_ids.length; i++) { 96 Object o = pm.getObjectById(a_ids[i], true); 97 Assert.assertNotNull(o); 98 pm.currentTransaction().begin(); 99 pm.deletePersistent(o); 100 o = pm.getObjectById(b_ids[i], true); 101 Assert.assertNotNull(o); 102 pm.deletePersistent(o); 103 pm.currentTransaction().commit(); 104 } 105 pm.close(); 106 } 107 } 108 | Popular Tags |