String hintName = "openjpa.FetchPlan.LRSSize";
EntityManager em = emf.createEntityManager();
OpenJPAEntityManager oem = (OpenJPAEntityManager) em.getDelegate();
JDBCFetchPlan fPlan = (JDBCFetchPlan) oem.getFetchPlan();
JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl)
((EntityManagerImpl) oem).getBroker().getFetchConfiguration();
lrsSizeHintTest(fPlan, fConfig, hintName, String
.valueOf(LRSSizes.SIZE_QUERY), LRSSizeAlgorithm.QUERY,
LRSSizes.SIZE_QUERY);
lrsSizeHintTest(fPlan, fConfig, hintName, LRSSizes.SIZE_QUERY,
LRSSizeAlgorithm.QUERY, LRSSizes.SIZE_QUERY);
lrsSizeHintTest(fPlan, fConfig, hintName, String
.valueOf(LRSSizes.SIZE_LAST), LRSSizeAlgorithm.LAST,
LRSSizes.SIZE_LAST);
lrsSizeHintTest(fPlan, fConfig, hintName, LRSSizes.SIZE_LAST,
LRSSizeAlgorithm.LAST, LRSSizes.SIZE_LAST);
lrsSizeHintTest(fPlan, fConfig, hintName, String
.valueOf(LRSSizes.SIZE_UNKNOWN), LRSSizeAlgorithm.UNKNOWN,
LRSSizes.SIZE_UNKNOWN);
lrsSizeHintTest(fPlan, fConfig, hintName, LRSSizes.SIZE_UNKNOWN,
LRSSizeAlgorithm.UNKNOWN, LRSSizes.SIZE_UNKNOWN);
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, "12345");
fPlan.setHint(hintName, "67890");
fail("Expecting a a IllegalArgumentException.");
} catch (Exception e) {
assertTrue("Caught expected exception",
IllegalArgumentException.class.isAssignableFrom(e.getClass()));
}
try {
fPlan.setHint(hintName, -1);
fPlan.setHint(hintName, -2);
fail("Expecting a a IllegalArgumentException.");
} catch (Exception e) {
assertTrue("Caught expected exception",
IllegalArgumentException.class.isAssignableFrom(e.getClass()));
}
try {
fPlan.setHint(hintName, FetchConfiguration.DEFAULT);
assertEquals(LRSSizeAlgorithm.QUERY, fPlan.getLRSSizeAlgorithm());
assertEquals(LRSSizes.SIZE_QUERY, fPlan.getLRSSize());
assertEquals(LRSSizes.SIZE_QUERY, fConfig.getLRSSize());
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected " + e.getClass().getName());
}
em.close();