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.branch;
20
21 import java.io.File;
22
23 import org.apache.maven.scm.ScmBranchParameters;
24 import org.apache.maven.scm.provider.svn.command.branch.SvnBranchCommandTckTest;
25 import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
26 import org.apache.maven.scm.repository.ScmRepository;
27 import org.codehaus.plexus.util.cli.Commandline;
28 import org.junit.Test;
29
30 import static org.apache.maven.scm.provider.svn.SvnScmTestUtils.SVN_COMMAND_LINE;
31
32
33
34
35
36
37
38 public class SvnExeBranchCommandTckTest extends SvnBranchCommandTckTest {
39 public String getScmProviderCommand() {
40 return SVN_COMMAND_LINE;
41 }
42
43
44 @Test
45 public void testBranchUserNameSvnHttpsRemoteBranchingWithRev() throws Exception {
46 File messageFile = File.createTempFile("maven-scm", "commit");
47 messageFile.deleteOnExit();
48
49 ScmBranchParameters scmBranchParameters = new ScmBranchParameters();
50 scmBranchParameters.setRemoteBranching(true);
51 scmBranchParameters.setPinExternals(false);
52 scmBranchParameters.setScmRevision("2");
53
54 testCommandLine(
55 "scm:svn:https://foo.com/svn/trunk",
56 "svnbranch",
57 messageFile,
58 "user",
59 "svn --username user --no-auth-cache --non-interactive copy --parents --file "
60 + messageFile.getAbsolutePath()
61 + " --encoding UTF-8 --revision 2 https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@",
62 scmBranchParameters);
63 }
64
65 @Test
66 public void testBranchUserNameSvnHttpsRemoteBranchingWithRevWithPinExternals() throws Exception {
67 File messageFile = File.createTempFile("maven-scm", "commit");
68 messageFile.deleteOnExit();
69
70 ScmBranchParameters scmBranchParameters = new ScmBranchParameters();
71 scmBranchParameters.setRemoteBranching(true);
72 scmBranchParameters.setPinExternals(true);
73 scmBranchParameters.setScmRevision("2");
74
75 testCommandLine(
76 "scm:svn:https://foo.com/svn/trunk",
77 "svnbranch",
78 messageFile,
79 "user",
80 "svn --username user --no-auth-cache --non-interactive copy --parents --file "
81 + messageFile.getAbsolutePath()
82 + " --encoding UTF-8 --pin-externals --revision 2 https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@",
83 scmBranchParameters);
84 }
85
86 @Test
87 public void testBranchUserNameSvnHttpsRemoteBranchingNoRev() throws Exception {
88 File messageFile = File.createTempFile("maven-scm", "commit");
89 messageFile.deleteOnExit();
90
91 ScmBranchParameters scmBranchParameters = new ScmBranchParameters();
92 scmBranchParameters.setRemoteBranching(true);
93 scmBranchParameters.setPinExternals(false);
94
95 testCommandLine(
96 "scm:svn:https://foo.com/svn/trunk",
97 "svnbranch",
98 messageFile,
99 "user",
100 "svn --username user --no-auth-cache --non-interactive copy --parents --file "
101 + messageFile.getAbsolutePath()
102 + " --encoding UTF-8 https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@",
103 scmBranchParameters);
104 }
105
106 @Test
107 public void testBranchUserNameSvnHttpsRemoteBranchingNoRevWithPinExternals() throws Exception {
108 File messageFile = File.createTempFile("maven-scm", "commit");
109 messageFile.deleteOnExit();
110
111 ScmBranchParameters scmBranchParameters = new ScmBranchParameters();
112 scmBranchParameters.setRemoteBranching(true);
113 scmBranchParameters.setPinExternals(true);
114
115 testCommandLine(
116 "scm:svn:https://foo.com/svn/trunk",
117 "svnbranch",
118 messageFile,
119 "user",
120 "svn --username user --no-auth-cache --non-interactive copy --parents --file "
121 + messageFile.getAbsolutePath()
122 + " --encoding UTF-8 --pin-externals https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@",
123 scmBranchParameters);
124 }
125
126 @Test
127 public void testBranchUserNameSvnHttps() throws Exception {
128 File messageFile = File.createTempFile("maven-scm", "commit");
129 messageFile.deleteOnExit();
130
131 testCommandLine(
132 "scm:svn:https://foo.com/svn/trunk",
133 "svnbranch",
134 messageFile,
135 "user",
136 "svn --username user --no-auth-cache --non-interactive copy --parents --file "
137 + messageFile.getAbsolutePath() + " --encoding UTF-8 . https://foo.com/svn/branches/svnbranch@",
138 null);
139 }
140
141 @Test
142 public void testBranchUserNameSvnSsh() throws Exception {
143 File messageFile = File.createTempFile("maven-scm", "commit");
144 messageFile.deleteOnExit();
145
146 testCommandLine(
147 "scm:svn:svn+ssh://foo.com/svn/trunk",
148 "svnbranch",
149 messageFile,
150 "user",
151 "svn --username user --no-auth-cache --non-interactive copy --parents --file "
152 + messageFile.getAbsolutePath()
153 + " --encoding UTF-8 . svn+ssh://user@foo.com/svn/branches/svnbranch@");
154 }
155
156 private void testCommandLine(
157 String scmUrl,
158 String branch,
159 File messageFile,
160 String user,
161 String commandLine,
162 ScmBranchParameters scmBranchParameters)
163 throws Exception {
164 File workingDirectory = getTestFile("target/svn-update-command-test");
165
166 ScmRepository repository = getScmManager().makeScmRepository(scmUrl);
167
168 SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
169
170 svnRepository.setUser(user);
171
172 Commandline cl = null;
173 if (scmBranchParameters == null) {
174 cl = SvnBranchCommand.createCommandLine(svnRepository, workingDirectory, branch, messageFile);
175 } else {
176 cl = SvnBranchCommand.createCommandLine(
177 svnRepository, workingDirectory, branch, messageFile, scmBranchParameters);
178 }
179
180 assertCommandLine(commandLine, workingDirectory, cl);
181 }
182
183 private void testCommandLine(String scmUrl, String branch, File messageFile, String user, String commandLine)
184 throws Exception {
185 testCommandLine(scmUrl, branch, messageFile, user, commandLine, null);
186 }
187 }