* persistence managers.
*/
public void testFactoryLifecycleListeners() {
OpenJPAEntityManagerFactory pmf =
(OpenJPAEntityManagerFactory) getEmf();
OpenJPAEntityManagerFactorySPI pmfSPI =
((OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.cast(pmf));
//FIXME jthomas
LoadListener listener = new LoadListener() {
public void afterLoad(LifecycleEvent ev) {
}
public void afterRefresh(LifecycleEvent ev) {
}
};
pmfSPI
.addLifecycleListener(listener, new Class[]{ RuntimeTest4.class });
try {
BrokerImpl broker = (BrokerImpl) JPAFacadeHelper.toBroker
(pmf.createEntityManager());
MetaDataRepository repos = broker.getConfiguration().
getMetaDataRepositoryInstance();
assertTrue("no listeners defined added to Runtimetest4",
broker.getLifecycleEventManager().hasLoadListeners(
new RuntimeTest4("foo"),
repos.getMetaData(RuntimeTest4.class, null, true)));
assertFalse("there should be listeners def for runtimetest1",
broker.getLifecycleEventManager().hasLoadListeners
(new RuntimeTest1(), repos.getMetaData
(RuntimeTest1.class, null, true)));
broker.close();
} finally {
pmfSPI.removeLifecycleListener(listener);
}
}