|
12 | 12 | */
|
13 | 13 | public class GitHubRepositoryNameTest {
|
14 | 14 |
|
| 15 | + private void testURL(String URL, String host, String owner, String repository) |
| 16 | + { |
| 17 | + GitHubRepositoryName repo = GitHubRepositoryName.create(URL); |
| 18 | + assertNotNull(repo); |
| 19 | + assertEquals(host, repo.host); |
| 20 | + assertEquals(owner, repo.userName); |
| 21 | + assertEquals(repository, repo.repositoryName); |
| 22 | + } |
| 23 | + |
15 | 24 | @Test
|
16 | 25 | public void gitAtUrlGitHub() {
|
17 |
| - GitHubRepositoryName repo = GitHubRepositoryName |
18 |
| - .create("git@github.com:jenkinsci/jenkins.git"); |
19 |
| - assertNotNull(repo); |
20 |
| - assertEquals("jenkinsci", repo.userName); |
21 |
| - assertEquals("jenkins", repo.repositoryName); |
22 |
| - assertEquals("github.com", repo.host); |
| 26 | + testURL("git@github.com:jenkinsci/jenkins.git", "github.com", "jenkinsci", "jenkins"); |
23 | 27 | }
|
24 | 28 |
|
25 | 29 | @Test
|
26 | 30 | public void gitAtUrlOtherHost() {
|
27 |
| - GitHubRepositoryName repo = GitHubRepositoryName |
28 |
| - .create("git@gh.company.com:jenkinsci/jenkins.git"); |
29 |
| - assertNotNull(repo); |
30 |
| - assertEquals("jenkinsci", repo.userName); |
31 |
| - assertEquals("jenkins", repo.repositoryName); |
32 |
| - assertEquals("gh.company.com", repo.host); |
| 31 | + testURL("git@gh.company.com:jenkinsci/jenkins.git", "gh.company.com", "jenkinsci", "jenkins"); |
33 | 32 | }
|
34 | 33 |
|
35 | 34 | @Test
|
36 | 35 | public void gitColonUrlGitHub() {
|
37 |
| - GitHubRepositoryName repo = GitHubRepositoryName |
38 |
| - .create("git://github.com/jenkinsci/jenkins.git"); |
39 |
| - assertNotNull(repo); |
40 |
| - assertEquals("jenkinsci", repo.userName); |
41 |
| - assertEquals("jenkins", repo.repositoryName); |
42 |
| - assertEquals("github.com", repo.host); |
| 36 | + testURL("git://github.com/jenkinsci/jenkins.git", "github.com", "jenkinsci", "jenkins"); |
43 | 37 | }
|
44 | 38 |
|
45 | 39 | @Test
|
46 | 40 | public void gitColonUrlOtherHost() {
|
47 |
| - GitHubRepositoryName repo = GitHubRepositoryName |
48 |
| - .create("git://company.net/jenkinsci/jenkins.git"); |
49 |
| - assertNotNull(repo); |
50 |
| - assertEquals("jenkinsci", repo.userName); |
51 |
| - assertEquals("jenkins", repo.repositoryName); |
52 |
| - assertEquals("company.net", repo.host); |
| 41 | + testURL("git://company.net/jenkinsci/jenkins.git", "company.net", "jenkinsci", "jenkins"); |
53 | 42 | }
|
54 | 43 |
|
55 | 44 | @Test
|
56 | 45 | public void httpsUrlGitHub() {
|
57 |
| - GitHubRepositoryName repo = GitHubRepositoryName |
58 |
| - .create("https://user@github.com/jenkinsci/jenkins.git"); |
59 |
| - assertNotNull(repo); |
60 |
| - assertEquals("jenkinsci", repo.userName); |
61 |
| - assertEquals("jenkins", repo.repositoryName); |
62 |
| - assertEquals("github.com", repo.host); |
| 46 | + testURL("https://user@github.com/jenkinsci/jenkins.git", "github.com", "jenkinsci", "jenkins"); |
63 | 47 | }
|
64 | 48 |
|
65 | 49 | @Test
|
66 | 50 | public void httpsUrlGitHubWithoutUser() {
|
67 |
| - //this is valid for anonymous usage |
68 |
| - GitHubRepositoryName repo = GitHubRepositoryName |
69 |
| - .create("https://github.com/jenkinsci/jenkins.git"); |
70 |
| - assertNotNull(repo); |
71 |
| - assertEquals("jenkinsci", repo.userName); |
72 |
| - assertEquals("jenkins", repo.repositoryName); |
73 |
| - assertEquals("github.com", repo.host); |
| 51 | + testURL("https://github.com/jenkinsci/jenkins.git", "github.com", "jenkinsci", "jenkins"); |
74 | 52 | }
|
75 | 53 |
|
76 |
| - |
77 | 54 | @Test
|
78 | 55 | public void httpsUrlOtherHost() {
|
79 |
| - GitHubRepositoryName repo = GitHubRepositoryName |
80 |
| - .create("https://employee@gh.company.com/jenkinsci/jenkins.git"); |
81 |
| - assertNotNull(repo); |
82 |
| - assertEquals("jenkinsci", repo.userName); |
83 |
| - assertEquals("jenkins", repo.repositoryName); |
84 |
| - assertEquals("gh.company.com", repo.host); |
| 56 | + testURL("https://employee@gh.company.com/jenkinsci/jenkins.git", "gh.company.com", "jenkinsci", "jenkins"); |
| 57 | + } |
| 58 | + |
| 59 | + @Test |
| 60 | + public void gitAtUrlGitHubNoSuffix() { |
| 61 | + testURL("git@github.com:jenkinsci/jenkins", "github.com", "jenkinsci", "jenkins"); |
| 62 | + } |
| 63 | + |
| 64 | + @Test |
| 65 | + public void gitAtUrlOtherHostNoSuffix() { |
| 66 | + testURL("git@gh.company.com:jenkinsci/jenkins", "gh.company.com", "jenkinsci", "jenkins"); |
| 67 | + } |
| 68 | + |
| 69 | + @Test |
| 70 | + public void gitColonUrlGitHubNoSuffix() { |
| 71 | + testURL("git://github.com/jenkinsci/jenkins", "github.com", "jenkinsci", "jenkins"); |
| 72 | + } |
| 73 | + |
| 74 | + @Test |
| 75 | + public void gitColonUrlOtherHostNoSuffix() { |
| 76 | + testURL("git://company.net/jenkinsci/jenkins", "company.net", "jenkinsci", "jenkins"); |
| 77 | + } |
| 78 | + |
| 79 | + @Test |
| 80 | + public void httpsUrlGitHubNoSuffix() { |
| 81 | + testURL("https://user@github.com/jenkinsci/jenkins", "github.com", "jenkinsci", "jenkins"); |
| 82 | + } |
| 83 | + |
| 84 | + @Test |
| 85 | + public void httpsUrlGitHubWithoutUserNoSuffix() { |
| 86 | + testURL("https://github.com/jenkinsci/jenkins", "github.com", "jenkinsci", "jenkins"); |
| 87 | + } |
| 88 | + |
| 89 | + @Test |
| 90 | + public void httpsUrlOtherHostNoSuffix() { |
| 91 | + testURL("https://employee@gh.company.com/jenkinsci/jenkins", "gh.company.com", "jenkinsci", "jenkins"); |
85 | 92 | }
|
86 | 93 | }
|
0 commit comments