Q: What does the plugin manager do? A: It manages plugins.

This commit is contained in:
akwizgran
2011-10-14 14:49:29 +01:00
parent d54ca67fe9
commit 55182528cf
12 changed files with 510 additions and 6 deletions

View File

@@ -26,6 +26,7 @@
<test name='net.sf.briar.i18n.FontManagerTest'/>
<test name='net.sf.briar.i18n.I18nTest'/>
<test name='net.sf.briar.invitation.InvitationWorkerTest'/>
<test name='net.sf.briar.plugins.PluginManagerImplTest'/>
<test name='net.sf.briar.plugins.file.LinuxRemovableDriveFinderTest'/>
<test name='net.sf.briar.plugins.file.MacRemovableDriveFinderTest'/>
<test name='net.sf.briar.plugins.file.PollingRemovableDriveMonitorTest'/>

View File

@@ -0,0 +1,44 @@
package net.sf.briar.plugins;
import java.util.Map;
import java.util.concurrent.Executor;
import junit.framework.TestCase;
import net.sf.briar.api.TransportId;
import net.sf.briar.api.TransportProperties;
import net.sf.briar.api.db.DatabaseComponent;
import net.sf.briar.api.transport.ConnectionDispatcher;
import net.sf.briar.api.ui.UiCallback;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.junit.Test;
public class PluginManagerImplTest extends TestCase {
@Test
public void testStartAndStop() throws Exception {
Mockery context = new Mockery();
final DatabaseComponent db = context.mock(DatabaseComponent.class);
final Map<?, ?> localTransports = context.mock(Map.class);
final ConnectionDispatcher dispatcher =
context.mock(ConnectionDispatcher.class);
final UiCallback uiCallback = context.mock(UiCallback.class);
context.checking(new Expectations() {{
allowing(db).getLocalTransports();
will(returnValue(localTransports));
allowing(localTransports).get(with(any(TransportId.class)));
will(returnValue(new TransportProperties()));
allowing(db).getRemoteProperties(with(any(TransportId.class)));
will(returnValue(new TransportProperties()));
}});
Executor executor = new ImmediateExecutor();
Poller poller = new PollerImpl();
PluginManagerImpl p =
new PluginManagerImpl(executor, db, poller, dispatcher, uiCallback);
// The Bluetooth plugin will not start without a Bluetooth device, so
// we expect two plugins to be started
assertEquals(2, p.startPlugins());
assertEquals(2, p.stopPlugins());
}
}