make sure tests cleanup EMs and EMFs

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1021802 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald Woods 2010-10-12 15:38:20 +00:00
parent 2f648350b4
commit 58d1f4966a
2 changed files with 13 additions and 4 deletions

View File

@ -76,10 +76,18 @@ public abstract class AbstractCachedEMFTestCase extends AbstractPersistenceTestC
@Override
protected boolean removeEldestEntry(Map.Entry<K,V> entry) {
OpenJPAEntityManagerFactorySPI oemf = (OpenJPAEntityManagerFactorySPI)entry.getValue();
// if (oemf != null && oemf.isOpen()) {
// oemf.close();
// }
return this.size() > 2;
if (this.size() > 2) {
// if the eldest should be removed, then try to close it first
if (oemf != null && oemf.isOpen()) {
try {
oemf.close();
} catch (Exception e) {
// no-op - eat it
}
}
return true;
}
return false;
}
}

View File

@ -85,6 +85,7 @@ public abstract class SingleEMFTestCase
throw e;
} finally {
closeEMF(emf);
emf = null;
}
}