-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from fleeksoft/develop
fix test
- Loading branch information
Showing
22 changed files
with
327 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
ksoup-test/test@jvmAndAndroid/com/fleeksoft/ksoup/ParserHelper.jvm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.fleeksoft.ksoup | ||
|
||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
|
||
|
||
object ParserHelper { | ||
fun getPath(resourceName: String): Path { | ||
return Paths.get(TestHelper.getResourceAbsolutePath(resourceName)) | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
ksoup-test/test@jvmAndAndroid/com/fleeksoft/ksoup/select/SelectorIT.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.fleeksoft.ksoup.select | ||
|
||
import com.fleeksoft.ksoup.Ksoup | ||
import com.fleeksoft.ksoup.nodes.Document | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class SelectorIT { | ||
// todo:// create coroutine test in common | ||
@Test | ||
fun multiThreadHas() { | ||
val html = "<div id=1></div><div id=2><p>One</p><p>Two</p>" | ||
val eval = QueryParser.parse("div:has(p)") | ||
|
||
val numThreads = 20 | ||
val numThreadLoops = 5 | ||
|
||
val catcher = ThreadCatcher() | ||
|
||
val threads: Array<Thread?> = arrayOfNulls(numThreads) | ||
for (threadNum in 0 until numThreads) { | ||
val thread = Thread { | ||
val doc: Document = Ksoup.parse(html) | ||
for (loop in 0 until numThreadLoops) { | ||
val els: Elements = doc.select(eval) | ||
assertEquals(1, els.size) | ||
assertEquals("2", els[0].id()) | ||
} | ||
} | ||
thread.setName("Runner-$threadNum") | ||
thread.start() | ||
thread.setUncaughtExceptionHandler(catcher) | ||
threads[threadNum] = thread | ||
} | ||
|
||
// now join them all | ||
for (thread in threads) { | ||
thread?.join() | ||
} | ||
|
||
assertEquals(0, catcher.exceptionCount.get()) | ||
} | ||
|
||
internal class ThreadCatcher : Thread.UncaughtExceptionHandler { | ||
var exceptionCount: java.util.concurrent.atomic.AtomicInteger = java.util.concurrent.atomic.AtomicInteger() | ||
|
||
override fun uncaughtException(t: Thread, e: Throwable) { | ||
e.printStackTrace() | ||
exceptionCount.incrementAndGet() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ repositories: | |
|
||
dependencies: | ||
- $libs.codepoints | ||
- $libs.stately.concurrent | ||
- $libs.korlibs.io: exported |
Oops, something went wrong.