Add some unit tests for RSS type and content guess methods
This commit is contained in:
parent
51cea7c4c2
commit
4e27a0b86f
@ -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 com.readrops.api.utils.ParseException
|
||||||
import junit.framework.TestCase.assertEquals
|
import junit.framework.TestCase.assertEquals
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@ -55,6 +54,16 @@ class LocalRSSHelperTest {
|
|||||||
|
|
||||||
</feed>""".toByteArray()
|
</feed>""".toByteArray()
|
||||||
)), LocalRSSHelper.RSSType.ATOM)
|
)), LocalRSSHelper.RSSType.ATOM)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun unknownContentTest() {
|
||||||
|
assertEquals(LocalRSSHelper.getRSSContentType(ByteArrayInputStream(
|
||||||
|
"""<html>
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>""".trimMargin().toByteArray()
|
||||||
|
)), LocalRSSHelper.RSSType.UNKNOWN)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
19
api/src/test/java/com/readrops/api/utils/LibUtilsTest.kt
Normal file
19
api/src/test/java/com/readrops/api/utils/LibUtilsTest.kt
Normal 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")
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user