1 16 17 package org.springframework.orm.ojb.support; 18 19 import java.util.ArrayList ; 20 import java.util.List ; 21 22 import junit.framework.TestCase; 23 import org.apache.ojb.broker.PersistenceBrokerFactory; 24 25 import org.springframework.orm.ojb.PersistenceBrokerTemplate; 26 27 31 public class PersistenceBrokerDaoSupportTests extends TestCase { 32 33 public void testWithDefaultSettings() throws Exception { 34 final List test = new ArrayList (); 35 PersistenceBrokerDaoSupport dao = new PersistenceBrokerDaoSupport() { 36 protected void initDao() { 37 test.add("test"); 38 } 39 }; 40 dao.afterPropertiesSet(); 41 assertEquals(PersistenceBrokerFactory.getDefaultKey(), dao.getPersistenceBrokerTemplate().getPbKey()); 42 assertEquals("initDao called", test.size(), 1); 43 } 44 45 public void testWithJcdAlias() throws Exception { 46 final List test = new ArrayList (); 47 PersistenceBrokerDaoSupport dao = new PersistenceBrokerDaoSupport() { 48 protected void initDao() { 49 test.add("test"); 50 } 51 }; 52 dao.setJcdAlias("alias1"); 53 dao.afterPropertiesSet(); 54 assertEquals("alias1", dao.getPersistenceBrokerTemplate().getJcdAlias()); 55 assertEquals("initDao called", test.size(), 1); 56 } 57 58 public void testWithPersistenceBrokerTemplate() throws Exception { 59 PersistenceBrokerTemplate template = new PersistenceBrokerTemplate(); 60 final List test = new ArrayList (); 61 PersistenceBrokerDaoSupport dao = new PersistenceBrokerDaoSupport() { 62 protected void initDao() { 63 test.add("test"); 64 } 65 }; 66 dao.setPersistenceBrokerTemplate(template); 67 dao.afterPropertiesSet(); 68 assertEquals("Correct PersistenceBrokerTemplate", template, dao.getPersistenceBrokerTemplate()); 69 assertEquals("initDao called", test.size(), 1); 70 } 71 72 } 73 | Popular Tags |