1 16 17 package org.springframework.orm.jdo.support; 18 19 import java.util.ArrayList ; 20 import java.util.List ; 21 22 import javax.jdo.PersistenceManagerFactory; 23 24 import junit.framework.TestCase; 25 import org.easymock.MockControl; 26 27 import org.springframework.orm.jdo.JdoTemplate; 28 29 33 public class JdoDaoSupportTests extends TestCase { 34 35 public void testJdoDaoSupportWithPersistenceManagerFactory() throws Exception { 36 MockControl pmfControl = MockControl.createControl(PersistenceManagerFactory.class); 37 PersistenceManagerFactory pmf = (PersistenceManagerFactory) pmfControl.getMock(); 38 pmfControl.replay(); 39 final List test = new ArrayList (); 40 JdoDaoSupport dao = new JdoDaoSupport() { 41 protected void initDao() { 42 test.add("test"); 43 } 44 }; 45 dao.setPersistenceManagerFactory(pmf); 46 dao.afterPropertiesSet(); 47 assertEquals("Correct PersistenceManagerFactory", pmf, dao.getPersistenceManagerFactory()); 48 assertEquals("Correct JdoTemplate", pmf, dao.getJdoTemplate().getPersistenceManagerFactory()); 49 assertEquals("initDao called", test.size(), 1); 50 pmfControl.verify(); 51 } 52 53 public void testJdoDaoSupportWithJdoTemplate() throws Exception { 54 JdoTemplate template = new JdoTemplate(); 55 final List test = new ArrayList (); 56 JdoDaoSupport dao = new JdoDaoSupport() { 57 protected void initDao() { 58 test.add("test"); 59 } 60 }; 61 dao.setJdoTemplate(template); 62 dao.afterPropertiesSet(); 63 assertEquals("Correct JdoTemplate", template, dao.getJdoTemplate()); 64 assertEquals("initDao called", test.size(), 1); 65 } 66 67 } 68 | Popular Tags |