Fix test and poller instantiation

This commit is contained in:
goapunk
2018-05-23 14:28:51 +02:00
parent c6b88b51f0
commit 3793cb841b
2 changed files with 8 additions and 10 deletions

View File

@@ -108,6 +108,13 @@ class PluginManagerImpl implements PluginManager, Service {
@Override
public void startService() throws ServiceException {
if (used.getAndSet(true)) throw new IllegalStateException();
// Instantiate the poller
if (pluginConfig.shouldPoll()) {
LOG.info("Starting poller");
Poller poller = new Poller(ioExecutor, scheduler, connectionManager,
connectionRegistry, this, random, clock);
eventBus.addListener(poller);
}
// Instantiate the simplex plugins and start them asynchronously
LOG.info("Starting simplex plugins");
for (SimplexPluginFactory f : pluginConfig.getSimplexFactories()) {
@@ -140,13 +147,6 @@ class PluginManagerImpl implements PluginManager, Service {
ioExecutor.execute(new PluginStarter(d, startLatch));
}
}
// Instantiate the poller
if (pluginConfig.shouldPoll()) {
LOG.info("Starting poller");
Poller poller = new Poller(ioExecutor, scheduler, connectionManager,
connectionRegistry, this, random, clock);
eventBus.addListener(poller);
}
}
@Override

View File

@@ -40,9 +40,7 @@ public class PluginManagerImplTest extends BrambleTestCase {
setThreadingPolicy(new Synchroniser());
}};
Executor ioExecutor = Executors.newSingleThreadExecutor();
RejectedExecutionHandler policy =
new ScheduledThreadPoolExecutor.DiscardPolicy();
ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(1, policy);
ScheduledExecutorService scheduler = context.mock(ScheduledExecutorService.class);
SecureRandom random = new SecureRandom();
Clock clock = context.mock(Clock.class);
EventBus eventBus = context.mock(EventBus.class);