public void testLockTimeoutHint() {
String hintName = "openjpa.LockTimeout";
EntityManager em = emf.createEntityManager();
OpenJPAEntityManager oem = (OpenJPAEntityManager)em.getDelegate();
JDBCFetchPlan fPlan = (JDBCFetchPlan) oem.getFetchPlan();
JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl)
((EntityManagerImpl) oem).getBroker().getFetchConfiguration();
lockTimeoutHintTest(fPlan, fConfig, hintName, "-1", -1);
lockTimeoutHintTest(fPlan, fConfig, hintName, -1, -1);
lockTimeoutHintTest(fPlan, fConfig, hintName, "0", 0);
lockTimeoutHintTest(fPlan, fConfig, hintName, 0, 0);
lockTimeoutHintTest(fPlan, fConfig, hintName, "100", 100);
lockTimeoutHintTest(fPlan, fConfig, hintName, 100, 100);
try {
fPlan.setHint(hintName, "xxxxx");
fPlan.setHint(hintName, "yyyyy");
fail("Expecting a a IllegalArgumentException.");
} catch (Exception e) {
assertTrue("Caught expected exception",
IllegalArgumentException.class.isAssignableFrom(e.getClass()));
}
try {
fPlan.setHint(hintName, -2);
fPlan.setHint(hintName, -3);
fail("Expecting a a IllegalArgumentException.");
} catch (Exception e) {
assertTrue("Caught expected exception",
IllegalArgumentException.class.isAssignableFrom(e.getClass()));
}
try {
fPlan.setHint(hintName, FetchConfiguration.DEFAULT);
int defTimeout = fConfig.getContext().getConfiguration()
.getLockTimeout();
assertEquals(defTimeout, fPlan.getLockTimeout());
assertEquals(defTimeout, fConfig.getLockTimeout());
} catch (Exception e) {
fail("Unexpected " + e.getClass().getName());
}
em.close();