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.userid;
18:
19: import org.objectweb.speedo.SpeedoTestHelper;
20: import org.objectweb.speedo.pobjects.userid.IntervenantHelper;
21: import org.objectweb.speedo.pobjects.userid.ConventionHelper;
22: import org.objectweb.util.monolog.api.BasicLevel;
23:
24: import javax.jdo.PersistenceManager;
25: import java.util.ArrayList;
26: import java.util.Calendar;
27:
28: /**
29: *
30: * @author S.Chassande-Barrioz
31: */
32: public class TestGroupama extends SpeedoTestHelper {
33:
34: public TestGroupama(String s) {
35: super (s);
36: }
37:
38: protected String getLoggerName() {
39: return LOG_NAME + "rt.userid.groupama";
40: }
41:
42: public void testA() {
43: try {
44: PersistenceManager pm = pmf.getPersistenceManager();
45: pm.currentTransaction().begin();
46: for (int i = 0; i < 5; i++) {
47: IntervenantHelper ih = new IntervenantHelper();
48: ih.setNomep(i);
49: ih.setConventions(new ArrayList());
50: for (int j = 0; j < i; j++) {
51: ConventionHelper ch = new ConventionHelper();
52: ch.setCdmec("cdmec" + i + "_" + j);
53: ch.setCdmem("cdmem" + i + "_" + j);
54: ch.setCdmed("cdmed" + i + "_" + j);
55: ch.setNomep(i);
56: ch.setIntervenant(ih);
57: ch.setDdmec(Calendar.getInstance().getTime());
58: ch.setCdmese("cdmese" + i + "_" + j);
59: ih.getConventions().add(ch);
60: }
61: pm.makePersistent(ih);
62: }
63: pm.currentTransaction().commit();
64:
65: pm.evictAll(); //clear the L2 cache
66:
67: pm.currentTransaction().begin();
68: IntervenantHelper ih = (IntervenantHelper) pm
69: .getObjectById(pm.newObjectIdInstance(
70: IntervenantHelper.class, "" + 2), false);
71: assertEquals("Bad convention elements in collection", 2, ih
72: .getConventions().size());
73: pm.close();
74: deleteAllInstances(IntervenantHelper.class);
75: deleteAllInstances(ConventionHelper.class);
76: } catch (Exception e) {
77: logger.log(BasicLevel.ERROR, "Exception", e);
78: fail(e.getMessage());
79: }
80: }
81:
82: }
|