diff options
author | Jim Hahn <jrh3@att.com> | 2018-06-21 16:23:19 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2018-06-21 17:17:10 -0400 |
commit | 9afa523e5147c971a0d8d0405361f3c3e8faa6ce (patch) | |
tree | 05566af1d59b8da6338435384a0fed481c76b179 /integrity-audit/src/test/java/org/onap/policy/common/ia/DbDAOTest.java | |
parent | ec62d8d34ae4724b81d29f6314951c277f423ba4 (diff) |
IntegrityAuditor: remove sleep from junit tests
Modified the code to use a CurrentTime object for its "time" operations
(e.g., sleep(), currentTimeInMillis()). Modified junit tests to replace
the CurrentTime object with TestTime objects so they don't actually
do any sleeping.
Reformat "commit" message.
Remove TODO from junit test.
Init testTime in junit setUp().
Add AuditorTime and test classes.
Change "latch" to "semaphore" in comments.
Change time units in junit test from SECONDS to MILLISECONDS.
Add sleep() method to auditor test class.
Reorder field qualifiers.
Change utils scope to "compile" in pom.
Change-Id: I8aa8b642b315156c00422192e4aa8e47b4503c2f
Issue-ID: POLICY-908
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'integrity-audit/src/test/java/org/onap/policy/common/ia/DbDAOTest.java')
-rw-r--r-- | integrity-audit/src/test/java/org/onap/policy/common/ia/DbDAOTest.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDAOTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDAOTest.java index 01e2f2b0..6e93529c 100644 --- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDAOTest.java +++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDAOTest.java @@ -52,6 +52,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.common.ia.jpa.IntegrityAuditEntity; import org.onap.policy.common.utils.jpa.EntityTransCloser; +import org.onap.policy.common.utils.time.TestTime; /* * All JUnits are designed to run in the local development environment @@ -273,6 +274,8 @@ public class DbDAOTest extends IntegrityAuditTestBase { Properties properties = makeProperties(); try (EntityTransCloser et = new EntityTransCloser(em.getTransaction())) { + TestTime testTime = getTestTime(); + // Create an entry dbDao = new DbDAO(resourceName, A_SEQ_PU, properties); @@ -296,10 +299,10 @@ public class DbDAOTest extends IntegrityAuditTestBase { final Date oldDate = iae.getLastUpdated(); // ensure dates are different by sleeping for a bit - Thread.sleep(1); + testTime.sleep(1); iae.setSite("SiteB"); - iae.setLastUpdated(new Date()); + iae.setLastUpdated(testTime.getDate()); final Date newDate = iae.getLastUpdated(); em.persist(iae); |