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.untag;
20
21 import java.io.File;
22
23 import org.apache.maven.scm.ScmFileSet;
24 import org.apache.maven.scm.ScmTestCase;
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
31
32
33
34 public class SvnUntagCommandTest extends ScmTestCase {
35
36
37
38
39
40
41 @Test
42 public void testUntagHttp() throws Exception {
43
44 File messageFile = File.createTempFile("maven-scm", "untag");
45 messageFile.deleteOnExit();
46
47 testCommandLine(
48 "scm:svn:http://foo.com/svn/tags",
49 new ScmFileSet(getUntagTestFile()),
50 "svntag",
51 "user",
52 messageFile,
53 "svn --username user --no-auth-cache --non-interactive " + "--file " + messageFile.getAbsolutePath()
54 + " remove http://foo.com/svn/tags/svntag@");
55 }
56
57
58
59
60
61
62 @Test
63 public void testUntagSsh() throws Exception {
64
65 File messageFile = File.createTempFile("maven-scm", "untag");
66 messageFile.deleteOnExit();
67
68 testCommandLine(
69 "scm:svn:svn+ssh://foo.com/svn/tags",
70 new ScmFileSet(getUntagTestFile()),
71 "svntag",
72 "user",
73 messageFile,
74 "svn --username user --no-auth-cache --non-interactive " + "--file " + messageFile.getAbsolutePath()
75 + " remove svn+ssh://user@foo.com/svn/tags/svntag@");
76 }
77
78
79
80
81
82
83 private File getUntagTestFile() {
84 return getTestFile("target/svn-untag-command-test");
85 }
86
87
88
89
90
91
92
93
94 private SvnScmProviderRepository getSvnRepository(String scmUrl) throws Exception {
95 ScmRepository repository = getScmManager().makeScmRepository(scmUrl);
96
97 return (SvnScmProviderRepository) repository.getProviderRepository();
98 }
99
100
101
102
103
104
105
106
107
108
109
110
111 private void testCommandLine(
112 String scmUrl, ScmFileSet scmFileSet, String tag, String user, File messageFile, String commandline)
113 throws Exception {
114 SvnScmProviderRepository repo = getSvnRepository(scmUrl);
115 repo.setUser(user);
116 Commandline cl = new SvnUntagCommand().createCommandline(repo, scmFileSet, tag, messageFile);
117
118 assertCommandLine(commandline, scmFileSet.getBasedir(), cl);
119 }
120 }