KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * Copyright (C) 2001-2004 France Telecom R&D
3  */

4 package org.objectweb.speedo.runtime.collection;
5
6 import org.objectweb.speedo.SpeedoTestHelper;
7 import org.objectweb.speedo.pobjects.collection.AutoRef;
8
9 import javax.jdo.PersistenceManager;
10 import java.util.Arrays JavaDoc;
11
12 /**
13  *
14  *
15  * @author chassase
16  */

17 public class TestAutoRef extends SpeedoTestHelper {
18
19     /**
20      * @param s
21      */

22     public TestAutoRef(String JavaDoc s) {
23         super(s);
24     }
25
26     /**
27      * @see org.objectweb.speedo.SpeedoTestHelper#getLoggerName()
28      */

29     protected String JavaDoc getLoggerName() {
30         return "TestAutoRef";
31     }
32
33     
34     public void testA() {
35         AutoRef ar1 = new AutoRef("testA_ar1");
36         ar1.setMyRef(new AutoRef("testA_ar2"));
37         ar1.setMyRefs(Arrays.asList(new AutoRef[]{
38                 new AutoRef("testA_ar3"), new AutoRef("testA_ar4")}));
39         PersistenceManager pm = pmf.getPersistenceManager();
40         pm.currentTransaction().begin();
41         pm.makePersistent(ar1);
42         ar1 = null;
43         pm.currentTransaction().commit();
44         pm.evictAll();
45         pm.currentTransaction().begin();
46         ar1 = (AutoRef) pm.getObjectById(
47                 pm.newObjectIdInstance(AutoRef.class, "testA_ar1"), false);
48         pm.deletePersistentAll(ar1.getMyRefs());
49         pm.deletePersistent(ar1.getMyRef());
50         pm.deletePersistent(ar1);
51         pm.currentTransaction().commit();
52         pm.close();
53     }
54 }
55
Popular Tags