compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.9.1'
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
compile group: 'org.jsoup', name: 'jsoup', version: '1.10.2'
+ compile group: 'io.dropwizard.metrics', name: 'metrics-core', version: '4.1.0'
testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit'
testCompile group: 'junit', name: 'junit', version: '4.11'
package net.pterodactylus.sone.main
+import com.codahale.metrics.*
import com.google.common.base.*
import com.google.common.eventbus.*
import com.google.inject.*
bind(Database::class.java).to(MemoryDatabase::class.java).`in`(Singleton::class.java)
bind(BaseL10n::class.java).toInstance(sonePlugin.l10n().base)
loaders?.let { bind(Loaders::class.java).toInstance(it) }
+ bind(MetricRegistry::class.java).`in`(Singleton::class.java)
bindListener(Matchers.any(), object : TypeListener {
override fun <I> hear(typeLiteral: TypeLiteral<I>, typeEncounter: TypeEncounter<I>) {
package net.pterodactylus.sone.main
+import com.codahale.metrics.*
import com.google.common.base.*
import com.google.common.eventbus.*
import com.google.inject.Guice.*
verify(eventBus).register(core)
}
+ @Test
+ fun `metrics registry can be created`() {
+ assertThat(injector.getInstance<MetricRegistry>(), notNullValue())
+ }
+
+ @Test
+ fun `metrics registry is created as singleton`() {
+ val firstMetricRegistry = injector.getInstance<MetricRegistry>()
+ val secondMetricRegistry = injector.getInstance<MetricRegistry>()
+ assertThat(firstMetricRegistry, sameInstance(secondMetricRegistry))
+ }
+
}