1 5 6 package org.apache.ojb.broker.sqlcount; 7 8 import org.apache.ojb.broker.CdArticle; 9 import org.apache.ojb.broker.Identity; 10 import org.apache.ojb.broker.InterfaceArticle; 11 import org.apache.ojb.broker.PersistenceBroker; 12 import org.apache.ojb.broker.PersistenceBrokerFactory; 13 import org.apache.ojb.broker.cache.ObjectCacheEmptyImpl; 14 import org.apache.ojb.broker.util.configuration.impl.OjbConfiguration; 15 import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator; 16 17 21 public class EmptyCacheCountTest extends AbstractCountTest 22 { 23 protected PersistenceBroker myPB; 24 25 private Class old_ObjectCache; 26 private String [] old_CacheFilter; 27 28 private OjbConfiguration getConfig() 29 { 30 return (OjbConfiguration) OjbConfigurator.getInstance().getConfigurationFor(null); 31 } 32 33 37 protected void setUp() throws Exception 38 { 39 super.setUp(); 41 myPB = PersistenceBrokerFactory.defaultPersistenceBroker(); 42 } 45 46 50 protected void tearDown() throws Exception 51 { 52 super.tearDown(); 55 } 56 57 60 public void testAccessArticleTwice() 61 { 62 resetStmtCount(); 63 myPB.clearCache(); 64 myPB.beginTransaction(); 65 Identity id = new Identity(null, InterfaceArticle.class, new Object [] {new Integer (200)}); 66 logger.info(id.toString()); 67 assertNull(id.getObjectsRealClass()); 68 myPB.getObjectByIdentity(id); 69 assertEquals(CdArticle.class, id.getObjectsRealClass()); 70 assertStmtCount("access one cd", 1, 3); resetStmtCount(); 72 myPB.getObjectByIdentity(id); 73 assertStmtCount("access one cd again", 1); myPB.commitTransaction(); 75 } 76 } 77 | Popular Tags |