From: David ‘Bombe’ Roden Date: Sun, 21 Jan 2018 10:24:13 +0000 (+0100) Subject: Add test for DI constructability of ReloadingPage X-Git-Tag: v79^2~199 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a250e29b8808ff3cf52bb1144657cca89e3df474;p=Sone.git Add test for DI constructability of ReloadingPage --- diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/ReloadingPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/ReloadingPage.kt index 697d173..7342ac9 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ReloadingPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ReloadingPage.kt @@ -4,11 +4,12 @@ import net.pterodactylus.util.web.Page import net.pterodactylus.util.web.Request import net.pterodactylus.util.web.Response import java.io.File +import javax.inject.Inject /** * [Page] implementation that delivers static files from the filesystem. */ -class ReloadingPage(private val prefix: String, private val path: String, private val mimeType: String): Page { +class ReloadingPage @Inject constructor(private val prefix: String, private val path: String, private val mimeType: String): Page { override fun isPrefixPage() = true diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/ReloadingPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/ReloadingPageTest.kt index 7ebb052..007e481 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ReloadingPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ReloadingPageTest.kt @@ -1,8 +1,11 @@ package net.pterodactylus.sone.web.pages +import net.pterodactylus.sone.test.getInstance +import net.pterodactylus.sone.web.baseInjector import net.pterodactylus.sone.web.page.FreenetRequest import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.notNullValue import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder @@ -52,4 +55,9 @@ class ReloadingPageTest { assertThat(responseBytes.toByteArray(), equalTo("Hello\nWorld\n".toByteArray())) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance>(), notNullValue()) + } + }