Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test files html to gz #22

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading