This repository was archived by the owner on Jul 31, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
src/test/java/org/kohsuke Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org .kohsuke ;
2+
3+ import org .apache .commons .io .IOUtils ;
4+ import org .junit .Assert ;
5+ import org .junit .Before ;
6+ import org .kohsuke .github .GitHub ;
7+
8+ import java .io .FileInputStream ;
9+ import java .util .Properties ;
10+
11+ /**
12+ * @author Kohsuke Kawaguchi
13+ */
14+ public abstract class AbstractGitHubApiTestBase extends Assert {
15+
16+ protected GitHub gitHub ;
17+
18+ @ Before
19+ public void setUp () throws Exception {
20+ Properties props = new Properties ();
21+ java .io .File f = new java .io .File (System .getProperty ("user.home" ), ".github.kohsuke2" );
22+ if (f .exists ()) {
23+ FileInputStream in = new FileInputStream (f );
24+ try {
25+ props .load (in );
26+ gitHub = GitHub .connect (props .getProperty ("login" ),props .getProperty ("oauth" ));
27+ } finally {
28+ IOUtils .closeQuietly (in );
29+ }
30+ } else {
31+ gitHub = GitHub .connect ();
32+ }
33+ }
34+ }
Original file line number Diff line number Diff line change 5959/**
6060 * Unit test for simple App.
6161 */
62- public class AppTest {
63-
64- private GitHub gitHub ;
65-
66- @ Before
67- public void setUp () throws Exception {
68- Properties props = new Properties ();
69- java .io .File f = new java .io .File (System .getProperty ("user.home" ), ".github.kohsuke2" );
70- if (f .exists ()) {
71- FileInputStream in = new FileInputStream (f );
72- try {
73- props .load (in );
74- gitHub = GitHub .connect (props .getProperty ("login" ),props .getProperty ("oauth" ));
75- } finally {
76- IOUtils .closeQuietly (in );
77- }
78- } else {
79- gitHub = GitHub .connect ();
80- }
81- }
82-
62+ public class AppTest extends AbstractGitHubApiTestBase {
8363 private String getTestRepositoryName () throws IOException {
8464 return getUser ().getLogin () + "/github-api-test" ;
8565 }
Original file line number Diff line number Diff line change 11package org .kohsuke ;
22
3- import junit .framework .TestCase ;
43import org .apache .commons .io .IOUtils ;
54import org .eclipse .jgit .api .Git ;
65import org .eclipse .jgit .api .errors .GitAPIException ;
76import org .eclipse .jgit .dircache .DirCache ;
87import org .eclipse .jgit .transport .UsernamePasswordCredentialsProvider ;
8+ import org .junit .Test ;
99import org .kohsuke .github .GHAsset ;
1010import org .kohsuke .github .GHIssue ;
1111import org .kohsuke .github .GHMilestone ;
1212import org .kohsuke .github .GHMyself ;
1313import org .kohsuke .github .GHRelease ;
1414import org .kohsuke .github .GHRepository ;
15- import org .kohsuke .github .GitHub ;
1615
1716import java .io .File ;
1817import java .io .FileInputStream ;
2221import java .util .List ;
2322import java .util .Properties ;
2423
25- public class LifecycleTest extends TestCase {
26- private GitHub gitHub ;
27-
28- @ Override
29- public void setUp () throws Exception {
30- super .setUp ();
31- gitHub = GitHub .connect ();
32- }
33-
24+ public class LifecycleTest extends AbstractGitHubApiTestBase {
25+ @ Test
3426 public void testCreateRepository () throws IOException , GitAPIException , InterruptedException {
3527 GHMyself myself = gitHub .getMyself ();
3628 GHRepository repository = myself .getRepository ("github-api-test" );
You can’t perform that action at this time.
0 commit comments