Examples of JDBCFetchPlan


Examples of org.apache.openjpa.persistence.jdbc.JDBCFetchPlan

    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();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.