import com.google.inject.Guice.*
import com.google.inject.name.Names.*
import freenet.l10n.*
-import freenet.pluginmanager.*
import net.pterodactylus.sone.core.*
import net.pterodactylus.sone.database.*
import net.pterodactylus.sone.database.memory.*
import org.hamcrest.Matchers.*
import org.mockito.Mockito.*
import java.io.*
+import java.util.concurrent.*
import java.util.concurrent.atomic.*
import kotlin.test.*
@Test
fun `core is created as singleton`() {
- val firstCore = injector.getInstance<Core>()
- val secondCore = injector.getInstance<Core>()
- assertThat(secondCore, sameInstance(firstCore))
+ injector.verifySingletonInstance<Core>()
}
@Test
}
@Test
- fun `metrics registry can be created`() {
- assertThat(injector.getInstance<MetricRegistry>(), notNullValue())
+ fun `metrics registry is created as singleton`() {
+ injector.verifySingletonInstance<MetricRegistry>()
}
@Test
- fun `metrics registry is created as singleton`() {
- val firstMetricRegistry = injector.getInstance<MetricRegistry>()
- val secondMetricRegistry = injector.getInstance<MetricRegistry>()
- assertThat(firstMetricRegistry, sameInstance(secondMetricRegistry))
+ fun `wot connector is created as singleton`() {
+ injector.verifySingletonInstance<WebOfTrustConnector>()
}
@Test
- fun `wot connector can be created`() {
- assertThat(injector.getInstance<WebOfTrustConnector>(), notNullValue())
+ fun `notification ticker is created as singleton`() {
+ injector.verifySingletonInstance<ScheduledExecutorService>(named("notification"))
}
@Test
- fun `wot connector is created as singleton`() {
- val firstWebOfTrustConnector = injector.getInstance<WebOfTrustConnector>()
- val secondWebOfTrustConnector = injector.getInstance<WebOfTrustConnector>()
- assertThat(firstWebOfTrustConnector, sameInstance(secondWebOfTrustConnector))
+ fun `ticker shutdown is created as singleton`() {
+ injector.verifySingletonInstance<TickerShutdown>()
}
}