mirror of
https://github.com/square/okhttp.git
synced 2025-08-08 23:42:08 +03:00
Switch back to the kotlin JVM plugin (#8149)
* Switch back to the kotlin JVM plugin This does a ton of file moves from jvmMain to main, and jvmTest to test. * Don't use AnimalSniffer on okcurl * Use assertk more (#8150)
This commit is contained in:
@@ -1,47 +1,33 @@
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
kotlin("jvm")
|
||||
id("ru.vyarus.animalsniffer")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
api(libs.squareup.okio)
|
||||
api(projects.okhttp)
|
||||
api(projects.okhttpTls)
|
||||
api(libs.assertj.core)
|
||||
api(libs.bouncycastle.bcprov)
|
||||
implementation(libs.bouncycastle.bcpkix)
|
||||
implementation(libs.bouncycastle.bctls)
|
||||
api(libs.conscrypt.openjdk)
|
||||
api(libs.openjsse)
|
||||
|
||||
api(libs.amazonCorretto)
|
||||
|
||||
api(libs.hamcrestLibrary)
|
||||
api(libs.junit.jupiter.api)
|
||||
api(libs.junit.jupiter.params)
|
||||
|
||||
api(libs.junit.pioneer)
|
||||
|
||||
compileOnly(libs.findbugs.jsr305)
|
||||
compileOnly(libs.robolectric.android)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val jvmMainApi by configurations.getting
|
||||
|
||||
dependencies {
|
||||
jvmMainApi(variantOf(libs.amazonCorretto) {
|
||||
api(libs.squareup.okio)
|
||||
api(projects.okhttp)
|
||||
api(projects.okhttpTls)
|
||||
api(libs.assertj.core)
|
||||
api(libs.assertk)
|
||||
api(libs.bouncycastle.bcprov)
|
||||
implementation(libs.bouncycastle.bcpkix)
|
||||
implementation(libs.bouncycastle.bctls)
|
||||
api(libs.conscrypt.openjdk)
|
||||
api(libs.openjsse)
|
||||
|
||||
api(variantOf(libs.amazonCorretto) {
|
||||
classifier("linux-x86_64")
|
||||
})
|
||||
|
||||
api(libs.hamcrestLibrary)
|
||||
api(libs.junit.jupiter.api)
|
||||
api(libs.junit.jupiter.params)
|
||||
|
||||
api(libs.junit.pioneer)
|
||||
|
||||
compileOnly(libs.findbugs.jsr305)
|
||||
compileOnly(libs.robolectric.android)
|
||||
|
||||
}
|
||||
|
||||
animalsniffer {
|
||||
|
@@ -15,10 +15,11 @@
|
||||
*/
|
||||
package okhttp3
|
||||
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.containsExactly
|
||||
import java.net.InetAddress
|
||||
import java.net.UnknownHostException
|
||||
import okio.Buffer
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
|
||||
class FakeDns : Dns {
|
||||
private val hostAddresses: MutableMap<String, List<InetAddress>> = mutableMapOf()
|
@@ -15,15 +15,17 @@
|
||||
*/
|
||||
package okhttp3
|
||||
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isCloseTo
|
||||
import assertk.assertions.isFalse
|
||||
import assertk.assertions.isInstanceOf
|
||||
import assertk.assertions.matchesPredicate
|
||||
import java.util.Deque
|
||||
import java.util.concurrent.ConcurrentLinkedDeque
|
||||
import java.util.concurrent.TimeUnit
|
||||
import okhttp3.ConnectionEvent.NoNewExchanges
|
||||
import okhttp3.internal.connection.RealConnection
|
||||
import okhttp3.internal.platform.Platform
|
||||
import okio.IOException
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.data.Offset
|
||||
import org.junit.jupiter.api.Assertions
|
||||
|
||||
open class RecordingConnectionListener(
|
||||
@@ -88,7 +90,7 @@ open class RecordingConnectionListener(
|
||||
TimeUnit.NANOSECONDS.toMillis(actualElapsedNs)
|
||||
.toDouble()
|
||||
)
|
||||
.isCloseTo(elapsedMs.toDouble(), Offset.offset(100.0))
|
||||
.isCloseTo(elapsedMs.toDouble(), 100.0)
|
||||
}
|
||||
|
||||
return result
|
||||
@@ -104,13 +106,11 @@ open class RecordingConnectionListener(
|
||||
|
||||
private fun logEvent(e: ConnectionEvent) {
|
||||
if (e.connection != null) {
|
||||
assertThat(Thread.holdsLock(e.connection))
|
||||
.overridingErrorMessage("Called with lock $${e.connection}")
|
||||
assertThat(Thread.holdsLock(e.connection), "Called with lock $${e.connection}")
|
||||
.isFalse()
|
||||
}
|
||||
for (lock in forbiddenLocks) {
|
||||
assertThat(Thread.holdsLock(lock))
|
||||
.overridingErrorMessage("Called with lock $lock")
|
||||
assertThat(Thread.holdsLock(lock), "Called with lock $lock")
|
||||
.isFalse()
|
||||
}
|
||||
|
||||
@@ -153,7 +153,9 @@ open class RecordingConnectionListener(
|
||||
override fun connectionReleased(connection: Connection, call: Call) {
|
||||
if (eventSequence.find { it is ConnectionEvent.ConnectStart && it.connection == connection } != null && connection is RealConnection) {
|
||||
if (connection.noNewExchanges) {
|
||||
assertThat(eventSequence).anyMatch { it is NoNewExchanges && it.connection == connection }
|
||||
assertThat(eventSequence).matchesPredicate { deque ->
|
||||
deque.any { it is NoNewExchanges && it.connection == connection }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package okhttp3
|
||||
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.containsExactly
|
||||
import java.util.ArrayDeque
|
||||
import java.util.Deque
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
|
||||
class RecordingCookieJar : CookieJar {
|
||||
private val requestCookies: Deque<List<Cookie>> = ArrayDeque()
|
@@ -15,6 +15,11 @@
|
||||
*/
|
||||
package okhttp3
|
||||
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isCloseTo
|
||||
import assertk.assertions.isFalse
|
||||
import assertk.assertions.isInstanceOf
|
||||
import assertk.assertions.matchesPredicate
|
||||
import java.io.IOException
|
||||
import java.net.InetAddress
|
||||
import java.net.InetSocketAddress
|
||||
@@ -51,11 +56,7 @@ import okhttp3.CallEvent.ResponseHeadersStart
|
||||
import okhttp3.CallEvent.SatisfactionFailure
|
||||
import okhttp3.CallEvent.SecureConnectEnd
|
||||
import okhttp3.CallEvent.SecureConnectStart
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.data.Offset
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Assertions.fail
|
||||
import org.junit.jupiter.api.fail
|
||||
|
||||
open class RecordingEventListener(
|
||||
/**
|
||||
@@ -119,7 +120,7 @@ open class RecordingEventListener(
|
||||
TimeUnit.NANOSECONDS.toMillis(actualElapsedNs)
|
||||
.toDouble()
|
||||
)
|
||||
.isCloseTo(elapsedMs.toDouble(), Offset.offset(100.0))
|
||||
.isCloseTo(elapsedMs.toDouble(), 100.0)
|
||||
}
|
||||
|
||||
return result
|
||||
@@ -135,9 +136,7 @@ open class RecordingEventListener(
|
||||
|
||||
private fun logEvent(e: CallEvent) {
|
||||
for (lock in forbiddenLocks) {
|
||||
assertThat(Thread.holdsLock(lock))
|
||||
.overridingErrorMessage(lock.toString())
|
||||
.isFalse()
|
||||
assertThat(Thread.holdsLock(lock), lock.toString()).isFalse()
|
||||
}
|
||||
|
||||
if (enforceOrder) {
|
||||
@@ -149,7 +148,7 @@ open class RecordingEventListener(
|
||||
|
||||
private fun checkForStartEvent(e: CallEvent) {
|
||||
if (eventSequence.isEmpty()) {
|
||||
assertThat(e).isInstanceOfAny(CallStart::class.java, Canceled::class.java)
|
||||
assertThat(e).matchesPredicate { it is CallStart || it is Canceled }
|
||||
} else {
|
||||
eventSequence.forEach loop@ {
|
||||
when (e.closes(it)) {
|
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package okhttp3.internal.concurrent
|
||||
|
||||
import okhttp3.OkHttpClient
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEmpty
|
||||
import java.io.Closeable
|
||||
import java.util.AbstractQueue
|
||||
import java.util.concurrent.BlockingQueue
|
||||
@@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.logging.Logger
|
||||
import kotlin.concurrent.withLock
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
/**
|
||||
* Runs a [TaskRunner] in a controlled environment so that everything is sequential and
|
@@ -16,6 +16,8 @@
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
package okhttp3.internal.http
|
||||
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.containsExactly
|
||||
import java.io.IOException
|
||||
import java.net.InetSocketAddress
|
||||
import java.net.Proxy
|
||||
@@ -23,7 +25,6 @@ import java.net.ProxySelector
|
||||
import java.net.SocketAddress
|
||||
import java.net.URI
|
||||
import okhttp3.internal.format
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
|
||||
class RecordingProxySelector : ProxySelector() {
|
||||
@JvmField val proxies = mutableListOf<Proxy>()
|
Reference in New Issue
Block a user