making test more lenient for our build server

This commit is contained in:
Adrian Cole 2011-02-27 17:29:47 -08:00
parent 3d3770a556
commit 4ec14fc847
1 changed files with 18 additions and 12 deletions

View File

@ -42,20 +42,22 @@ public class RetryablePredicateTest {
Date startPlusThird = new Date(System.currentTimeMillis() + 1000); Date startPlusThird = new Date(System.currentTimeMillis() + 1000);
predicate.apply(""); predicate.apply("");
Date now = new Date(); Date now = new Date();
assert now.compareTo(startPlusThird) < 0 : String.format("%s should be less than %s", now, startPlusThird); assert now.compareTo(startPlusThird) < 0 : String.format("%s should be less than %s", now.getTime(),
startPlusThird.getTime());
} }
@Test @Test
void testAlwaysFalseMillis() { void testAlwaysFalseMillis() {
RetryablePredicate<String> predicate = new RetryablePredicate<String>(Predicates.<String> alwaysFalse(), 3, 1, RetryablePredicate<String> predicate = new RetryablePredicate<String>(Predicates.<String> alwaysFalse(), 3, 1,
TimeUnit.SECONDS); TimeUnit.SECONDS);
Date startPlus3Thirds = new Date(System.currentTimeMillis() + 3000); Date startPlus3Seconds = new Date(System.currentTimeMillis() + 3000);
Date startPlus4Thirds = new Date(System.currentTimeMillis() + 4000); Date startPlus4Seconds = new Date(System.currentTimeMillis() + 4001);
predicate.apply(""); predicate.apply("");
Date now = new Date(); Date now = new Date();
assert now.compareTo(startPlus3Thirds) >= 0 : String.format("%s should be less than %s", startPlus3Thirds, now); assert now.compareTo(startPlus3Seconds) >= 0 : String.format("%s should be less than %s", startPlus3Seconds
assert now.compareTo(startPlus4Thirds) <= 0 : String .getTime(), now.getTime());
.format("%s should be greater than %s", startPlus4Thirds, now); assert now.compareTo(startPlus4Seconds) <= 0 : String.format("%s should be greater than %s", startPlus4Seconds
.getTime(), now.getTime());
} }
@ -75,12 +77,14 @@ public class RetryablePredicateTest {
RetryablePredicate<String> predicate = new RetryablePredicate<String>(new ThirdTimeTrue(), 3, 1, TimeUnit.SECONDS); RetryablePredicate<String> predicate = new RetryablePredicate<String>(new ThirdTimeTrue(), 3, 1, TimeUnit.SECONDS);
Date startPlus = new Date(System.currentTimeMillis() + 1000); Date startPlus = new Date(System.currentTimeMillis() + 1000);
Date startPlus3 = new Date(System.currentTimeMillis() + 3000); Date startPlus3 = new Date(System.currentTimeMillis() + 3001);
predicate.apply(""); predicate.apply("");
Date now = new Date(); Date now = new Date();
assert now.compareTo(startPlus) >= 0 : String.format("%s should be greater than %s", now, startPlus); assert now.compareTo(startPlus) >= 0 : String.format("%s should be greater than %s", now.getTime(), startPlus
assert now.compareTo(startPlus3) <= 0 : String.format("%s should be greater than %s", startPlus3, now); .getTime());
assert now.compareTo(startPlus3) <= 0 : String.format("%s should be greater than %s", startPlus3.getTime(), now
.getTime());
} }
@Test @Test
@ -89,11 +93,13 @@ public class RetryablePredicateTest {
TimeUnit.SECONDS); TimeUnit.SECONDS);
Date startPlus = new Date(System.currentTimeMillis() + 1000); Date startPlus = new Date(System.currentTimeMillis() + 1000);
Date startPlus2 = new Date(System.currentTimeMillis() + 2000); Date startPlus2 = new Date(System.currentTimeMillis() + 2001);
predicate.apply(""); predicate.apply("");
Date now = new Date(); Date now = new Date();
assert now.compareTo(startPlus) >= 0 : String.format("%s should be greater than %s", now, startPlus); assert now.compareTo(startPlus) >= 0 : String.format("%s should be greater than %s", now.getTime(), startPlus
assert now.compareTo(startPlus2) <= 0 : String.format("%s should be greater than %s", startPlus2, now); .getTime());
assert now.compareTo(startPlus2) <= 0 : String.format("%s should be greater than %s", startPlus2.getTime(), now
.getTime());
} }
} }