Skip to content

Instantly share code, notes, and snippets.

🍩
busy busy

Jesse Wilson swankjesse

🍩
busy busy
View GitHub Profile
@swankjesse
swankjesse / ConcurrencyBenchmark.kt
Created Jun 13, 2020
Compare concurrency of various SegmentPool strategies
View ConcurrencyBenchmark.kt
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
View AtomicBitSet.kt
/*
* 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
View README.md

JUnit Test Sharding

This is a JUnit extension that shards the tests for parallel execution.

It selects tests by hashing the test class and method name.

Configuration

Tests are sharded if these environment variables are present:

View LegacyRedirectInterceptor.java
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.
View ResetTest.kt
/*
* 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
View Fibonacci.kt
import java.math.BigInteger
interface Fibonacci {
fun fib(n: Int): Int
}
object LawfulGood : Fibonacci {
override fun fib(n: Int): Int {
check(n >= 0) { "fib is undefined for negative values: $n" }
return when (n) {
View InternetDomainNameTest.java
/*
* Copyright (C) 2009 The Guava Authors
*
* 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
View CompletableFutureGet.java
/*
* Copyright (C) 2014 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
@swankjesse
swankjesse / BytesAndValueTest.kt
Created May 31, 2019
Retrofit converter that gives you both the raw response bytes and the converted object
View BytesAndValueTest.kt
import okhttp3.ResponseBody
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import okio.ByteString
import okio.ByteString.Companion.encodeUtf8
import org.assertj.core.api.Assertions.assertThat
import org.junit.Rule
import org.junit.Test
import retrofit2.Call
import retrofit2.Converter
View Java_decompiled_Credentials.java
// JAVA DECOMPILED
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package okhttp3;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
You can’t perform that action at this time.