Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 16 for Sleep (0.14 sec)

  1. mockwebserver-deprecated/src/test/java/okhttp3/mockwebserver/MockWebServerTest.kt

       * response is ready.
       */
      @Test
      fun dispatchBlocksWaitingForEnqueue() {
        Thread {
          try {
            Thread.sleep(1000)
          } catch (ignored: InterruptedException) {
          }
          server.enqueue(MockResponse().setBody("enqueued in the background"))
        }.start()
        val connection = server.url("/").toUrl().openConnection()
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 21.9K bytes
    - Viewed (0)
  2. okhttp/src/test/java/okhttp3/WholeOperationTimeoutTest.kt

          Request.Builder()
            .url(server.url("/"))
            .build()
        val call = client.newCall(request)
        call.timeout().timeout(250, TimeUnit.MILLISECONDS)
        val response = call.execute()
        Thread.sleep(500)
        assertFailsWith<IOException> {
          response.body.source().readUtf8()
        }.also { expected ->
          assertThat(expected.message).isEqualTo("timeout")
          assertThat(call.isCanceled()).isTrue()
        }
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 10.5K bytes
    - Viewed (0)
  3. samples/guide/src/main/java/okhttp3/recipes/kt/WiresharkExample.kt

        try {
          for (i in 1..2) {
            // Space out traffic to make it easier to demarcate.
            sendTestRequest(fbRequest)
            Thread.sleep(1000)
            sendTestRequest(twitterRequest)
            Thread.sleep(1000)
            sendTestRequest(googleRequest)
            Thread.sleep(2000)
          }
        } finally {
          client.connectionPool.evictAll()
          client.dispatcher.executorService.shutdownNow()
    
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 10.7K bytes
    - Viewed (1)
  4. okhttp/src/test/java/okhttp3/internal/ws/WebSocketHttpTest.kt

            .build(),
        )
        val webSocket: WebSocket = newWebSocket()
        clientListener.assertOpen()
        val server = serverListener.assertOpen()
    
        // Sleep longer than the HTTP client's read timeout.
        Thread.sleep((client.readTimeoutMillis + 500).toLong())
        server.send("abc")
        clientListener.assertTextMessage("abc")
        closeWebSockets(webSocket, server)
      }
    
      @Test
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Sun Mar 31 17:16:15 GMT 2024
    - 35.2K bytes
    - Viewed (1)
  5. okhttp-dnsoverhttps/src/test/java/okhttp3/dnsoverhttps/DnsOverHttpsTest.kt

        assertThat(recordedRequest!!.method).isEqualTo("GET")
        assertThat(recordedRequest.path).isEqualTo(
          "/lookup?ct&dns=AAABAAABAAAAAAAABmdvb2dsZQNjb20AAAEAAQ",
        )
        Thread.sleep(2000)
        server.enqueue(
          dnsResponse(
            "0000818000010003000000000567726170680866616365626f6f6b03636f6d0000010001c00c000500010" +
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Wed Apr 10 19:46:48 GMT 2024
    - 11K bytes
    - Viewed (0)
  6. okhttp-testing-support/src/main/kotlin/okhttp3/internal/concurrent/TaskFaker.kt

          yieldUntil(ResumePriority.BeforeOtherTasks) {
            contextSwitchCount > contextSwitchCountBefore
          }
        }
      }
    
      /** Sleep until [durationNanos] elapses. For use by the task threads. */
      fun sleep(durationNanos: Long) {
        taskRunner.lock.withLock {
          val sleepUntil = nanoTime + durationNanos
          yieldUntil { nanoTime >= sleepUntil }
        }
      }
    
      /**
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Apr 29 00:33:04 GMT 2024
    - 12.6K bytes
    - Viewed (0)
  7. okhttp/src/test/java/okhttp3/internal/connection/ConnectionPoolTest.kt

        assertThat(realTaskRunner.activeQueues()).isNotEmpty()
        Thread.sleep(100)
        val threads = arrayOfNulls<Thread>(Thread.activeCount() * 2)
        Thread.enumerate(threads)
        for (t in threads) {
          if (t != null && t.name == "OkHttp TaskRunner") {
            t.interrupt()
          }
        }
        Thread.sleep(100)
        assertThat(realTaskRunner.activeQueues()).isEmpty()
      }
    
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Wed Apr 24 04:40:49 GMT 2024
    - 12.7K bytes
    - Viewed (0)
  8. mockwebserver/src/main/kotlin/mockwebserver3/MockResponse.kt

        fun socketPolicy(socketPolicy: SocketPolicy) =
          apply {
            this.socketPolicy = socketPolicy
          }
    
        /**
         * Throttles the request reader and response writer to sleep for the given period after each
         * series of [bytesPerPeriod] bytes are transferred. Use this to simulate network behavior.
         */
        fun throttleBody(
          bytesPerPeriod: Long,
          period: Long,
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Tue Jan 23 14:31:42 GMT 2024
    - 13.3K bytes
    - Viewed (1)
  9. okhttp/src/main/kotlin/okhttp3/internal/concurrent/TaskRunner.kt

          var readyTask: Task? = null
          var multipleReadyTasks = false
    
          // Decide what to run. This loop's goal wants to:
          //  * Find out what this thread should do (either run a task or sleep)
          //  * Find out if there's enough work to start another thread.
          eachQueue@ for (queue in readyQueues) {
            val candidate = queue.futureTasks[0]
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Apr 29 00:33:04 GMT 2024
    - 10.6K bytes
    - Viewed (0)
  10. okhttp/src/test/java/okhttp3/DuplexTest.kt

        }
      }
    
      @Test
      fun fullCallTimeoutDoesNotApplyOnceConnected() {
        enableProtocol(Protocol.HTTP_2)
        val body =
          MockStreamHandler()
            .sendResponse("response A\n")
            .sleep(750, TimeUnit.MILLISECONDS)
            .sendResponse("response B\n")
            .receiveRequest("request C\n")
            .exhaustResponse()
            .exhaustRequest()
        server.enqueue(
          MockResponse.Builder()
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Sat Jan 20 10:30:28 GMT 2024
    - 23.9K bytes
    - Viewed (0)
Back to top