import net.pterodactylus.sone.database.memory.*
import net.pterodactylus.sone.freenet.*
import net.pterodactylus.sone.freenet.wot.*
+import net.pterodactylus.sone.web.FreenetSessionProvider
+import net.pterodactylus.sone.web.SessionProvider
import net.pterodactylus.util.config.*
import net.pterodactylus.util.config.ConfigurationException
import net.pterodactylus.util.logging.*
bind(WebOfTrustConnector::class.java).to(PluginWebOfTrustConnector::class.java).`in`(Singleton::class.java)
bind(TickerShutdown::class.java).`in`(Singleton::class.java)
bind(SoneUriCreator::class.java).`in`(Singleton::class.java)
+ bind(SessionProvider::class.java).to(FreenetSessionProvider::class.java).`in`(Singleton::class.java)
bindListener(Matchers.any(), object : TypeListener {
override fun <I> hear(typeLiteral: TypeLiteral<I>, typeEncounter: TypeEncounter<I>) {
import com.google.common.base.*
import com.google.common.eventbus.*
import com.google.inject.Guice.*
+import com.google.inject.Injector
import com.google.inject.name.Names.*
+import freenet.clients.http.SessionManager
import freenet.l10n.*
import net.pterodactylus.sone.core.*
import net.pterodactylus.sone.database.*
import net.pterodactylus.sone.freenet.plugin.*
import net.pterodactylus.sone.freenet.wot.*
import net.pterodactylus.sone.test.*
+import net.pterodactylus.sone.web.SessionProvider
import net.pterodactylus.util.config.*
import net.pterodactylus.util.version.Version
import org.hamcrest.MatcherAssert.*
whenever(l10n()).thenReturn(l10n)
}
- private val injector by lazy {
- createInjector(
- SoneModule(sonePlugin, EventBus()),
- FreenetInterface::class.isProvidedByDeepMock(),
- PluginRespiratorFacade::class.isProvidedByDeepMock(),
- PluginConnector::class.isProvidedByDeepMock()
- )
- }
+ private val injector by lazy { createInjector() }
@AfterTest
fun removePropertiesFromCurrentDirectory() {
@Test
fun `core is registered with event bus`() {
val eventBus = mock<EventBus>()
- val injector = createInjector(
- SoneModule(sonePlugin, eventBus),
- FreenetInterface::class.isProvidedByDeepMock(),
- PluginRespiratorFacade::class.isProvidedByDeepMock(),
- PluginConnector::class.isProvidedByDeepMock()
- )
+ val injector = createInjector(eventBus)
val core = injector.getInstance<Core>()
verify(eventBus).register(core)
}
+ private fun createInjector(eventBus: EventBus = EventBus()): Injector =
+ createInjector(
+ SoneModule(sonePlugin, eventBus),
+ FreenetInterface::class.isProvidedByDeepMock(),
+ PluginRespiratorFacade::class.isProvidedByDeepMock(),
+ PluginConnector::class.isProvidedByDeepMock(),
+ SessionManager::class.isProvidedByMock()
+ )
+
@Test
fun `metrics registry is created as singleton`() {
injector.verifySingletonInstance<MetricRegistry>()
injector.verifySingletonInstance<SoneUriCreator>()
}
+ @Test
+ fun `session provider is created as singleton`() {
+ injector.verifySingletonInstance<SessionProvider>()
+ }
+
}