mirror of https://github.com/apache/openjpa.git
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:
parent
2f648350b4
commit
58d1f4966a
|
@ -76,10 +76,18 @@ public abstract class AbstractCachedEMFTestCase extends AbstractPersistenceTestC
|
||||||
@Override
|
@Override
|
||||||
protected boolean removeEldestEntry(Map.Entry<K,V> entry) {
|
protected boolean removeEldestEntry(Map.Entry<K,V> entry) {
|
||||||
OpenJPAEntityManagerFactorySPI oemf = (OpenJPAEntityManagerFactorySPI)entry.getValue();
|
OpenJPAEntityManagerFactorySPI oemf = (OpenJPAEntityManagerFactorySPI)entry.getValue();
|
||||||
// if (oemf != null && oemf.isOpen()) {
|
if (this.size() > 2) {
|
||||||
// oemf.close();
|
// if the eldest should be removed, then try to close it first
|
||||||
// }
|
if (oemf != null && oemf.isOpen()) {
|
||||||
return this.size() > 2;
|
try {
|
||||||
|
oemf.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// no-op - eat it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ public abstract class SingleEMFTestCase
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
closeEMF(emf);
|
closeEMF(emf);
|
||||||
|
emf = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue