mirror of
https://github.com/square/okhttp.git
synced 2025-11-23 06:42:24 +03:00
Fix android tests (#7464)
This commit is contained in:
@@ -84,13 +84,15 @@ import javax.net.ssl.SSLPeerUnverifiedException
|
|||||||
import javax.net.ssl.SSLSocket
|
import javax.net.ssl.SSLSocket
|
||||||
import javax.net.ssl.TrustManagerFactory
|
import javax.net.ssl.TrustManagerFactory
|
||||||
import javax.net.ssl.X509TrustManager
|
import javax.net.ssl.X509TrustManager
|
||||||
|
import org.junit.jupiter.api.BeforeEach
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run with "./gradlew :android-test:connectedCheck" and make sure ANDROID_SDK_ROOT is set.
|
* Run with "./gradlew :android-test:connectedCheck" and make sure ANDROID_SDK_ROOT is set.
|
||||||
*/
|
*/
|
||||||
@ExtendWith(MockWebServerExtension::class)
|
@ExtendWith(MockWebServerExtension::class)
|
||||||
@Tag("Slow")
|
@Tag("Slow")
|
||||||
class OkHttpTest(val server: MockWebServer) {
|
class OkHttpTest {
|
||||||
|
|
||||||
@Suppress("RedundantVisibilityModifier")
|
@Suppress("RedundantVisibilityModifier")
|
||||||
@JvmField
|
@JvmField
|
||||||
@RegisterExtension public val platform = PlatformRule()
|
@RegisterExtension public val platform = PlatformRule()
|
||||||
@@ -109,6 +111,13 @@ class OkHttpTest(val server: MockWebServer) {
|
|||||||
|
|
||||||
private val handshakeCertificates = localhost()
|
private val handshakeCertificates = localhost()
|
||||||
|
|
||||||
|
private lateinit var server: MockWebServer
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
fun setup(server: MockWebServer) {
|
||||||
|
this.server = server
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testPlatform() {
|
fun testPlatform() {
|
||||||
assertTrue(Platform.isAndroid)
|
assertTrue(Platform.isAndroid)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ import org.opentest4j.TestAbortedException
|
|||||||
* Run with "./gradlew :android-test:connectedCheck" and make sure ANDROID_SDK_ROOT is set.
|
* Run with "./gradlew :android-test:connectedCheck" and make sure ANDROID_SDK_ROOT is set.
|
||||||
*/
|
*/
|
||||||
@ExtendWith(MockWebServerExtension::class)
|
@ExtendWith(MockWebServerExtension::class)
|
||||||
class AndroidAsyncDnsTest(val server: MockWebServer) {
|
class AndroidAsyncDnsTest {
|
||||||
private val localhostName: String = InetAddress.getByName("localhost").canonicalHostName
|
private val localhostName: String = InetAddress.getByName("localhost").canonicalHostName
|
||||||
|
|
||||||
private val localhost: HandshakeCertificates by lazy {
|
private val localhost: HandshakeCertificates by lazy {
|
||||||
@@ -65,8 +65,11 @@ class AndroidAsyncDnsTest(val server: MockWebServer) {
|
|||||||
.sslSocketFactory(localhost.sslSocketFactory(), localhost.trustManager)
|
.sslSocketFactory(localhost.sslSocketFactory(), localhost.trustManager)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
private lateinit var server: MockWebServer
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun init() {
|
fun init(server: MockWebServer) {
|
||||||
|
this.server = server
|
||||||
server.useHttps(localhost.sslSocketFactory())
|
server.useHttps(localhost.sslSocketFactory())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user