X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FReloadingPageTest.kt;h=6470c95eec7bc2287b50c552e92efa003d62a0d0;hb=bfaaa6079966860b840f01cba4e83dc6e1cff947;hp=e32dc1bdcf8243a369540c928f38bba320ad42f5;hpb=a76956e389fcfe6282ad4ca7156bbf76327bb0c0;p=Sone.git 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 e32dc1b..6470c95 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ReloadingPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ReloadingPageTest.kt @@ -8,14 +8,15 @@ import org.hamcrest.Matchers.* import org.junit.* import org.junit.rules.* import java.nio.file.* -import kotlin.text.Charsets.UTF_8 /** * Unit test for [ReloadingPage]. */ class ReloadingPageTest { - @Rule @JvmField val tempFolder = TemporaryFolder() + @Rule + @JvmField + val tempFolder = TemporaryFolder() private val folder by lazy { tempFolder.newFolder()!! } private val page by lazy { ReloadingPage("/prefix/", folder.path, "text/plain") } private val webPageTest = WebPageTest() @@ -43,18 +44,19 @@ class ReloadingPageTest { @Test fun `requesting valid file results in 200 and delivers file`() { - Files.write(Paths.get(folder.path, "file.txt"), listOf("Hello", "World"), UTF_8) + val fileContent = listOf("Hello", "World").joinToString("\n", postfix = "\n").toByteArray() + Files.write(Paths.get(folder.path, "file.txt"), fileContent) webPageTest.request("/prefix/path/file.txt") page.handleRequest(freenetRequest, response) assertThat(response.statusCode, equalTo(200)) assertThat(response.statusText, equalTo("OK")) assertThat(response.contentType, equalTo("text/plain")) - assertThat(responseBytes.toByteArray(), equalTo("Hello\nWorld\n".toByteArray())) + assertThat(responseBytes.toByteArray(), equalTo(fileContent)) } @Test fun `page can be created by dependency injection`() { - assertThat(baseInjector.getInstance>(), notNullValue()) + assertThat(baseInjector.getInstance>(), notNullValue()) } }