mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Merged IncomingConnectionExecutor and PluginExecutor into IoExecutor.
We don't need two separate executors for long-running IO threads.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package org.briarproject;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.briarproject.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.api.lifecycle.Service;
|
||||
import org.briarproject.api.lifecycle.ShutdownManager;
|
||||
@@ -10,6 +13,7 @@ import com.google.inject.AbstractModule;
|
||||
|
||||
public class TestLifecycleModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(LifecycleManager.class).toInstance(new LifecycleManager() {
|
||||
|
||||
@@ -37,5 +41,7 @@ public class TestLifecycleModule extends AbstractModule {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
bind(Executor.class).annotatedWith(IoExecutor.class).toInstance(
|
||||
Executors.newCachedThreadPool());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class PluginManagerImplTest extends BriarTestCase {
|
||||
public void testStartAndStop() throws Exception {
|
||||
Clock clock = new SystemClock();
|
||||
Mockery context = new Mockery();
|
||||
final Executor pluginExecutor = Executors.newCachedThreadPool();
|
||||
final Executor ioExecutor = Executors.newCachedThreadPool();
|
||||
final SimplexPluginConfig simplexPluginConfig =
|
||||
context.mock(SimplexPluginConfig.class);
|
||||
final DuplexPluginConfig duplexPluginConfig =
|
||||
@@ -116,7 +116,7 @@ public class PluginManagerImplTest extends BriarTestCase {
|
||||
oneOf(simplexPlugin).stop();
|
||||
oneOf(duplexPlugin).stop();
|
||||
}});
|
||||
PluginManagerImpl p = new PluginManagerImpl(pluginExecutor,
|
||||
PluginManagerImpl p = new PluginManagerImpl(ioExecutor,
|
||||
simplexPluginConfig, duplexPluginConfig, clock, db, poller,
|
||||
dispatcher, uiCallback);
|
||||
// Two plugins should be started and stopped
|
||||
|
||||
@@ -15,7 +15,6 @@ import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.TransportProperties;
|
||||
import org.briarproject.api.plugins.duplex.DuplexPluginCallback;
|
||||
import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
@@ -194,8 +193,7 @@ public class ModemPluginTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testPolling() throws Exception {
|
||||
final ExecutorService pluginExecutor =
|
||||
Executors.newSingleThreadExecutor();
|
||||
final ExecutorService ioExecutor = Executors.newSingleThreadExecutor();
|
||||
Mockery context = new Mockery();
|
||||
final ModemFactory modemFactory = context.mock(ModemFactory.class);
|
||||
final SerialPortList serialPortList =
|
||||
@@ -203,7 +201,7 @@ public class ModemPluginTest extends BriarTestCase {
|
||||
final DuplexPluginCallback callback =
|
||||
context.mock(DuplexPluginCallback.class);
|
||||
// Disable shuffling for this test, it confuses jMock
|
||||
final ModemPlugin plugin = new ModemPlugin(pluginExecutor, modemFactory,
|
||||
final ModemPlugin plugin = new ModemPlugin(ioExecutor, modemFactory,
|
||||
serialPortList, callback, 0, 0, 0, false);
|
||||
final Modem modem = context.mock(Modem.class);
|
||||
final TransportProperties local = new TransportProperties();
|
||||
@@ -265,7 +263,7 @@ public class ModemPluginTest extends BriarTestCase {
|
||||
assertTrue(plugin.start());
|
||||
plugin.poll(Collections.<ContactId>emptyList());
|
||||
assertTrue(disposeAction.invoked.await(5, SECONDS));
|
||||
pluginExecutor.shutdown();
|
||||
ioExecutor.shutdown();
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user