From af4a14eac1ca05db1b8db000d4bd74aebc0fe14f Mon Sep 17 00:00:00 2001 From: adamw Date: Thu, 2 Jun 2011 07:52:30 +0200 Subject: [PATCH] HHH-5025: waiting max 3 seconds for the cache to be written to disk --- .../integration/cache/HibernateSecLvlQueryCache.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/cache/HibernateSecLvlQueryCache.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/cache/HibernateSecLvlQueryCache.java index 79677dbdc7..a3a399f54b 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/cache/HibernateSecLvlQueryCache.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/cache/HibernateSecLvlQueryCache.java @@ -51,9 +51,15 @@ public class HibernateSecLvlQueryCache extends AbstractSessionTest { .add(new RevisionTypeAuditExpression(RevisionType.ADD, "=")) .setCacheable(true).setCacheRegion(QUERY_CACHE_REGION).getResultList(); - // Waiting for cached data to persist to disk. - Thread.sleep(1000); - + // Waiting max 3 seconds for cached data to persist to disk. + for (int i=0; i<30; i++) { + if (getQueryCacheSize() > 0) { + break; + } + + Thread.sleep(100); + } + Assert.assertTrue(getQueryCacheSize() > 0); }