Add some unit tests for RSS type and content guess methods

This commit is contained in:
Shinokuni 2020-08-28 22:50:53 +02:00
parent 51cea7c4c2
commit 4e27a0b86f
2 changed files with 30 additions and 2 deletions

View File

@ -1,6 +1,5 @@
package com.readrops.api
package com.readrops.api.localfeed
import com.readrops.api.localfeed.LocalRSSHelper
import com.readrops.api.utils.ParseException
import junit.framework.TestCase.assertEquals
import org.junit.Test
@ -55,6 +54,16 @@ class LocalRSSHelperTest {
</feed>""".toByteArray()
)), LocalRSSHelper.RSSType.ATOM)
}
@Test
fun unknownContentTest() {
assertEquals(LocalRSSHelper.getRSSContentType(ByteArrayInputStream(
"""<html>
<body>
</body>
</html>""".trimMargin().toByteArray()
)), LocalRSSHelper.RSSType.UNKNOWN)
}
}

View File

@ -0,0 +1,19 @@
package com.readrops.api.utils
import junit.framework.TestCase.assertEquals
import org.junit.Test
class LibUtilsTest {
@Test
fun contentTypeWithCharsetTest() {
assertEquals(LibUtils.parseContentType("application/rss+xml; charset=UTF-8"),
"application/rss+xml")
}
@Test
fun contentTypeWithoutCharsetText() {
assertEquals(LibUtils.parseContentType("text/xml"),
"text/xml")
}
}