1 10 11 package com.triactive.jdo.test; 12 13 import java.util.Iterator ; 14 import javax.jdo.PersistenceManager; 15 import javax.jdo.Transaction; 16 import javax.jdo.Extent; 17 18 19 25 public class ExtentTest extends PersistenceTestCase 26 { 27 protected boolean schemaInitialized = false; 28 29 34 public ExtentTest(String name) 35 { 36 super(name); 37 } 38 39 40 protected void setUp() throws Exception 41 { 42 super.setUp(); 43 44 if (!schemaInitialized) 45 { 46 addClassesToSchema(new Class [] 47 { 48 Widget.class, 49 } 50 ); 51 schemaInitialized = true; 52 } 53 } 54 55 56 public void testCloseAll() throws Exception 57 { 58 PersistenceManager pm = pmf.getPersistenceManager(); 59 Transaction tx = pm.currentTransaction(); 60 try 61 { 62 tx.begin(); 63 Extent ex = pm.getExtent( Widget.class, false ); 64 65 ex.closeAll(); 67 Iterator i = ex.iterator(); 68 ex.closeAll(); assertEquals( "iterator.hasNext() after extent.closeAll", false, i.hasNext() ); 70 71 ex.iterator(); 72 ex.iterator(); 73 ex.closeAll(); 75 tx.commit(); 76 } 77 finally 78 { 79 if (tx.isActive()) 80 tx.rollback(); 81 82 pm.close(); 83 } 84 } 85 } 86 | Popular Tags |