Package org.kohsuke.github.extras
Class OkHttpConnectorTest
- java.lang.Object
-
- org.kohsuke.github.AbstractGitHubWireMockTest
-
- org.kohsuke.github.extras.OkHttpConnectorTest
-
public class OkHttpConnectorTest extends AbstractGitHubWireMockTest
Test showing the behavior of OkHttpConnector with and without cache.Key take aways:
- These tests are artificial and intended to highlight the differences in behavior between scenarios. However, the differences they indicate are stark.
- Caching reduces rate limit consumption by at least a factor of two in even the simplest case.
- The OkHttp cache is pretty smart and will often connect read and write requests made on the same client and invalidate caches.
- Changes made outside the current client cause the OkHttp cache to return stale data. This is expected and correct behavior.
- "max-age=0" addresses the problem of external changes by revalidating caches for each request. This produces the same number of requests as OkHttp without caching, but those requests only count towards the GitHub rate limit if data has changes.
- Author:
- Liam Newman
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.kohsuke.github.AbstractGitHubWireMockTest
AbstractGitHubWireMockTest.TemplatingHelper
-
-
Field Summary
-
Fields inherited from class org.kohsuke.github.AbstractGitHubWireMockTest
baseFilesClassPath, baseRecordPath, gitHub, mockGitHub, tempGitHubRepositories, templating, useDefaultGitHub
-
-
Constructor Summary
Constructors Constructor Description OkHttpConnectorTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidDefaultConnector()protected com.github.tomakehurst.wiremock.core.WireMockConfigurationgetWireMockOptions()voidOkHttpConnector_Cache_MaxAge_Three()voidOkHttpConnector_Cache_MaxAgeDefault_Zero()voidOkHttpConnector_Cache_MaxAgeNone()voidOkHttpConnector_NoCache()voidsetupRepo()-
Methods inherited from class org.kohsuke.github.AbstractGitHubWireMockTest
assertThat, assertThat, assertThat, cleanupRepository, cleanupTempRepositories, fail, fail, getGitHubBuilder, getNonRecordingGitHub, getTempRepository, getTempRepository, getUser, getUser, kohsuke, requireProxy, snapshotNotAllowed, verifyAuthenticated, wireMockSetup
-
-
-
-
Method Detail
-
getWireMockOptions
protected com.github.tomakehurst.wiremock.core.WireMockConfiguration getWireMockOptions()
- Overrides:
getWireMockOptionsin classAbstractGitHubWireMockTest
-
OkHttpConnector_Cache_MaxAgeNone
public void OkHttpConnector_Cache_MaxAgeNone() throws Exception- Throws:
Exception
-
OkHttpConnector_Cache_MaxAge_Three
public void OkHttpConnector_Cache_MaxAge_Three() throws Exception- Throws:
Exception
-
-