public void testFetchPlanResultSetTypeHint() {
String hintName = "openjpa.FetchPlan.ResultSetType";
EntityManager em = emf.createEntityManager();
OpenJPAEntityManager oem = (OpenJPAEntityManager)em.getDelegate();
JDBCFetchPlan fPlan = (JDBCFetchPlan) oem.getFetchPlan();
JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl)
((EntityManagerImpl) oem).getBroker().getFetchConfiguration();
resultSetTypeHintTest(fPlan, fConfig, hintName,
ResultSetType.FORWARD_ONLY.name(), ResultSetType.FORWARD_ONLY,
ResultSet.TYPE_FORWARD_ONLY);
resultSetTypeHintTest(fPlan, fConfig, hintName,
ResultSetType.FORWARD_ONLY, ResultSetType.FORWARD_ONLY,
ResultSet.TYPE_FORWARD_ONLY);
resultSetTypeHintTest(fPlan, fConfig, hintName,
ResultSetType.SCROLL_SENSITIVE.name(),
ResultSetType.SCROLL_SENSITIVE, ResultSet.TYPE_SCROLL_SENSITIVE);
resultSetTypeHintTest(fPlan, fConfig, hintName,
ResultSetType.SCROLL_SENSITIVE, ResultSetType.SCROLL_SENSITIVE,
ResultSet.TYPE_SCROLL_SENSITIVE);
resultSetTypeHintTest(fPlan, fConfig, hintName,
ResultSetType.SCROLL_INSENSITIVE.name(),
ResultSetType.SCROLL_INSENSITIVE,
ResultSet.TYPE_SCROLL_INSENSITIVE);
resultSetTypeHintTest(fPlan, fConfig, hintName,
ResultSetType.SCROLL_INSENSITIVE, ResultSetType.SCROLL_INSENSITIVE,
ResultSet.TYPE_SCROLL_INSENSITIVE);
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 unexpected exception " + e,
IllegalArgumentException.class.isAssignableFrom(e.getClass()));
}