11package org .kohsuke .github ;
22
3+ import java .io .FileNotFoundException ;
34import java .io .IOException ;
45import java .lang .reflect .Field ;
56import java .util .Collections ;
67import java .util .HashMap ;
78import java .util .Map ;
8- import java .util .Properties ;
99
10- import junit .framework .TestCase ;
10+ import org .junit .Test ;
11+
12+ import static org .hamcrest .CoreMatchers .notNullValue ;
13+ import static org .hamcrest .MatcherAssert .assertThat ;
14+ import static org .junit .Assert .assertEquals ;
15+ import static org .mockito .Mockito .spy ;
16+ import static org .mockito .Mockito .when ;
1117
1218/**
1319 * Unit test for {@link GitHub}.
1420 */
15- public class GitHubTest extends TestCase {
16-
21+ public class GitHubTest {
22+ @ Test
1723 public void testGitHubServerWithHttp () throws Exception {
1824 GitHub hub = GitHub .connectToEnterprise ("http://enterprise.kohsuke.org/api/v3" , "bogus" ,"bogus" );
1925 assertEquals ("http://enterprise.kohsuke.org/api/v3/test" , hub .getApiURL ("/test" ).toString ());
2026 }
21-
27+ @ Test
2228 public void testGitHubServerWithHttps () throws Exception {
2329 GitHub hub = GitHub .connectToEnterprise ("https://enterprise.kohsuke.org/api/v3" , "bogus" ,"bogus" );
2430 assertEquals ("https://enterprise.kohsuke.org/api/v3/test" , hub .getApiURL ("/test" ).toString ());
2531 }
26-
32+ @ Test
2733 public void testGitHubServerWithoutServer () throws Exception {
2834 GitHub hub = GitHub .connectUsingPassword ("kohsuke" , "bogus" );
2935 assertEquals ("https://api.github.com/test" , hub .getApiURL ("/test" ).toString ());
3036 }
31-
37+ @ Test
3238 public void testGitHubBuilderFromEnvironment () throws IOException {
3339
3440 Map <String , String >props = new HashMap <String , String >();
@@ -86,7 +92,7 @@ private void setupEnvironment(Map<String, String> newenv) {
8692 e1 .printStackTrace ();
8793 }
8894 }
89-
95+ @ Test
9096 public void testGitHubBuilderFromCustomEnvironment () throws IOException {
9197 Map <String , String > props = new HashMap <String , String >();
9298
@@ -105,4 +111,12 @@ public void testGitHubBuilderFromCustomEnvironment() throws IOException {
105111 assertEquals ("bogusEndpoint" , builder .endpoint );
106112 }
107113
114+ @ Test
115+ public void testGitHubEnterpriseDoesNotHaveRateLimit () throws IOException {
116+ GitHub github = spy (new GitHubBuilder ().build ());
117+ when (github .retrieve ()).thenThrow (FileNotFoundException .class );
118+
119+ GHRateLimit rateLimit = github .getRateLimit ();
120+ assertThat (rateLimit .getResetDate (), notNullValue ());
121+ }
108122}
0 commit comments