Skip to content
Snippets Groups Projects
Commit 77b2fa8a authored by Torsten Grote's avatar Torsten Grote
Browse files

Merge branch '832-fix-bridge-test' into 'master'

Fix Tor bridge integration test

See merge request briar/briar!875
parents 1de6c863 f9d58733
No related branches found
No related tags found
No related merge requests found
...@@ -3,14 +3,15 @@ package org.briarproject.bramble.plugin.tor; ...@@ -3,14 +3,15 @@ package org.briarproject.bramble.plugin.tor;
import android.content.Context; import android.content.Context;
import android.support.test.runner.AndroidJUnit4; import android.support.test.runner.AndroidJUnit4;
import org.briarproject.bramble.DaggerIntegrationTestComponent;
import org.briarproject.bramble.IntegrationTestComponent;
import org.briarproject.bramble.api.event.EventBus; import org.briarproject.bramble.api.event.EventBus;
import org.briarproject.bramble.api.network.NetworkManager;
import org.briarproject.bramble.api.plugin.BackoffFactory; import org.briarproject.bramble.api.plugin.BackoffFactory;
import org.briarproject.bramble.api.plugin.duplex.DuplexPlugin; import org.briarproject.bramble.api.plugin.duplex.DuplexPlugin;
import org.briarproject.bramble.api.system.Clock; import org.briarproject.bramble.api.system.Clock;
import org.briarproject.bramble.api.system.LocationUtils; import org.briarproject.bramble.api.system.LocationUtils;
import org.briarproject.bramble.test.BrambleAndroidIntegrationTestComponent;
import org.briarproject.bramble.test.BrambleTestCase; import org.briarproject.bramble.test.BrambleTestCase;
import org.briarproject.bramble.test.DaggerBrambleAndroidIntegrationTestComponent;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -41,6 +42,8 @@ public class BridgeTest extends BrambleTestCase { ...@@ -41,6 +42,8 @@ public class BridgeTest extends BrambleTestCase {
private final static Logger LOG = private final static Logger LOG =
Logger.getLogger(BridgeTest.class.getSimpleName()); Logger.getLogger(BridgeTest.class.getSimpleName());
@Inject
NetworkManager networkManager;
@Inject @Inject
EventBus eventBus; EventBus eventBus;
@Inject @Inject
...@@ -77,8 +80,8 @@ public class BridgeTest extends BrambleTestCase { ...@@ -77,8 +80,8 @@ public class BridgeTest extends BrambleTestCase {
@Before @Before
public void setUp() { public void setUp() {
IntegrationTestComponent component = BrambleAndroidIntegrationTestComponent component =
DaggerIntegrationTestComponent.builder().build(); DaggerBrambleAndroidIntegrationTestComponent.builder().build();
component.inject(this); component.inject(this);
Executor ioExecutor = Executors.newCachedThreadPool(); Executor ioExecutor = Executors.newCachedThreadPool();
...@@ -87,7 +90,7 @@ public class BridgeTest extends BrambleTestCase { ...@@ -87,7 +90,7 @@ public class BridgeTest extends BrambleTestCase {
SocketFactory torSocketFactory = SocketFactory.getDefault(); SocketFactory torSocketFactory = SocketFactory.getDefault();
factory = new TorPluginFactory(ioExecutor, scheduler, appContext, factory = new TorPluginFactory(ioExecutor, scheduler, appContext,
locationUtils, eventBus, torSocketFactory, networkManager, locationUtils, eventBus, torSocketFactory,
backoffFactory, circumventionProvider, clock); backoffFactory, circumventionProvider, clock);
} }
......
package org.briarproject.bramble.test;
import android.app.Application;
import android.support.test.InstrumentationRegistry;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
@Module
class ApplicationModule {
@Provides
@Singleton
Application provideApplication() {
return (Application) InstrumentationRegistry.getTargetContext()
.getApplicationContext();
}
}
package org.briarproject.bramble; package org.briarproject.bramble.test;
import org.briarproject.bramble.BrambleAndroidModule;
import org.briarproject.bramble.event.EventModule; import org.briarproject.bramble.event.EventModule;
import org.briarproject.bramble.plugin.PluginModule; import org.briarproject.bramble.plugin.PluginModule;
import org.briarproject.bramble.plugin.tor.BridgeTest; import org.briarproject.bramble.plugin.tor.BridgeTest;
...@@ -12,11 +13,13 @@ import dagger.Component; ...@@ -12,11 +13,13 @@ import dagger.Component;
@Singleton @Singleton
@Component(modules = { @Component(modules = {
BrambleAndroidModule.class, BrambleAndroidModule.class,
TestLifecycleModule.class,
ApplicationModule.class,
PluginModule.class, // needed for BackoffFactory PluginModule.class, // needed for BackoffFactory
EventModule.class, EventModule.class,
SystemModule.class, SystemModule.class,
}) })
public interface IntegrationTestComponent { public interface BrambleAndroidIntegrationTestComponent {
void inject(BridgeTest init); void inject(BridgeTest init);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment