diff options
author | Håkon Hallingstad <hakon@oath.com> | 2018-06-22 11:01:22 +0200 |
---|---|---|
committer | Håkon Hallingstad <hakon@oath.com> | 2018-06-22 11:01:22 +0200 |
commit | da8720586341957f15bf6a42b291d879c8569538 (patch) | |
tree | 29bb114ffbc6bb5bdd4a048e53845df00f449e08 /vespajlib/src/test | |
parent | d17e36f062c38550a96ccee3e41d7ff5266efecb (diff) |
set-node-state timeout in CC
Diffstat (limited to 'vespajlib/src/test')
-rw-r--r-- | vespajlib/src/test/java/com/yahoo/time/TimeBudgetTest.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/time/TimeBudgetTest.java b/vespajlib/src/test/java/com/yahoo/time/TimeBudgetTest.java index a51081067b7..f197cc34b32 100644 --- a/vespajlib/src/test/java/com/yahoo/time/TimeBudgetTest.java +++ b/vespajlib/src/test/java/com/yahoo/time/TimeBudgetTest.java @@ -8,8 +8,10 @@ import org.junit.Test; import java.time.Clock; import java.time.Duration; import java.time.Instant; +import java.util.Optional; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; @@ -23,12 +25,12 @@ public class TimeBudgetTest { TimeBudget timeBudget = TimeBudget.fromNow(clock, Duration.ofSeconds(10)); clock.advance(Duration.ofSeconds(7)); - assertEquals(Duration.ofSeconds(3), timeBudget.timeLeftOrThrow()); + assertEquals(Duration.ofSeconds(3), timeBudget.timeLeftOrThrow().get()); // Verify that toMillis() of >=1 is fine, but 0 is not. clock.setInstant(Instant.ofEpochSecond(9, 999000000)); - assertEquals(1, timeBudget.timeLeftOrThrow().toMillis()); + assertEquals(1, timeBudget.timeLeftOrThrow().get().toMillis()); clock.setInstant(Instant.ofEpochSecond(9, 999000001)); try { timeBudget.timeLeftOrThrow(); @@ -37,4 +39,15 @@ public class TimeBudgetTest { // OK } } + + @Test + public void noDeadline() { + ManualClock clock = new ManualClock(); + clock.setInstant(Instant.ofEpochSecond(0)); + TimeBudget timeBudget = TimeBudget.from(clock, clock.instant(), Optional.empty()); + + assertFalse(timeBudget.originalTimeout().isPresent()); + assertFalse(timeBudget.timeLeftOrThrow().isPresent()); + assertFalse(timeBudget.deadline().isPresent()); + } }
\ No newline at end of file |