Skip to content

Commit

Permalink
Merge pull request #22 from fleeksoft/develop
Browse files Browse the repository at this point in the history
test files html to gz
  • Loading branch information
itboy87 authored Dec 20, 2023
2 parents abb866d + c6abc56 commit 96b0c84
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 4,078 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class DataUtilTest {

@Test
fun handlesChunkedInputStream() {
val inputFile: String = TestHelper.getResourceAbsolutePath("htmltests/large.html")
val inputFile: String = TestHelper.getResourceAbsolutePath("htmltests/large.html.gz")
val input: String = TestHelper.getFileAsString(inputFile.toPath())
// val stream = VaryingBufferReader(BufferReader(input))
val expected = Ksoup.parse(input, "https://example.com")
Expand All @@ -295,7 +295,7 @@ class DataUtilTest {

@Test
fun handlesUnlimitedRead() {
val inputFile: String = TestHelper.getResourceAbsolutePath("htmltests/large.html")
val inputFile: String = TestHelper.getResourceAbsolutePath("htmltests/large.html.gz")
val input: String = TestHelper.getFileAsString(inputFile.toPath())
val byteBuffer: ByteArray = DataUtil.readToByteBuffer(BufferReader(input.toBuffer()), 0)
val read = byteBuffer.decodeToString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GithubIssue19 {

@Test
fun testAttributeIncorrectMixCharsetIssue() {
val document: Document = Ksoup.parseFile(TestHelper.getResourceAbsolutePath("htmltests/issue19.html"))
val document: Document = Ksoup.parseFile(TestHelper.getResourceAbsolutePath("htmltests/issue19.html.gz"))
val imagesEls: Elements = document.select("img")
for (imagesEl in imagesEls) {
val attr: String = imagesEl.attr("src")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class GithubIssuesTests {
@Test
fun testIssue20DuplicateElements() {
// https://github.com/fleeksoft/ksoup/issues/20
Ksoup.parse(TestHelper.getFileAsString(TestHelper.getResourceAbsolutePath("htmltests/issue20.html").toPath()))
Ksoup.parse(TestHelper.getFileAsString(TestHelper.getResourceAbsolutePath("htmltests/issue20.html.gz").toPath()))
.apply {
body().select("div[class=firs l]")
.firstOrNull()?.let { element ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ class CharacterReaderTest {
fun linenumbersAgreeWithEditor() {
val content: String =
TestHelper.getFileAsString(
TestHelper.getResourceAbsolutePath("htmltests/large.html").toPath(),
TestHelper.getResourceAbsolutePath("htmltests/large.html.gz").toPath(),
)
val reader = CharacterReader(content)
reader.trackNewlines(true)
Expand Down
1,296 changes: 0 additions & 1,296 deletions ksoup/src/commonTest/resources/htmltests/issue19.html

This file was deleted.

1,767 changes: 0 additions & 1,767 deletions ksoup/src/commonTest/resources/htmltests/issue20.html

This file was deleted.

1,004 changes: 0 additions & 1,004 deletions ksoup/src/commonTest/resources/htmltests/large.html

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.fleeksoft.ksoup.nodes.Document
import com.fleeksoft.ksoup.parser.Parser
import com.fleeksoft.ksoup.ported.BufferReader
import io.ktor.utils.io.charsets.*
import okio.gzip
import okio.source
import java.io.*
import java.nio.charset.StandardCharsets
Expand Down Expand Up @@ -53,7 +54,7 @@ class DataUtilTestJvm {

@Test
fun testHandlesChunkedInputStream() {
val file = File(TestHelper.getResourceAbsolutePath("htmltests/large.html"))
val file = File(TestHelper.getResourceAbsolutePath("htmltests/large.html.gz"))
val input = getFileAsString(file)
val expected =
Ksoup.parse(
Expand All @@ -62,14 +63,14 @@ class DataUtilTestJvm {
)
val doc: Document =
Ksoup.parse(
bufferReader = BufferReader(FileInputStream(file).source()),
bufferReader = BufferReader(FileInputStream(file).source().gzip()),
charsetName = null,
baseUri = "https://example.com",
)

val doc2: Document =
Ksoup.parseInputStream(
inputStream = FileInputStream(file),
inputStream = GZIPInputStream(FileInputStream(file)),
charsetName = null,
baseUri = "https://example.com",
)
Expand All @@ -81,7 +82,7 @@ class DataUtilTestJvm {

@Test
fun testHandlesUnlimitedRead() {
val file = File(TestHelper.getResourceAbsolutePath("htmltests/large.html"))
val file = File(TestHelper.getResourceAbsolutePath("htmltests/large.html.gz"))
val input: String = getFileAsString(file)

// VaryingReadInputStream stream = new VaryingReadInputStream(ParseTest.inputStreamFrom(input));
Expand All @@ -94,13 +95,13 @@ class DataUtilTestJvm {
)
val doc2: Document =
Ksoup.parseInputStream(
inputStream = FileInputStream(file),
inputStream = GZIPInputStream(FileInputStream(file)),
charsetName = null,
baseUri = "https://example.com",
)
val docThree: Document =
Ksoup.parse(
bufferReader = BufferReader(FileInputStream(file).source()),
bufferReader = BufferReader(FileInputStream(file).source().gzip()),
charsetName = null,
baseUri = "https://example.com",
)
Expand Down

0 comments on commit 96b0c84

Please sign in to comment.