@Override protected TimestampManagementService getTimestampManagementService() { return getSingletonTimestampService(); }
private void getTimestampAndIgnoreErrors() { try { getTimestampService().getFreshTimestamp(); } catch (Exception e) { // expected } } }
@Test public void shouldNotTryToStoreANewBoundIfMultipleServicesAreRunning() { timestampBoundStore.pretendMultipleServersAreRunning(); getTimestampAndIgnoreErrors(); getTimestampAndIgnoreErrors(); assertThat(timestampBoundStore.numberOfAllocations(), is(lessThan(2))); }
@Test(expected = IllegalArgumentException.class) public void shouldRejectFastForwardToTheSentinelValue() { getTimestampManagementService().fastForwardTimestamp(TimestampManagementService.SENTINEL_TIMESTAMP); }
@Test(expected = ServiceNotAvailableException.class) public void throwsAserviceNotAvailableExceptionIfThereAreMultipleServersRunning() { timestampBoundStore.pretendMultipleServersAreRunning(); getTimestampService().getFreshTimestamp(); }
@Test public void shouldRethrowAllocationExceptions() { final IllegalArgumentException failure = new IllegalArgumentException(); exception.expect(RuntimeException.class); exception.expectCause(is(failure)); timestampBoundStore.failWith(failure); getTimestampService().getFreshTimestamp(); }
@Override protected TimestampService getTimestampService() { return getSingletonTimestampService(); }