From a250e29b8808ff3cf52bb1144657cca89e3df474 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 21 Jan 2018 11:24:13 +0100 Subject: [PATCH] Add test for DI constructability of ReloadingPage --- src/main/kotlin/net/pterodactylus/sone/web/pages/ReloadingPage.kt | 3 ++- .../kotlin/net/pterodactylus/sone/web/pages/ReloadingPageTest.kt | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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()) + } + } -- 2.7.4