From: David ‘Bombe’ Roden Date: Fri, 17 May 2019 08:43:03 +0000 (+0200) Subject: ➕ Make Fred’s ToadletContainer available to Guice X-Git-Tag: v79^2~50 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=7ae0065ee19bef259ff5f061e272bf90aa2f54c7;p=Sone.git ➕ Make Fred’s ToadletContainer available to Guice --- 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() + } + }