Replace default methods with helper classes.

This is a workaround for AbstractMethodErrors
thrown by on-device tests.
This commit is contained in:
akwizgran
2019-12-11 16:27:55 +00:00
parent 5ba64577bd
commit 5962d3c763
35 changed files with 182 additions and 144 deletions

View File

@@ -11,4 +11,14 @@ public interface BrambleAndroidEagerSingletons {
void inject(AndroidNetworkModule.EagerSingletons init);
void inject(ReportingModule.EagerSingletons init);
class Helper {
public static void injectEagerSingletons(
BrambleAndroidEagerSingletons c) {
c.inject(new AndroidBatteryModule.EagerSingletons());
c.inject(new AndroidNetworkModule.EagerSingletons());
c.inject(new ReportingModule.EagerSingletons());
}
}
}

View File

@@ -18,10 +18,4 @@ import dagger.Module;
SocksModule.class
})
public class BrambleAndroidModule {
public static void initEagerSingletons(BrambleAndroidEagerSingletons c) {
c.inject(new AndroidBatteryModule.EagerSingletons());
c.inject(new AndroidNetworkModule.EagerSingletons());
c.inject(new ReportingModule.EagerSingletons());
}
}

View File

@@ -39,18 +39,21 @@ public interface BrambleCoreEagerSingletons {
void inject(VersioningModule.EagerSingletons init);
default void injectBrambleCoreEagerSingletons() {
inject(new ContactModule.EagerSingletons());
inject(new CryptoExecutorModule.EagerSingletons());
inject(new DatabaseExecutorModule.EagerSingletons());
inject(new IdentityModule.EagerSingletons());
inject(new LifecycleModule.EagerSingletons());
inject(new RendezvousModule.EagerSingletons());
inject(new PluginModule.EagerSingletons());
inject(new PropertiesModule.EagerSingletons());
inject(new SystemModule.EagerSingletons());
inject(new TransportModule.EagerSingletons());
inject(new ValidationModule.EagerSingletons());
inject(new VersioningModule.EagerSingletons());
class Helper {
public static void injectEagerSingletons(BrambleCoreEagerSingletons c) {
c.inject(new ContactModule.EagerSingletons());
c.inject(new CryptoExecutorModule.EagerSingletons());
c.inject(new DatabaseExecutorModule.EagerSingletons());
c.inject(new IdentityModule.EagerSingletons());
c.inject(new LifecycleModule.EagerSingletons());
c.inject(new RendezvousModule.EagerSingletons());
c.inject(new PluginModule.EagerSingletons());
c.inject(new PropertiesModule.EagerSingletons());
c.inject(new SystemModule.EagerSingletons());
c.inject(new TransportModule.EagerSingletons());
c.inject(new ValidationModule.EagerSingletons());
c.inject(new VersioningModule.EagerSingletons());
}
}
}

View File

@@ -50,8 +50,4 @@ import dagger.Module;
VersioningModule.class
})
public class BrambleCoreModule {
public static void initEagerSingletons(BrambleCoreEagerSingletons c) {
c.injectBrambleCoreEagerSingletons();
}
}

View File

@@ -1,5 +1,6 @@
package org.briarproject.bramble.contact;
import org.briarproject.bramble.BrambleCoreEagerSingletons;
import org.briarproject.bramble.api.Pair;
import org.briarproject.bramble.api.contact.Contact;
import org.briarproject.bramble.api.contact.ContactManager;
@@ -61,11 +62,11 @@ public class ContactExchangeIntegrationTest extends BrambleTestCase {
alice = DaggerContactExchangeIntegrationTestComponent.builder()
.testDatabaseConfigModule(
new TestDatabaseConfigModule(aliceDir)).build();
alice.injectBrambleCoreEagerSingletons();
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(alice);
bob = DaggerContactExchangeIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(bobDir))
.build();
bob.injectBrambleCoreEagerSingletons();
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(bob);
// Set up the devices and get the identities
aliceIdentity = setUp(alice, "Alice");
bobIdentity = setUp(bob, "Bob");

View File

