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
bind(PluginRespirator::class.java).toProvider(Provider<PluginRespirator> { pluginRespirator })
pluginRespirator.node!!.let { node -> bind(Node::class.java).toProvider(Provider<Node> { node }) }
bind(HighLevelSimpleClient::class.java).toProvider(Provider<HighLevelSimpleClient> { pluginRespirator.hlSimpleClient!! })
+ bind(ToadletContainer::class.java).toProvider(Provider<ToadletContainer> { pluginRespirator.toadletContainer })
}
@Provides @Singleton
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
}
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)
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<ToadletContainer>()
+ }
+
}