1 7 package com.genimen.djeneric.test; 8 9 import junit.framework.TestCase; 10 11 import com.genimen.djeneric.repository.DjPersistenceManager; 12 import com.genimen.djeneric.repository.DjPersistenceManagerFactory; 13 import com.genimen.djeneric.repository.DjSession; 14 import com.genimen.djeneric.repository.exceptions.DjenericException; 15 16 19 public class TestCreateSession extends TestCase 20 { 21 22 26 public TestCreateSession(String arg0) 27 { 28 super(arg0); 29 } 30 31 public void testCreateSession() throws DjenericException 32 { 33 DjPersistenceManagerFactory factory = new DjPersistenceManagerFactory(getClass() 34 .getResourceAsStream("repositories.xml")); 35 DjPersistenceManager mgr = factory.createInstance("test"); 36 mgr.setCurrentContext("dflt"); 37 38 DjSession session = mgr.createSession(); 39 session.close(); 40 mgr.close(); 41 } 42 43 public void testBulkSessions() throws DjenericException 44 { 45 DjPersistenceManagerFactory factory = new DjPersistenceManagerFactory(getClass() 46 .getResourceAsStream("repositories.xml")); 47 DjPersistenceManager mgr = factory.createInstance("test"); 48 mgr.setCurrentContext("dflt"); 49 50 int COUNT = 25; 51 52 for (int i = 0; i < COUNT; i++) 53 { 54 DjSession session = mgr.createSession(); 55 session.close(); 56 } 57 System.out.println(COUNT + " sessions (created and closed)"); 58 59 DjSession sessions[] = new DjSession[COUNT]; 60 for (int i = 0; i < COUNT; i++) 61 { 62 sessions[i] = mgr.createSession(); 63 } 64 65 System.out.println(COUNT + " sessions opened"); 66 for (int i = 0; i < COUNT; i++) 67 { 68 sessions[i].close(); 69 } 70 71 System.out.println(COUNT + " sessions closed"); 72 73 mgr.close(); 74 System.out.println("Manager closed"); 75 } 76 77 } | Popular Tags |