From: David ‘Bombe’ Roden Date: Fri, 12 Jul 2019 05:26:13 +0000 (+0200) Subject: 🐛 Create Core as singleton X-Git-Tag: v81^2~189 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=32926dd92d7eb59ffaf7dcb9ba6052d29d3c40d1;p=Sone.git 🐛 Create Core as singleton --- diff --git a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt index 07ec56e..66cd29a 100644 --- a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt @@ -62,6 +62,7 @@ class SoneModule(private val sonePlugin: SonePlugin) : AbstractModule() { } @Provides + @Singleton fun getCore(configuration: Configuration, freenetInterface: FreenetInterface, identityManager: IdentityManager, soneDownloader: SoneDownloader, imageInserter: ImageInserter, updateChecker: UpdateChecker, webOfTrustUpdater: WebOfTrustUpdater, eventBus: EventBus, database: Database) = Core(configuration, freenetInterface, identityManager, soneDownloader, imageInserter, updateChecker, webOfTrustUpdater, eventBus, database).apply { debugInformation.showVersionInformation = configuration.getBooleanValue("Debug/ShowVersionInformation").getValue(false) diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt index dd7923d..d928214 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt @@ -188,4 +188,11 @@ class SoneModuleTest { assertThat(testObject.ref.get(), sameInstance(event)) } + @Test + fun `core is created as singleton`() { + val firstCore = injector.getInstance() + val secondCore = injector.getInstance() + assertThat(secondCore, sameInstance(firstCore)) + } + }