Class OkHttpGitHubConnectorTest

java.lang.Object
org.kohsuke.github.AbstractGitHubWireMockTest
org.kohsuke.github.extras.okhttp3.OkHttpGitHubConnectorTest

public class OkHttpGitHubConnectorTest extends AbstractGitHubWireMockTest
Test showing the behavior of OkHttpGitHubConnector 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
  • Constructor Details

    • OkHttpGitHubConnectorTest

      public OkHttpGitHubConnectorTest()
      Instantiates a new ok http git hub connector test.
  • Method Details

    • getWireMockOptions

      protected com.github.tomakehurst.wiremock.core.WireMockConfiguration getWireMockOptions()
      Gets the wire mock options.
      Overrides:
      getWireMockOptions in class AbstractGitHubWireMockTest
      Returns:
      the wire mock options
    • setupRepo

      public void setupRepo() throws Exception
      Setup repo.
      Throws:
      Exception - the exception
    • deleteCache

      public void deleteCache() throws IOException
      Delete cache.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • DefaultConnector

      public void DefaultConnector() throws Exception
      Default connector.
      Throws:
      Exception - the exception
    • OkHttpConnector_NoCache

      public void OkHttpConnector_NoCache() throws Exception
      Ok http connector no cache.
      Throws:
      Exception - the exception
    • OkHttpConnector_Cache_MaxAgeNone

      public void OkHttpConnector_Cache_MaxAgeNone() throws Exception
      Ok http connector cache max age none.
      Throws:
      Exception - the exception
    • OkHttpConnector_Cache_MaxAge_Three

      public void OkHttpConnector_Cache_MaxAge_Three() throws Exception
      Ok http connector cache max age three.
      Throws:
      Exception - the exception
    • OkHttpConnector_Cache_MaxAgeDefault_Zero

      public void OkHttpConnector_Cache_MaxAgeDefault_Zero() throws Exception
      Ok http connector cache max age default zero.
      Throws:
      Exception - the exception