String hintName = "openjpa.jdbc.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, String
.valueOf(ResultSet.TYPE_FORWARD_ONLY), ResultSetType.FORWARD_ONLY,
ResultSet.TYPE_FORWARD_ONLY);
resultSetTypeHintTest(fPlan, fConfig, hintName,
ResultSet.TYPE_FORWARD_ONLY, ResultSetType.FORWARD_ONLY,
ResultSet.TYPE_FORWARD_ONLY);
resultSetTypeHintTest(fPlan, fConfig, hintName, String
.valueOf(ResultSet.TYPE_SCROLL_SENSITIVE),
ResultSetType.SCROLL_SENSITIVE, ResultSet.TYPE_SCROLL_SENSITIVE);
resultSetTypeHintTest(fPlan, fConfig, hintName,
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSetType.SCROLL_SENSITIVE,
ResultSet.TYPE_SCROLL_SENSITIVE);
resultSetTypeHintTest(fPlan, fConfig, hintName, String
.valueOf(ResultSet.TYPE_SCROLL_INSENSITIVE),
ResultSetType.SCROLL_INSENSITIVE,
ResultSet.TYPE_SCROLL_INSENSITIVE);
resultSetTypeHintTest(fPlan, fConfig, hintName,
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSetType.SCROLL_INSENSITIVE,
ResultSet.TYPE_SCROLL_INSENSITIVE);
try {
fPlan.setHint(hintName, "xxxxx", false);
fPlan.setHint(hintName, "yyyyy", true);
fail("Expecting a a IllegalArgumentException.");
} catch (Exception e) {
assertTrue("Caught expected exception",
IllegalArgumentException.class.isAssignableFrom(e.getClass()));
}
try {
fPlan.setHint(hintName, "12345", false);
fPlan.setHint(hintName, "67890", true);
fail("Expecting a a IllegalArgumentException.");
} catch (Exception e) {
assertTrue("Caught expected exception",
IllegalArgumentException.class.isAssignableFrom(e.getClass()));
}
try {
fPlan.setHint(hintName, -1, false);
fPlan.setHint(hintName, -2, true);
fail("Expecting a a IllegalArgumentException.");
} catch (Exception e) {
assertTrue("Caught expected exception",
IllegalArgumentException.class.isAssignableFrom(e.getClass()));
}
try {
fPlan.setHint(hintName, FetchConfiguration.DEFAULT, true);
assertEquals(ResultSet.TYPE_FORWARD_ONLY, fConfig
.getResultSetType());
} catch (Exception e) {
fail("Unexpected " + e.getClass().getName());
}
em.close();