Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
Expand Down Expand Up @@ -621,6 +625,18 @@
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<!-- select non-aggregate reports -->
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand Down
28 changes: 14 additions & 14 deletions src/test/java/org/kohsuke/github/GHRateLimitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ public void testGitHubRateLimit() throws Exception {
GHRateLimit headerRateLimit = rateLimit;

// Give this a moment
Thread.sleep(1000);
Thread.sleep(1500);

// ratelimit() uses headerRateLimit if available and headerRateLimit is not expired
assertThat(gitHub.rateLimit(), equalTo(headerRateLimit));

assertThat(mockGitHub.getRequestCount(), equalTo(1));

// Give this a moment
Thread.sleep(1000);
Thread.sleep(1500);

// Always requests new info
rateLimit = gitHub.getRateLimit();
Expand All @@ -96,7 +96,7 @@ public void testGitHubRateLimit() throws Exception {
previousLimit = rateLimit;

// Give this a moment
Thread.sleep(1000);
Thread.sleep(1500);

// Always requests new info
rateLimit = gitHub.getRateLimit();
Expand Down Expand Up @@ -200,7 +200,7 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception {
Date lastReset = new Date(System.currentTimeMillis() / 1000L);

// Give this a moment
Thread.sleep(1000);
Thread.sleep(1500);

// -------------------------------------------------------------
// Before any queries, rate limit starts as null but may be requested
Expand All @@ -224,7 +224,7 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception {
assertThat(mockGitHub.getRequestCount(), equalTo(1));

// Give this a moment
Thread.sleep(1000);
Thread.sleep(1500);

// -------------------------------------------------------------
// First call to /user gets response without rate limit information
Expand All @@ -244,7 +244,7 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception {
assertThat(mockGitHub.getRequestCount(), equalTo(3));

// Give this a moment
Thread.sleep(1000);
Thread.sleep(1500);

// Always requests new info
rateLimit = gitHub.getRateLimit();
Expand All @@ -256,13 +256,13 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception {
assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1));

// Give this a moment
Thread.sleep(1000);
Thread.sleep(1500);

// last is still null, because it actually means lastHeaderRateLimit
assertThat(gitHub.lastRateLimit(), CoreMatchers.nullValue());

// ratelimit() tries not to make additional requests, uses queried rate limit since header not available
Thread.sleep(1000);
Thread.sleep(1500);
assertThat(gitHub.rateLimit(), sameInstance(rateLimit));

// -------------------------------------------------------------
Expand All @@ -283,15 +283,15 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception {
GHRateLimit headerRateLimit = rateLimit;

// Give this a moment
Thread.sleep(1000);
Thread.sleep(1500);

// ratelimit() uses headerRateLimit if available and headerRateLimit is not expired
assertThat(gitHub.rateLimit(), sameInstance(headerRateLimit));

assertThat(mockGitHub.getRequestCount(), equalTo(5));

// Give this a moment
Thread.sleep(1000);
Thread.sleep(1500);

// Always requests new info
rateLimit = gitHub.getRateLimit();
Expand All @@ -308,7 +308,7 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception {
assertThat(mockGitHub.getRequestCount(), equalTo(6));

// Wait for the header
Thread.sleep(1000);
Thread.sleep(1500);
}

@Test
Expand Down Expand Up @@ -361,7 +361,7 @@ private void executeExpirationTest() throws Exception {
GHRateLimit headerRateLimit = null;

// Give this a moment
Thread.sleep(1000);
Thread.sleep(1500);

// -------------------------------------------------------------
// /user gets response with rate limit information
Expand All @@ -380,7 +380,7 @@ private void executeExpirationTest() throws Exception {
sameInstance(headerRateLimit));

// Nothing changes still valid
Thread.sleep(1000);
Thread.sleep(1500);

assertThat("rateLimit() selects header instance when not expired, does not ask server",
gitHub.rateLimit(),
Expand All @@ -392,7 +392,7 @@ private void executeExpirationTest() throws Exception {
assertThat(mockGitHub.getRequestCount(), equalTo(1));

// This time, rateLimit() should find an expired record and get a new one.
Thread.sleep(3000);
Thread.sleep(2500);

assertThat("Header instance has expired", gitHub.lastRateLimit().isExpired(), is(true));

Expand Down