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.list;
20
21 import java.io.File;
22
23 import org.apache.maven.scm.ScmFileSet;
24 import org.apache.maven.scm.ScmRevision;
25 import org.apache.maven.scm.ScmTestCase;
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 import org.junit.Test;
30
31
32
33
34
35 public class SvnListCommandTest extends ScmTestCase {
36 @Test
37 public void testCommandLineWithEmptyTag() throws Exception {
38 testCommandLine("scm:svn:http://foo.com/svn/trunk", true, "svn --non-interactive list --recursive");
39 }
40
41 @Test
42 public void testCommandLineWithWhitespaceTag() throws Exception {
43 testCommandLine("scm:svn:http://foo.com/svn/trunk", false, "svn --non-interactive list");
44 }
45
46 @Test
47 public void testCommandLineWithoutTag() throws Exception {
48 testCommandLine("scm:svn:http://foo.com/svn/trunk", false, "svn --non-interactive list");
49 }
50
51 @Test
52 public void testCommandLineTag() throws Exception {
53 testCommandLine(
54 "scm:svn:http://anonymous@foo.com/svn/trunk",
55 false,
56 "10",
57 "svn --username anonymous --no-auth-cache --non-interactive list -r 10");
58 }
59
60 @Test
61 public void testCommandLineWithUsernameAndTag() throws Exception {
62 testCommandLine(
63 "scm:svn:http://anonymous@foo.com/svn/trunk",
64 false,
65 "10",
66 "svn --username anonymous --no-auth-cache --non-interactive list -r 10");
67 }
68
69
70
71
72
73 private SvnScmProviderRepository getSvnRepository(String scmUrl) throws Exception {
74 ScmRepository repository = getScmManager().makeScmRepository(scmUrl);
75
76 return (SvnScmProviderRepository) repository.getProviderRepository();
77 }
78
79 private void testCommandLine(String scmUrl, boolean recursive, String commandLine) throws Exception {
80 testCommandLine(scmUrl, recursive, null, commandLine);
81 }
82
83 private void testCommandLine(String scmUrl, boolean recursive, String revision, String commandLine)
84 throws Exception {
85 ScmFileSet fileSet = new ScmFileSet(new File("."), new File("."));
86
87 Commandline cl = SvnListCommand.createCommandLine(
88 getSvnRepository(scmUrl), fileSet, recursive, new ScmRevision(revision));
89
90 assertCommandLine(
91 commandLine + " http://foo.com/svn/trunk/.@", new File(System.getProperty("java.io.tmpdir")), cl);
92 }
93 }