01: /**
02: * Copyright (C) 2001-2004 France Telecom R&D
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * 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: */package org.objectweb.speedo.runtime.collection;
18:
19: import org.objectweb.speedo.SpeedoTestHelper;
20: import org.objectweb.speedo.pobjects.collection.AMMB;
21: import org.objectweb.speedo.pobjects.collection.BMMB;
22: import org.objectweb.util.monolog.api.BasicLevel;
23:
24: import javax.jdo.PersistenceManager;
25:
26: import junit.framework.Assert;
27:
28: import java.util.Collection;
29: import java.util.Iterator;
30:
31: /**
32: *
33: * @author S.Chassande-Barrioz
34: */
35: public class TestLoadMNB extends SpeedoTestHelper {
36:
37: public TestLoadMNB(String s) {
38: super (s);
39: }
40:
41: protected String getLoggerName() {
42: return LOG_NAME + ".rt.collection.TestLoadMNB";
43: }
44:
45: public void test1() {
46: PersistenceManager pm = pmf.getPersistenceManager();
47: pm.currentTransaction().begin();
48: Object oid = pm.newObjectIdInstance(AMMB.class, "1230");
49: Assert.assertNotNull("null oid !", oid);
50: AMMB a = (AMMB) pm.getObjectById(oid, false);
51: Assert.assertNotNull("null AMMB object", a);
52: Collection bs = a.getBs();
53: Assert.assertNotNull("null collection of BMMB", bs);
54: Iterator it = bs.iterator();
55: while (it.hasNext()) {
56: BMMB b = (BMMB) it.next();
57: Assert.assertNotNull("null element collection of BMMB", b);
58: logger.log(BasicLevel.DEBUG, "idb: " + b.getIdb());
59: it.remove();
60: b.getAs().remove(a);
61: pm.deletePersistent(b);
62: }
63: pm.deletePersistent(a);
64: pm.currentTransaction().commit();
65: pm.close();
66: }
67: }
|