OPENJPA-878 Committing code and test updates contributed by Donald Woods.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@755818 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jeremy Bauer 2009-03-19 02:54:29 +00:00
parent 2edc92d97f
commit bb1bc8a39d
1 changed files with 21 additions and 17 deletions
openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query

View File

@ -142,8 +142,6 @@ public class TestQueryTimeout extends SQLListenerTestCase {
* Expected Results: The DELAY function is being called and the query takes * Expected Results: The DELAY function is being called and the query takes
* 6000+ msecs to complete. * 6000+ msecs to complete.
*/ */
@AllowFailure(value=true, message="FIXME - The runtime >= 6K assertion " +
"in this test fails intermittently and needs to be corrected.")
public void testQueryTimeout1a() { public void testQueryTimeout1a() {
if (skipTests) { if (skipTests) {
return; return;
@ -165,9 +163,10 @@ public class TestQueryTimeout extends SQLListenerTestCase {
long runTime = endTime - startTime; long runTime = endTime - startTime;
getLog().trace("testQueryTimeout1a() - NoHintList runTime" + getLog().trace("testQueryTimeout1a() - NoHintList runTime" +
" msecs=" + runTime); " msecs=" + runTime);
assertTrue("Should have taken 6000+ msecs", runTime >= 6000); // Hack - Windows sometimes returns 5999 instead of 6000+
assertEquals("Verify we found the expected number of results.", assertTrue("Should have taken 6+ secs, but was msecs=" +
2, results.size()); runTime, runTime > 5900);
assertEquals("Verify we found 2 results.", 2, results.size());
} catch (Exception e) { } catch (Exception e) {
fail("Unexpected testQueryTimeout1a() exception = " + e); fail("Unexpected testQueryTimeout1a() exception = " + e);
} }
@ -203,7 +202,9 @@ public class TestQueryTimeout extends SQLListenerTestCase {
long runTime = endTime - startTime; long runTime = endTime - startTime;
getLog().trace("testQueryTimeout1c() - EM find/update runTime" + getLog().trace("testQueryTimeout1c() - EM find/update runTime" +
" msecs=" + runTime); " msecs=" + runTime);
assertTrue("Should have taken 2000+ msecs", runTime >= 2000); // Hack - Windows sometimes returns 1999 instead of 2000+
assertTrue("Should have taken 2+ secs, but was msecs=" +
runTime, runTime > 1900);
em.clear(); em.clear();
qt = em.find(QTimeout.class, new Integer(1)); qt = em.find(QTimeout.class, new Integer(1));
assertEquals("Verify the entity was updated.", assertEquals("Verify the entity was updated.",
@ -224,8 +225,6 @@ public class TestQueryTimeout extends SQLListenerTestCase {
* Expected Results: The DELAY function is being called and the query * Expected Results: The DELAY function is being called and the query
* takes 6000+ msecs to complete. * takes 6000+ msecs to complete.
*/ */
@AllowFailure(value=true, message="FIXME - The runtime >= 6K assertion " +
"in this test fails intermittently and needs to be corrected.")
public void testQueryTimeout2a() { public void testQueryTimeout2a() {
if (skipTests) { if (skipTests) {
return; return;
@ -253,9 +252,10 @@ public class TestQueryTimeout extends SQLListenerTestCase {
long runTime = endTime - startTime; long runTime = endTime - startTime;
getLog().trace("testQueryTimeout2a() - Hint0msec runTime msecs=" getLog().trace("testQueryTimeout2a() - Hint0msec runTime msecs="
+ runTime); + runTime);
assertTrue("Should have taken 6000+ msecs", runTime >= 6000); // Hack - Windows sometimes returns 5999 instead of 6000+
assertEquals("Verify we found the expected number of results.", assertTrue("Should have taken 6+ secs, but was msecs=" +
2, results.size()); runTime, runTime > 5900);
assertEquals("Verify we found 2 results.", 2, results.size());
} catch (Exception e) { } catch (Exception e) {
fail("Unexpected testQueryTimeout2a() exception = " + e); fail("Unexpected testQueryTimeout2a() exception = " + e);
} }
@ -307,7 +307,9 @@ public class TestQueryTimeout extends SQLListenerTestCase {
long runTime = endTime - startTime; long runTime = endTime - startTime;
getLog().trace("testQueryTimeout2b() - NoHintSingle runTime " + getLog().trace("testQueryTimeout2b() - NoHintSingle runTime " +
"msecs=" + runTime); "msecs=" + runTime);
assertTrue("Should have taken 2000+ msecs", runTime >= 2000); // Hack - Windows sometimes returns 1999 instead of 2000+
assertTrue("Should have taken 2+ secs, but was msecs=" +
runTime, runTime > 1900);
assertNotNull("Verify we received a result.", result); assertNotNull("Verify we received a result.", result);
} catch (Exception e) { } catch (Exception e) {
fail("Unexpected testQueryTimeout2b() exception = " + e); fail("Unexpected testQueryTimeout2b() exception = " + e);
@ -359,8 +361,8 @@ public class TestQueryTimeout extends SQLListenerTestCase {
//assertEquals("Should never get valid results due to the " + //assertEquals("Should never get valid results due to the " +
// "timeout.", 2, results.size()); // "timeout.", 2, results.size());
fail("QueryTimeout annotation failed to cause an Exception " + fail("QueryTimeout annotation failed to cause an Exception " +
"in testQueryTimeout3a(" "in testQueryTimeout3a(" + setTime +
+ setTime + " msecs), runTime msecs=" + runTime); " msecs), runTime msecs=" + runTime);
} catch (Exception e) { } catch (Exception e) {
// expected // expected
checkException("testQueryTimeout3a()", e); checkException("testQueryTimeout3a()", e);
@ -414,8 +416,8 @@ public class TestQueryTimeout extends SQLListenerTestCase {
+ runTime); + runTime);
//assertNull("Should never get valid result due to the timeout.", result); //assertNull("Should never get valid result due to the timeout.", result);
fail("QueryTimeout annotation failed to cause an Exception " + fail("QueryTimeout annotation failed to cause an Exception " +
"in testQueryTimeout3b(" "in testQueryTimeout3b(" + setTime +
+ setTime + " mscs), runTime msecs=" + runTime); " mscs), runTime msecs=" + runTime);
} catch (Exception e) { } catch (Exception e) {
// expected // expected
checkException("testQueryTimeout3b()", e); checkException("testQueryTimeout3b()", e);
@ -471,7 +473,9 @@ public class TestQueryTimeout extends SQLListenerTestCase {
getLog().trace( getLog().trace(
"testQueryTimeout4() - NoHintSingle runTime msecs=" "testQueryTimeout4() - NoHintSingle runTime msecs="
+ runTime); + runTime);
assertTrue("Should have taken 2000+ msecs", runTime >= 2000); // Hack - Windows sometimes returns 1999 instead of 2000+
assertTrue("Should have taken 2+ secs, but was msecs=" +
runTime, runTime > 1900);
assertNotNull("Verify we received a result.", result); assertNotNull("Verify we received a result.", result);
} catch (Exception e) { } catch (Exception e) {
fail("Unexpected testQueryTimeout4() exception = " + e); fail("Unexpected testQueryTimeout4() exception = " + e);