1 5 6 package org.apache.ojb.broker.sqlcount; 7 8 import org.apache.ojb.broker.Identity; 9 import org.apache.ojb.broker.PersistenceBroker; 10 import org.apache.ojb.broker.PersistenceBrokerFactory; 11 import org.apache.ojb.broker.cloneable.CloneableGroup; 12 import org.apache.ojb.broker.util.configuration.impl.OjbConfiguration; 13 import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator; 14 15 19 public class TwoLevelSimpleTest extends AbstractCountTest 20 { 21 private Class old_ObjectCache; 22 private String [] old_CacheFilter; 23 24 private OjbConfiguration getConfig() 25 { 26 return (OjbConfiguration) OjbConfigurator.getInstance().getConfigurationFor(null); 27 } 28 32 protected void setUp() throws Exception 33 { 34 super.setUp(); 37 } 40 41 45 protected void tearDown() throws Exception 46 { 47 super.tearDown(); 50 } 51 52 55 public void testAccessArticleTwice() 56 { 57 PersistenceBroker pb0, pb1; 58 pb0 = PersistenceBrokerFactory.defaultPersistenceBroker(); 59 pb1 = PersistenceBrokerFactory.defaultPersistenceBroker(); 60 assertNotSame(pb0, pb1); 61 62 resetStmtCount(); 63 pb0.clearCache(); 64 pb0.beginTransaction(); 65 Identity id = new Identity(null, CloneableGroup.class, new Object [] {new Integer (1)}); 66 logger.info(id.toString()); 67 assertNull(id.getObjectsRealClass()); 68 Object group0 = pb0.getObjectByIdentity(id); 69 assertNotNull(group0); 70 assertEquals(CloneableGroup.class, id.getObjectsRealClass()); 71 assertStmtCount("access one group", 1); 72 pb0.commitTransaction(); 73 74 resetStmtCount(); 75 pb1.beginTransaction(); 76 Object group1 = pb1.getObjectByIdentity(id); 77 assertStmtCount("access one group again", 0); assertNotSame(group0, group1); 79 pb1.commitTransaction(); 80 } 81 } 82 | Popular Tags |