1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package test.de.smartics.ci.config.maven;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.is;
20
21 import org.junit.Before;
22 import org.junit.Test;
23
24 import de.smartics.ci.config.hudson.ScmType;
25 import de.smartics.ci.config.maven.MavenPom;
26 import de.smartics.testdoc.annotations.Uut;
27 import de.smartics.util.lang.BlankArgumentException;
28
29
30
31
32 public class MavenPomScmTest
33 {
34
35
36
37
38
39
40 @Uut(method = "setScmConnectionString(String)")
41 private MavenPom uut;
42
43
44
45
46
47
48
49 @Before
50 public void setUp()
51 {
52 uut = new MavenPom();
53 }
54
55
56
57
58
59 @Test(expected = BlankArgumentException.class)
60 public void rejectsNullAsConnectionString()
61 {
62 uut.setScmConnectionString(null);
63 }
64
65 @Test(expected = BlankArgumentException.class)
66 public void rejectsBlankAsConnectionString()
67 {
68 uut.setScmConnectionString("\n \t");
69 }
70
71 @Test(expected = IllegalArgumentException.class)
72 public void rejectsConnectionStringNotConformingToFormat()
73 {
74 uut.setScmConnectionString("abc:def:http://some/url");
75 }
76
77 @Test(expected = IllegalArgumentException.class)
78 public void rejectsConnectionStringNotStartingWithScmPrefix()
79 {
80 uut.setScmConnectionString("abc:svn:http://some/url");
81 }
82
83 @Test(expected = IllegalArgumentException.class)
84 public void rejectsConnectionStringNotProvidingScmType()
85 {
86 uut.setScmConnectionString("abc:/some/url");
87 }
88
89 @Test(expected = IllegalArgumentException.class)
90 public void rejectsConnectionStringNotProvidingScmTypeButHttpProtocol()
91 {
92 uut.setScmConnectionString("scm:http://some/url");
93 }
94
95 @Test(expected = IllegalArgumentException.class)
96 public void rejectsConnectionStringNotProvidingScmTypeButHttpsProtocol()
97 {
98 uut.setScmConnectionString("scm:https://some/url");
99 }
100
101 @Test(expected = IllegalArgumentException.class)
102 public void rejectsConnectionStringContainingOnlyScmPrefix()
103 {
104 uut.setScmConnectionString("scm:");
105 }
106
107 @Test(expected = IllegalArgumentException.class)
108 public void rejectsConnectionStringContainingNoUrl()
109 {
110 uut.setScmConnectionString("scm:svn:");
111 }
112
113 @Test(expected = IllegalArgumentException.class)
114 public void rejectsConnectionStringMissingScmTypeDelimiter()
115 {
116 uut.setScmConnectionString("scm:svn");
117 }
118
119 @Test
120 public void readsScmInfoFromScmConnectionString()
121 {
122 final String url = "http://some/url";
123 uut.setScmConnectionString("scm:svn:" + url);
124 final ScmType scmType = uut.getScmType();
125 assertThat(scmType, is(ScmType.SVN));
126 final String scmUrl = uut.getScmUrl();
127 assertThat(scmUrl, is(url));
128 }
129
130 @Test(expected = IllegalArgumentException.class)
131 public void rejectsUnknownScmType()
132 {
133 uut.setScmConnectionString("scm:unknown:http://some/url");
134 }
135 }