1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.scm.provider.svn.svnexe.command.changelog;
20
21 import java.io.File;
22 import java.util.Calendar;
23 import java.util.Date;
24
25 import org.apache.maven.scm.ScmBranch;
26 import org.apache.maven.scm.ScmRevision;
27 import org.apache.maven.scm.ScmTestCase;
28 import org.apache.maven.scm.ScmVersion;
29 import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
30 import org.apache.maven.scm.repository.ScmRepository;
31 import org.codehaus.plexus.util.cli.Commandline;
32 import org.junit.Test;
33
34
35
36
37
38 public class SvnChangeLogCommandTest extends ScmTestCase {
39 @Test
40 public void testCommandLineNoDates() throws Exception {
41 testCommandLine(
42 "scm:svn:http://foo.com/svn/trunk",
43 null,
44 null,
45 null,
46 "svn --non-interactive log -v http://foo.com/svn/trunk@");
47 }
48
49 @Test
50 public void testCommandLineNoDatesLimitedCount() throws Exception {
51 testCommandLine(
52 "scm:svn:http://foo.com/svn/trunk",
53 null,
54 null,
55 null,
56 40,
57 "svn --non-interactive log -v --limit 40 http://foo.com/svn/trunk@");
58 }
59
60 @Test
61 public void testCommandLineWithDates() throws Exception {
62 Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, GMT_TIME_ZONE);
63 Date endDate = getDate(2003, Calendar.OCTOBER, 10, GMT_TIME_ZONE);
64
65 testCommandLine(
66 "scm:svn:http://foo.com/svn/trunk",
67 null,
68 startDate,
69 endDate,
70 "svn --non-interactive log -v -r \"{2003-09-10 00:00:00 +0000}:{2003-10-10 00:00:00 +0000}\" http://foo.com/svn/trunk@");
71 }
72
73 @Test
74 public void testCommandLineStartDateOnly() throws Exception {
75 Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE);
76
77 testCommandLine(
78 "scm:svn:http://foo.com/svn/trunk",
79 null,
80 startDate,
81 null,
82 "svn --non-interactive log -v -r \"{2003-09-10 01:01:01 +0000}:HEAD\" http://foo.com/svn/trunk@");
83 }
84
85 @Test
86 public void testCommandLineDateFormat() throws Exception {
87 Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE);
88 Date endDate = getDate(2005, Calendar.NOVEMBER, 13, 23, 23, 23, GMT_TIME_ZONE);
89
90 testCommandLine(
91 "scm:svn:http://foo.com/svn/trunk",
92 null,
93 startDate,
94 endDate,
95 "svn --non-interactive log -v -r \"{2003-09-10 01:01:01 +0000}:{2005-11-13 23:23:23 +0000}\" http://foo.com/svn/trunk@");
96 }
97
98 @Test
99 public void testCommandLineEndDateOnly() throws Exception {
100 Date endDate = getDate(2003, Calendar.NOVEMBER, 10, GMT_TIME_ZONE);
101
102
103 testCommandLine(
104 "scm:svn:http://foo.com/svn/trunk",
105 null,
106 null,
107 endDate,
108 "svn --non-interactive log -v http://foo.com/svn/trunk@");
109 }
110
111 @Test
112 public void testCommandLineWithBranchNoDates() throws Exception {
113 testCommandLine(
114 "scm:svn:http://foo.com/svn/trunk",
115 new ScmBranch("my-test-branch"),
116 null,
117 null,
118 "svn --non-interactive log -v http://foo.com/svn/branches/my-test-branch@ http://foo.com/svn/trunk@");
119 }
120
121 @Test
122 public void testCommandLineWithBranchStartDateOnly() throws Exception {
123 Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE);
124
125 testCommandLine(
126 "scm:svn:http://foo.com/svn/trunk",
127 new ScmBranch("my-test-branch"),
128 startDate,
129 null,
130 "svn --non-interactive log -v -r \"{2003-09-10 01:01:01 +0000}:HEAD\" http://foo.com/svn/branches/my-test-branch@ http://foo.com/svn/trunk@");
131 }
132
133 @Test
134 public void testCommandLineWithBranchEndDateOnly() throws Exception {
135 Date endDate = getDate(2003, Calendar.OCTOBER, 10, 1, 1, 1, GMT_TIME_ZONE);
136
137
138 testCommandLine(
139 "scm:svn:http://foo.com/svn/trunk",
140 new ScmBranch("my-test-branch"),
141 null,
142 endDate,
143 "svn --non-interactive log -v http://foo.com/svn/branches/my-test-branch@ http://foo.com/svn/trunk@");
144 }
145
146 @Test
147 public void testCommandLineWithBranchBothDates() throws Exception {
148 Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, GMT_TIME_ZONE);
149 Date endDate = getDate(2003, Calendar.OCTOBER, 10, GMT_TIME_ZONE);
150
151 testCommandLine(
152 "scm:svn:http://foo.com/svn/trunk",
153 new ScmBranch("my-test-branch"),
154 startDate,
155 endDate,
156 "svn --non-interactive log -v -r \"{2003-09-10 00:00:00 +0000}:{2003-10-10 00:00:00 +0000}\" http://foo.com/svn/branches/my-test-branch@ http://foo.com/svn/trunk@");
157 }
158
159 @Test
160 public void testCommandLineWithStartVersion() throws Exception {
161 testCommandLine(
162 "scm:svn:http://foo.com/svn/trunk",
163 new ScmRevision("1"),
164 null,
165 "svn --non-interactive log -v -r 1:HEAD http://foo.com/svn/trunk@");
166 }
167
168 @Test
169 public void testCommandLineWithStartVersionAndEndVersion() throws Exception {
170 testCommandLine(
171 "scm:svn:http://foo.com/svn/trunk",
172 new ScmRevision("1"),
173 new ScmRevision("10"),
174 "svn --non-interactive log -v -r 1:10 http://foo.com/svn/trunk@");
175 }
176
177 @Test
178 public void testCommandLineWithStartVersionAndEndVersionEquals() throws Exception {
179 testCommandLine(
180 "scm:svn:http://foo.com/svn/trunk",
181 new ScmRevision("1"),
182 new ScmRevision("1"),
183 "svn --non-interactive log -v -r 1 http://foo.com/svn/trunk@");
184 }
185
186 @Test
187 public void testCommandLineWithBaseVersion() throws Exception {
188 testCommandLine(
189 "scm:svn:http://foo.com/svn/trunk",
190 new ScmRevision("1"),
191 new ScmRevision("BASE"),
192 "svn --non-interactive log -v -r 1:BASE");
193 }
194
195
196
197
198
199 private void testCommandLine(String scmUrl, ScmBranch branch, Date startDate, Date endDate, String commandLine)
200 throws Exception {
201 testCommandLine(scmUrl, branch, startDate, endDate, null, commandLine);
202 }
203
204 private void testCommandLine(
205 String scmUrl, ScmBranch branch, Date startDate, Date endDate, Integer limit, String commandLine)
206 throws Exception {
207 File workingDirectory = getTestFile("target/svn-update-command-test");
208
209 ScmRepository repository = getScmManager().makeScmRepository(scmUrl);
210
211 SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
212
213 Commandline cl = SvnChangeLogCommand.createCommandLine(
214 svnRepository, workingDirectory, branch, startDate, endDate, null, null, limit);
215
216 assertCommandLine(commandLine, workingDirectory, cl);
217 }
218
219 private void testCommandLine(String scmUrl, ScmVersion startVersion, ScmVersion endVersion, String commandLine)
220 throws Exception {
221 File workingDirectory = getTestFile("target/svn-update-command-test");
222
223 ScmRepository repository = getScmManager().makeScmRepository(scmUrl);
224
225 SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
226
227 Commandline cl = SvnChangeLogCommand.createCommandLine(
228 svnRepository, workingDirectory, null, null, null, startVersion, endVersion);
229 assertCommandLine(commandLine, workingDirectory, cl);
230 }
231 }