@@ -1,5 +1,6 @@
package org.briarproject.bramble.sync;
import org.briarproject.bramble.BrambleCoreEagerSingletons;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.api.crypto.TransportCrypto;
@@ -72,7 +73,7 @@ public class SyncIntegrationTest extends BrambleTestCase {
SyncIntegrationTestComponent component =
DaggerSyncIntegrationTestComponent.builder().build();
component.injectBrambleCoreEagerSingletons();
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(component);
component.inject(this);
contactId = getContactId();

View File

@@ -1,5 +1,6 @@
package org.briarproject.bramble.plugin.tor;
import org.briarproject.bramble.BrambleCoreEagerSingletons;
import org.briarproject.bramble.api.battery.BatteryManager;
import org.briarproject.bramble.api.event.EventBus;
import org.briarproject.bramble.api.lifecycle.IoExecutor;
@@ -45,7 +46,7 @@ public class BridgeTest extends BrambleTestCase {
public static Iterable<String> data() {
BrambleJavaIntegrationTestComponent component =
DaggerBrambleJavaIntegrationTestComponent.builder().build();
component.injectBrambleCoreEagerSingletons();
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(component);
return component.getCircumventionProvider().getBridges(false);
}
@@ -90,7 +91,7 @@ public class BridgeTest extends BrambleTestCase {
BrambleJavaIntegrationTestComponent component =
DaggerBrambleJavaIntegrationTestComponent.builder().build();
component.injectBrambleCoreEagerSingletons();
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(component);
component.inject(this);
LocationUtils locationUtils = () -> "US";

View File

@@ -1,8 +1,8 @@
package org.briarproject.briar.android;
import org.briarproject.bramble.BrambleAndroidModule;
import org.briarproject.bramble.BrambleCoreModule;
import org.briarproject.briar.BriarCoreModule;
import org.briarproject.bramble.BrambleAndroidEagerSingletons;
import org.briarproject.bramble.BrambleCoreEagerSingletons;
import org.briarproject.briar.BriarCoreEagerSingletons;
public class BriarTestComponentApplication extends BriarApplicationImpl {
@@ -12,10 +12,10 @@ public class BriarTestComponentApplication extends BriarApplicationImpl {
.appModule(new AppModule(this)).build();
// We need to load the eager singletons directly after making the
// dependency graphs
BrambleCoreModule.initEagerSingletons(component); // FIXME AbstractMethodError
BrambleAndroidModule.initEagerSingletons(component);
BriarCoreModule.initEagerSingletons(component);
AndroidEagerSingletons.initEagerSingletons(component);
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(component);
BrambleAndroidEagerSingletons.Helper.injectEagerSingletons(component);
BriarCoreEagerSingletons.Helper.injectEagerSingletons(component);
AndroidEagerSingletons.Helper.injectEagerSingletons(component);
return component;
}

View File

@@ -73,7 +73,7 @@ import dagger.Component;
})
public interface AndroidComponent
extends BrambleCoreEagerSingletons, BrambleAndroidEagerSingletons,
BriarCoreEagerSingletons {
BriarCoreEagerSingletons, AndroidEagerSingletons {
// Exposed objects
@CryptoExecutor
@@ -176,7 +176,4 @@ public interface AndroidComponent
void inject(EmojiTextInputView textInputView);
void inject(BriarModelLoader briarModelLoader);
// Eager singleton load
void inject(AppModule.EagerSingletons init);
}

View File

@@ -1,8 +1,13 @@
package org.briarproject.briar.android;
class AndroidEagerSingletons {
interface AndroidEagerSingletons {
static void initEagerSingletons(AndroidComponent c) {
c.inject(new AppModule.EagerSingletons());
void inject(AppModule.EagerSingletons init);
class Helper {
static void injectEagerSingletons(AndroidEagerSingletons c) {
c.inject(new AppModule.EagerSingletons());
}
}
}

View File

@@ -17,9 +17,9 @@ import com.vanniktech.emoji.google.GoogleEmojiProvider;
import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;
import org.briarproject.bramble.BrambleAndroidModule;
import org.briarproject.bramble.BrambleCoreModule;
import org.briarproject.briar.BriarCoreModule;
import org.briarproject.bramble.BrambleAndroidEagerSingletons;
import org.briarproject.bramble.BrambleCoreEagerSingletons;
import org.briarproject.briar.BriarCoreEagerSingletons;
import org.briarproject.briar.BuildConfig;
import org.briarproject.briar.R;
import org.briarproject.briar.android.logging.CachingLogHandler;
@@ -133,10 +133,12 @@ public class BriarApplicationImpl extends Application
// We need to load the eager singletons directly after making the
// dependency graphs
BrambleCoreModule.initEagerSingletons(androidComponent);
BrambleAndroidModule.initEagerSingletons(androidComponent);
BriarCoreModule.initEagerSingletons(androidComponent);
AndroidEagerSingletons.initEagerSingletons(androidComponent);
BrambleCoreEagerSingletons.Helper
.injectEagerSingletons(androidComponent);
BrambleAndroidEagerSingletons.Helper
.injectEagerSingletons(androidComponent);
BriarCoreEagerSingletons.Helper.injectEagerSingletons(androidComponent);
AndroidEagerSingletons.Helper.injectEagerSingletons(androidComponent);
return androidComponent;
}

View File

@@ -7,9 +7,9 @@ import android.preference.PreferenceManager;
import com.vanniktech.emoji.EmojiManager;
import com.vanniktech.emoji.google.GoogleEmojiProvider;
import org.briarproject.bramble.BrambleAndroidModule;
import org.briarproject.bramble.BrambleCoreModule;
import org.briarproject.briar.BriarCoreModule;
import org.briarproject.bramble.BrambleAndroidEagerSingletons;
import org.briarproject.bramble.BrambleCoreEagerSingletons;
import org.briarproject.briar.BriarCoreEagerSingletons;
import java.util.Collection;
import java.util.logging.LogRecord;
@@ -42,10 +42,14 @@ public class TestBriarApplication extends Application
// We need to load the eager singletons directly after making the
// dependency graphs
BrambleCoreModule.initEagerSingletons(applicationComponent);
BrambleAndroidModule.initEagerSingletons(applicationComponent);
BriarCoreModule.initEagerSingletons(applicationComponent);
AndroidEagerSingletons.initEagerSingletons(applicationComponent);
BrambleCoreEagerSingletons.Helper
.injectEagerSingletons(applicationComponent);
BrambleAndroidEagerSingletons.Helper
.injectEagerSingletons(applicationComponent);
BriarCoreEagerSingletons.Helper
.injectEagerSingletons(applicationComponent);
AndroidEagerSingletons.Helper
.injectEagerSingletons(applicationComponent);
EmojiManager.install(new GoogleEmojiProvider());
}

View File

@@ -27,4 +27,17 @@ public interface BriarCoreEagerSingletons {
void inject(SharingModule.EagerSingletons init);
class Helper {
public static void injectEagerSingletons(BriarCoreEagerSingletons c) {
c.inject(new BlogModule.EagerSingletons());
c.inject(new FeedModule.EagerSingletons());
c.inject(new ForumModule.EagerSingletons());
c.inject(new GroupInvitationModule.EagerSingletons());
c.inject(new MessagingModule.EagerSingletons());
c.inject(new PrivateGroupModule.EagerSingletons());
c.inject(new SharingModule.EagerSingletons());
c.inject(new IntroductionModule.EagerSingletons());
}
}
}

View File

@@ -28,15 +28,4 @@ import dagger.Module;
TestModule.class
})
public class BriarCoreModule {
public static void initEagerSingletons(BriarCoreEagerSingletons c) {
c.inject(new BlogModule.EagerSingletons());
c.inject(new FeedModule.EagerSingletons());
c.inject(new ForumModule.EagerSingletons());
c.inject(new GroupInvitationModule.EagerSingletons());
c.inject(new MessagingModule.EagerSingletons());
c.inject(new PrivateGroupModule.EagerSingletons());
c.inject(new SharingModule.EagerSingletons());
c.inject(new IntroductionModule.EagerSingletons());
}
}

View File

@@ -65,23 +65,23 @@ public class BlogManagerIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -38,7 +38,7 @@ public class FeedManagerIntegrationTest extends BriarTestCase {
DaggerFeedManagerIntegrationTestComponent.builder()
.testDatabaseConfigModule(
new TestDatabaseConfigModule(testFile)).build();
component.injectFeedManagerEagerSingletons();
FeedManagerIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
IdentityManager identityManager = component.getIdentityManager();

View File

@@ -35,12 +35,6 @@ interface FeedManagerIntegrationTestComponent
void inject(FeedModule.EagerSingletons init);
default void injectFeedManagerEagerSingletons() {
injectBrambleCoreEagerSingletons();
inject(new BlogModule.EagerSingletons());
inject(new FeedModule.EagerSingletons());
}
IdentityManager getIdentityManager();
LifecycleManager getLifecycleManager();
@@ -49,4 +43,13 @@ interface FeedManagerIntegrationTestComponent
BlogManager getBlogManager();
class Helper {
public static void injectEagerSingletons(
FeedManagerIntegrationTestComponent c) {
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(c);
c.inject(new BlogModule.EagerSingletons());
c.inject(new FeedModule.EagerSingletons());
}
}
}

View File

@@ -56,23 +56,23 @@ public class ForumManagerTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
private ForumPost createForumPost(GroupId groupId,

View File

@@ -54,7 +54,8 @@ public class IntroductionCryptoIntegrationTest extends BrambleTestCase {
public IntroductionCryptoIntegrationTest() {
IntroductionIntegrationTestComponent component =
DaggerIntroductionIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper
.injectEagerSingletons(component);
component.inject(this);
crypto = new IntroductionCryptoImpl(cryptoComponent, clientHelper);

View File

@@ -114,23 +114,24 @@ public class IntroductionIntegrationTest
protected void createComponents() {
IntroductionIntegrationTestComponent component =
DaggerIntroductionIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper
.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerIntroductionIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerIntroductionIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerIntroductionIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -74,7 +74,8 @@ public class MessageEncoderParserIntegrationTest extends BrambleTestCase {
public MessageEncoderParserIntegrationTest() {
IntroductionIntegrationTestComponent component =
DaggerIntroductionIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper
.injectEagerSingletons(component);
component.inject(this);
messageEncoder = new MessageEncoderImpl(clientHelper, messageFactory);

View File

@@ -83,7 +83,8 @@ public class SessionEncoderParserIntegrationTest extends BrambleTestCase {
public SessionEncoderParserIntegrationTest() {
IntroductionIntegrationTestComponent component =
DaggerIntroductionIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
IntroductionIntegrationTestComponent.Helper
.injectEagerSingletons(component);
component.inject(this);
sessionEncoder = new SessionEncoderImpl(clientHelper);

View File

@@ -44,7 +44,8 @@ public class MessageSizeIntegrationTest extends BriarTestCase {
public MessageSizeIntegrationTest() {
MessageSizeIntegrationTestComponent component =
DaggerMessageSizeIntegrationTestComponent.builder().build();
component.injectMessageSizeEagerSingletons();
MessageSizeIntegrationTestComponent.Helper
.injectEagerSingletons(component);
component.inject(this);
}

View File

@@ -27,9 +27,13 @@ interface MessageSizeIntegrationTestComponent
void inject(MessagingModule.EagerSingletons init);
default void injectMessageSizeEagerSingletons() {
injectBrambleCoreEagerSingletons();
inject(new ForumModule.EagerSingletons());
inject(new MessagingModule.EagerSingletons());
class Helper {
public static void injectEagerSingletons(
MessageSizeIntegrationTestComponent c) {
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(c);
c.inject(new ForumModule.EagerSingletons());
c.inject(new MessagingModule.EagerSingletons());
}
}
}

View File

@@ -68,23 +68,23 @@ public class MessagingManagerIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -60,11 +60,13 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
alice = DaggerSimplexMessagingIntegrationTestComponent.builder()
.testDatabaseConfigModule(
new TestDatabaseConfigModule(aliceDir)).build();
alice.injectSimplexMessagingEagerSingletons();
SimplexMessagingIntegrationTestComponent.Helper
.injectEagerSingletons(alice);
bob = DaggerSimplexMessagingIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(bobDir))
.build();
bob.injectSimplexMessagingEagerSingletons();
SimplexMessagingIntegrationTestComponent.Helper
.injectEagerSingletons(bob);
}
@Test

View File

@@ -28,11 +28,6 @@ interface SimplexMessagingIntegrationTestComponent
void inject(MessagingModule.EagerSingletons init);
default void injectSimplexMessagingEagerSingletons() {
injectBrambleCoreEagerSingletons();
inject(new MessagingModule.EagerSingletons());
}
LifecycleManager getLifecycleManager();
IdentityManager getIdentityManager();
@@ -46,4 +41,13 @@ interface SimplexMessagingIntegrationTestComponent
EventBus getEventBus();
ConnectionManager getConnectionManager();
class Helper {
public static void injectEagerSingletons(
SimplexMessagingIntegrationTestComponent c) {
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(c);
c.inject(new MessagingModule.EagerSingletons());
}
}
}

View File

@@ -70,23 +70,23 @@ public class PrivateGroupIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -59,23 +59,23 @@ public class PrivateGroupManagerIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -66,23 +66,23 @@ public class GroupInvitationIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -82,23 +82,23 @@ public class BlogSharingIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
@Test

View File

@@ -99,23 +99,23 @@ public class ForumSharingIntegrationTest
protected void createComponents() {
BriarIntegrationTestComponent component =
DaggerBriarIntegrationTestComponent.builder().build();
component.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(component);
component.inject(this);
c0 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t0Dir))
.build();
c0.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c0);
c1 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t1Dir))
.build();
c1.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c1);
c2 = DaggerBriarIntegrationTestComponent.builder()
.testDatabaseConfigModule(new TestDatabaseConfigModule(t2Dir))
.build();
c2.injectBriarEagerSingletons();
BriarIntegrationTestComponent.Helper.injectEagerSingletons(c2);
}
private void addForumForSharer() throws DbException {

View File

@@ -69,17 +69,6 @@ public interface BriarIntegrationTestComponent
void inject(SharingModule.EagerSingletons init);
default void injectBriarEagerSingletons() {
injectBrambleCoreEagerSingletons();
inject(new BlogModule.EagerSingletons());
inject(new ForumModule.EagerSingletons());
inject(new GroupInvitationModule.EagerSingletons());
inject(new IntroductionModule.EagerSingletons());
inject(new MessagingModule.EagerSingletons());
inject(new PrivateGroupModule.EagerSingletons());
inject(new SharingModule.EagerSingletons());
}
LifecycleManager getLifecycleManager();
EventBus getEventBus();
@@ -121,4 +110,19 @@ public interface BriarIntegrationTestComponent
BlogFactory getBlogFactory();
ConnectionManager getConnectionManager();
class Helper {
public static void injectEagerSingletons(
BriarIntegrationTestComponent c) {
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(c);
c.inject(new BlogModule.EagerSingletons());
c.inject(new ForumModule.EagerSingletons());
c.inject(new GroupInvitationModule.EagerSingletons());
c.inject(new IntroductionModule.EagerSingletons());
c.inject(new MessagingModule.EagerSingletons());
c.inject(new PrivateGroupModule.EagerSingletons());
c.inject(new SharingModule.EagerSingletons());
}
}
}

View File

@@ -6,8 +6,8 @@ import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.int
import org.briarproject.bramble.BrambleCoreModule
import org.briarproject.briar.BriarCoreModule
import org.briarproject.bramble.BrambleCoreEagerSingletons
import org.briarproject.briar.BriarCoreEagerSingletons
import org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY
import org.spongycastle.util.encoders.Base64.toBase64String
import java.io.File
@@ -70,8 +70,8 @@ private class Main : CliktCommand(
DaggerBriarHeadlessApp.builder().headlessModule(HeadlessModule(dataDir)).build()
// We need to load the eager singletons directly after making the
// dependency graphs
BrambleCoreModule.initEagerSingletons(app)
BriarCoreModule.initEagerSingletons(app)
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(app)
BriarCoreEagerSingletons.Helper.injectEagerSingletons(app)
val authToken = getOrCreateAuthToken(dataDir, app.getSecureRandom())

View File

@@ -3,9 +3,9 @@ package org.briarproject.briar.headless
import io.javalin.Javalin
import io.javalin.core.util.Header.AUTHORIZATION
import khttp.responses.Response
import org.briarproject.bramble.BrambleCoreModule
import org.briarproject.bramble.BrambleCoreEagerSingletons
import org.briarproject.bramble.api.crypto.CryptoComponent
import org.briarproject.briar.BriarCoreModule
import org.briarproject.briar.BriarCoreEagerSingletons
import org.briarproject.briar.api.test.TestDataCreator
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.BeforeAll
@@ -32,8 +32,8 @@ abstract class IntegrationTest {
val app = DaggerBriarHeadlessTestApp.builder()
.headlessTestModule(HeadlessTestModule(dataDir))
.build()
BrambleCoreModule.initEagerSingletons(app)
BriarCoreModule.initEagerSingletons(app)
BrambleCoreEagerSingletons.Helper.injectEagerSingletons(app)
BriarCoreEagerSingletons.Helper.injectEagerSingletons(app)
router = app.getRouter()
crypto = app.getCryptoComponent()
testDataCreator = app.getTestDataCreator()