X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FSoneParserTest.kt;h=38419a2fbc891405f727511b2abb1e878d20903e;hb=HEAD;hp=0648d1f10dd0a0e4781a7af0ec202d62ec1f2b62;hpb=b55dc075f9cd34fb32baa44bbbc54a89d05e80b9;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/core/SoneParserTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/SoneParserTest.kt index 0648d1f..38419a2 100644 --- a/src/test/kotlin/net/pterodactylus/sone/core/SoneParserTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/core/SoneParserTest.kt @@ -5,6 +5,7 @@ import com.google.common.base.Optional.* import freenet.crypt.* import freenet.keys.InsertableClientSSK.* import net.pterodactylus.sone.data.* +import net.pterodactylus.sone.data.impl.AlbumImpl import net.pterodactylus.sone.database.memory.* import net.pterodactylus.sone.freenet.wot.* import net.pterodactylus.sone.test.* @@ -41,6 +42,7 @@ class SoneParserTest { whenever(sone.identity).thenReturn(identity) whenever(sone.requestUri).thenAnswer { clientSSK.uri.setKeyType("USK").setDocName("Sone") } whenever(sone.time).thenReturn(currentTimeMillis() - DAYS.toMillis(1)) + whenever(sone.rootAlbum).thenReturn(AlbumImpl(sone)) } @Test @@ -398,10 +400,18 @@ class SoneParserTest { } @Test + fun `unsuccessful parsing does not add a histogram entry`() { + val inputStream = javaClass.getResourceAsStream("sone-parser-with-invalid-image-height.xml") + assertThat(soneParser.parseSone(sone, inputStream), nullValue()) + val histogram = metricRegistry.histogram("sone.parse.duration") + assertThat(histogram.count, equalTo(0L)) + } + + @Test fun `successful parsing adds histogram entry`() { val inputStream = javaClass.getResourceAsStream("sone-parser-without-images.xml") assertThat(soneParser.parseSone(sone, inputStream), notNullValue()) - val histogram = metricRegistry.histogram("sone.parsing.duration") + val histogram = metricRegistry.histogram("sone.parse.duration") assertThat(histogram.count, equalTo(1L)) }