Fix all parsers issues
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
package org.koitharu.kotatsu.parsers
|
||||
|
||||
interface MangaParserTest {
|
||||
|
||||
fun testMangaList()
|
||||
|
||||
fun testMangaDetails()
|
||||
|
||||
fun testMangaPages()
|
||||
|
||||
fun testTags()
|
||||
}
|
||||
@@ -6,23 +6,23 @@ import java.net.URL
|
||||
|
||||
object AssertX {
|
||||
|
||||
fun assertContentType(url: String, type: String, subtype: String? = null) {
|
||||
Assert.assertFalse("URL is empty", url.isEmpty())
|
||||
val cn = URL(url).openConnection() as HttpURLConnection
|
||||
cn.requestMethod = "HEAD"
|
||||
cn.connect()
|
||||
when (val code = cn.responseCode) {
|
||||
HttpURLConnection.HTTP_MOVED_PERM,
|
||||
HttpURLConnection.HTTP_MOVED_TEMP -> assertContentType(cn.getHeaderField("Location"), type, subtype)
|
||||
HttpURLConnection.HTTP_OK -> {
|
||||
val ct = cn.contentType.substringBeforeLast(';').split("/")
|
||||
Assert.assertEquals(type, ct.first())
|
||||
if (subtype != null) {
|
||||
Assert.assertEquals(subtype, ct.last())
|
||||
}
|
||||
}
|
||||
else -> Assert.fail("Invalid response code $code")
|
||||
}
|
||||
}
|
||||
fun assertContentType(url: String, type: String, subtype: String? = null) {
|
||||
Assert.assertFalse("URL is empty", url.isEmpty())
|
||||
val cn = URL(url).openConnection() as HttpURLConnection
|
||||
cn.requestMethod = "HEAD"
|
||||
cn.connect()
|
||||
when (val code = cn.responseCode) {
|
||||
HttpURLConnection.HTTP_MOVED_PERM,
|
||||
HttpURLConnection.HTTP_MOVED_TEMP -> assertContentType(cn.getHeaderField("Location"), type, subtype)
|
||||
HttpURLConnection.HTTP_OK -> {
|
||||
val ct = cn.contentType.substringBeforeLast(';').split("/")
|
||||
Assert.assertEquals(type, ct.first())
|
||||
if (subtype != null) {
|
||||
Assert.assertEquals(subtype, ct.last())
|
||||
}
|
||||
}
|
||||
else -> Assert.fail("Invalid response code $code")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user