}
@Test
public void testExpiration() throws Exception {
int period = 15000;
ExpirationManager expirationManager = _server.getExpirationManager();
expirationManager.stop();
expirationManager.setCheckPeriod(15000);
expirationManager.setTimeoutExtension(15000);
expirationManager.start();
final AtomicInteger combinedSubs = countSubscriptions(_server);
final AtomicInteger fakeSubs = countSubscriptions(_server.getFakeServer());
final AtomicInteger realSubs = countSubscriptions(_server.getRealServer());
ExternalId weak = ExternalId.of(ExternalSchemes.BLOOMBERG_TICKER_WEAK, "GBP Curncy");
List<ExternalId> instruments = Lists.newArrayList(weak);
CollectingLiveDataListener listener = new CollectingLiveDataListener(1, 1);
subscribe(_liveDataClient, listener, instruments);
assertEquals(1, combinedSubs.get());
assertEquals(combinedSubs.get(), fakeSubs.get());
assertEquals(0, realSubs.get());
assertTrue(listener.waitUntilEnoughUpdatesReceived(30000));
for (int i = 0; i < 3; i++) {
expirationManager.extendPublicationTimeout(ImmutableSet.of(getLiveDataSpec(_liveDataClient, weak)));
Thread.sleep(period / 2);
}
assertEquals(1, combinedSubs.get());
assertEquals(combinedSubs.get(), fakeSubs.get());
assertEquals(0, realSubs.get());