This is a JUnit extension that shards the tests for parallel execution.
It selects tests by hashing the test class and method name.
Tests are sharded if these environment variables are present:
import java.awt.Rectangle | |
import java.io.Closeable | |
import java.io.IOException | |
import java.util.zip.CRC32 | |
import okio.Buffer | |
import okio.BufferedSink | |
import okio.BufferedSource | |
import okio.ByteString | |
import okio.ByteString.Companion.encodeUtf8 | |
import okio.ByteString.Companion.toByteString |
import java.io.BufferedReader; | |
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.net.URL; | |
import java.net.URLClassLoader; | |
import java.util.jar.JarOutputStream; | |
import java.util.zip.ZipEntry; | |
import static java.nio.charset.StandardCharsets.UTF_8; |
@Test | |
fun closeAJarFileWhileSomebodyIsReadingIt() { | |
val someJarResource = this::class.java.classLoader.getResource("LICENSE-junit.txt")!! | |
val connectionA = someJarResource.openConnection() | |
val sourceA = connectionA.getInputStream().source().buffer() | |
val connectionB = someJarResource.openConnection() | |
val sourceB = connectionB.getInputStream().source().buffer() |
/* | |
* Copyright (C) 2021 Square, Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
import okio.buffer | |
import okio.source | |
/** | |
* Converts a Kotlin file with `backtick method names` to camelCaseMethodNames. | |
*/ | |
fun main() { | |
val source = System.`in`.source().buffer() | |
while (true) { | |
val line = source.readUtf8Line() ?: break |
public final long readVarint64() throws IOException { | |
if (this.state != 0 && this.state != 2) { | |
throw (Throwable)(new ProtocolException("Expected VARINT or LENGTH_DELIMITED but was " + this.state)); | |
} else { | |
int shift = 0; | |
for(long result = 0L; shift < 64; shift += 7) { | |
this.source.require(1L); | |
int var10001 = this.pos++; | |
byte b = this.source.readByte(); |
package okio.samples | |
import okio.Buffer | |
import okio.BufferedSink | |
import okio.BufferedSource | |
import okio.buffer | |
import okio.source | |
import java.io.File | |
import java.util.concurrent.atomic.AtomicLong |
/* | |
* Copyright (C) 2020 Square, Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
import java.io.IOException; | |
import okhttp3.Interceptor; | |
import okhttp3.Response; | |
import static okhttp3.internal.http.StatusLine.HTTP_PERM_REDIRECT; | |
import static okhttp3.internal.http.StatusLine.HTTP_TEMP_REDIRECT; | |
/** | |
* In OkHttp 4.5 and earlier, HTTP 307 and 308 redirects were only honored if the request method | |
* was GET or HEAD. |