From 7ae0065ee19bef259ff5f061e272bf90aa2f54c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 17 May 2019 10:43:03 +0200 Subject: [PATCH] =?utf8?q?=E2=9E=95=20Make=20Fred=E2=80=99s=20ToadletConta?= =?utf8?q?iner=20available=20to=20Guice?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../kotlin/net/pterodactylus/sone/main/FreenetModule.kt | 2 ++ .../kotlin/net/pterodactylus/sone/main/FreenetModuleTest.kt | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/main/FreenetModule.kt b/src/main/kotlin/net/pterodactylus/sone/main/FreenetModule.kt index 1253d0a..d8349ba 100644 --- a/src/main/kotlin/net/pterodactylus/sone/main/FreenetModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/main/FreenetModule.kt @@ -4,6 +4,7 @@ import com.google.inject.Binder import com.google.inject.Module import com.google.inject.Provides import freenet.client.HighLevelSimpleClient +import freenet.clients.http.* import freenet.node.Node import freenet.pluginmanager.PluginRespirator import javax.inject.Provider @@ -18,6 +19,7 @@ class FreenetModule(private val pluginRespirator: PluginRespirator): Module { bind(PluginRespirator::class.java).toProvider(Provider { pluginRespirator }) pluginRespirator.node!!.let { node -> bind(Node::class.java).toProvider(Provider { node }) } bind(HighLevelSimpleClient::class.java).toProvider(Provider { pluginRespirator.hlSimpleClient!! }) + bind(ToadletContainer::class.java).toProvider(Provider { pluginRespirator.toadletContainer }) } @Provides @Singleton diff --git a/src/test/kotlin/net/pterodactylus/sone/main/FreenetModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/FreenetModuleTest.kt index b9c2bcc..ed2037d 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/FreenetModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/FreenetModuleTest.kt @@ -2,7 +2,7 @@ package net.pterodactylus.sone.main import com.google.inject.Guice import freenet.client.HighLevelSimpleClient -import freenet.clients.http.SessionManager +import freenet.clients.http.* import freenet.node.Node import freenet.pluginmanager.PluginRespirator import net.pterodactylus.sone.test.deepMock @@ -25,6 +25,7 @@ class FreenetModuleTest { } private val node = pluginRespirator.node!! private val highLevelSimpleClient = pluginRespirator.hlSimpleClient!! + private val toadletContainer: ToadletContainer = pluginRespirator.toadletContainer private val module = FreenetModule(pluginRespirator) private val injector = Guice.createInjector(module) @@ -75,4 +76,14 @@ class FreenetModuleTest { verify(pluginRespirator).getSessionManager("Sone") } + @Test + fun `toadlet container is returned correctly`() { + assertThat(injector.getInstance(), sameInstance(toadletContainer)) + } + + @Test + fun `toadlet container is returned as singleten`() { + verifySingletonInstance() + } + } -- 2.7.4