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