HostRegistryImpl implements HostRegistry { public void init() { hosts = CacheBuilder.newBuilder(). expireAfterAccess( HOST_EXPIRATION_SEC, TimeUnit.SECONDS ). removalListener( new RemovalListener<String, ResourceHostInfo>() { @Override public void onRemoval( final RemovalNotification<String, ResourceHostInfo> notification ) { if ( notification.getCause() == RemovalCause.EXPIRED ) { for ( HostListener listener : hostListeners ) { threadPool.execute( new HostNotifier( listener, notification.getValue() ) ); } } } } ). build(); hostUpdater.scheduleWithFixedDelay( new Runnable() { @Override public void run() { updateHosts(); } }, HOST_UPDATER_INTERVAL_SEC, HOST_UPDATER_INTERVAL_SEC, TimeUnit.SECONDS ); }  @Override void updateResourceHostEntryTimestamp( final String resourceHostId ); @Override ContainerHostInfo getContainerHostInfoById( final String id ); @Override ContainerHostInfo getContainerHostInfoByHostname( final String hostname ); @Override ContainerHostInfo getContainerHostInfoByContainerName( final String containerName ); @Override Set<ContainerHostInfo> getContainerHostsInfo(); @Override ResourceHostInfo getResourceHostInfoById( final String id ); @Override ResourceHostInfo getResourceHostInfoByHostname( final String hostname ); @Override Set<ResourceHostInfo> getResourceHostsInfo(); @Override ResourceHostInfo getResourceHostByContainerHost( final ContainerHostInfo containerHostInfo ); @Override HostInfo getHostInfoById( final String hostId ); @Override void removeResourceHost( final String id ); @Override void addHostListener( final HostListener listener ); @Override void removeHostListener( final HostListener listener ); void init(); void dispose(); @Override boolean pingHost( String hostIp );  }
@Test public void testInit() throws Exception { registry.init(); verify( hostUpdater ) .scheduleWithFixedDelay( any( Runnable.class ), anyLong(), anyLong(), any( TimeUnit.class ) ); assertNotSame( hosts, registry.hosts ); }