KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > runtime > collection > TestLoadMNB


1 /**
2  * Copyright (C) 2001-2004 France Telecom R&D
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

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 JavaDoc;
30 import java.util.Iterator JavaDoc;
31
32 /**
33  *
34  * @author S.Chassande-Barrioz
35  */

36 public class TestLoadMNB extends SpeedoTestHelper {
37
38     public TestLoadMNB(String JavaDoc s) {
39         super(s);
40     }
41
42     protected String JavaDoc 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 JavaDoc 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 JavaDoc bs = a.getBs();
54         Assert.assertNotNull("null collection of BMMB", bs);
55         Iterator JavaDoc 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