From 18e619b28421c8222b743c779d0b2e55c1bc1bd9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 10 Jul 2019 21:43:19 +0200 Subject: [PATCH] =?utf8?q?=E2=9C=85=20Test=20for=20correct=20l10n=20in=20S?= =?utf8?q?oneModule?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt | 2 ++ .../kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt index 6a349eb..18f4b95 100644 --- a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt @@ -6,6 +6,7 @@ import com.google.inject.* import com.google.inject.matcher.* import com.google.inject.name.Names.* import com.google.inject.spi.* +import freenet.l10n.* import net.pterodactylus.sone.database.* import net.pterodactylus.sone.database.memory.* import net.pterodactylus.sone.freenet.wot.* @@ -49,6 +50,7 @@ class SoneModule(private val sonePlugin: SonePlugin) : AbstractModule() { bind(PluginYear::class.java).toInstance(PluginYear(sonePlugin.year)) bind(PluginHomepage::class.java).toInstance(PluginHomepage(sonePlugin.homepage)) 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) } bindListener(Matchers.any(), object : TypeListener { diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt index 62f947c..0b8ef04 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt @@ -4,6 +4,7 @@ import com.google.common.base.* import com.google.common.eventbus.* import com.google.inject.Guice.* import com.google.inject.name.Names.* +import freenet.l10n.* import net.pterodactylus.sone.database.* import net.pterodactylus.sone.database.memory.* import net.pterodactylus.sone.freenet.wot.* @@ -12,9 +13,9 @@ import net.pterodactylus.util.config.* import net.pterodactylus.util.version.Version import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* -import org.junit.* import java.io.* import java.util.concurrent.atomic.* +import kotlin.test.* const val versionString = "v80" @@ -24,15 +25,17 @@ class SoneModuleTest { private val pluginVersion = Version("", 80) private val pluginYear = 2019 private val pluginHomepage = "home://page" + private val l10n = deepMock() private val sonePlugin = mock().apply { whenever(version).thenReturn(versionString) whenever(year).thenReturn(pluginYear) whenever(homepage).thenReturn(pluginHomepage) + whenever(l10n()).thenReturn(l10n) } private val injector by lazy { createInjector(SoneModule(sonePlugin)) } - @After + @AfterTest fun removePropertiesFromCurrentDirectory() { File(currentDir, "sone.properties").delete() } @@ -134,6 +137,11 @@ class SoneModuleTest { } @Test + fun `base l10n is bound correctly`() { + assertThat(injector.getInstance(), sameInstance(l10n.base)) + } + + @Test fun `default loader is used without dev options`() { assertThat(injector.getInstance(), instanceOf(DefaultLoaders::class.java)) } -- 2.7.4