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.checkout;
20
21 import java.io.File;
22
23 import org.apache.maven.scm.ScmRevision;
24 import org.apache.maven.scm.ScmTestCase;
25 import org.apache.maven.scm.manager.ScmManager;
26 import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
27 import org.apache.maven.scm.repository.ScmRepository;
28 import org.codehaus.plexus.util.FileUtils;
29 import org.codehaus.plexus.util.cli.Commandline;
30 import org.junit.Before;
31 import org.junit.Test;
32
33
34
35
36
37 public class SvnCheckOutCommandTest extends ScmTestCase {
38 private File workingDirectory;
39
40 private boolean recursive;
41
42
43
44
45
46 @Before
47 @Override
48 public void setUp() throws Exception {
49 super.setUp();
50
51 recursive = true;
52 workingDirectory = getTestFile("target/svn-checkout-command-test");
53 if (workingDirectory != null && workingDirectory.isDirectory()) {
54 FileUtils.deleteDirectory(workingDirectory);
55 }
56 }
57
58
59
60
61
62 @Test
63 public void testCommandLineWithoutRevision() throws Exception {
64 testCommandLine(
65 getScmManager(),
66 "scm:svn:http://foo.com/svn/trunk",
67 null,
68 "svn --non-interactive checkout http://foo.com/svn/trunk@ " + workingDirectory.getAbsolutePath());
69 }
70
71 @Test
72 public void testCommandLineWithEmptyRevision() throws Exception {
73 testCommandLine(
74 getScmManager(),
75 "scm:svn:http://foo.com/svn/trunk",
76 "",
77 "svn --non-interactive checkout http://foo.com/svn/trunk@ " + workingDirectory.getAbsolutePath());
78 }
79
80 @Test
81 public void testCommandLineWithRevision() throws Exception {
82 testCommandLine(
83 getScmManager(),
84 "scm:svn:http://foo.com/svn/trunk",
85 "10",
86 "svn --non-interactive checkout -r 10 http://foo.com/svn/trunk@ " + workingDirectory.getAbsolutePath());
87 }
88
89 @Test
90 public void testRecursiveCheckOutCommandLine() throws Exception {
91 recursive = false;
92 testCommandLine(
93 getScmManager(),
94 "scm:svn:http://foo.com/svn/trunk",
95 "10",
96 "svn --non-interactive checkout -N -r 10 http://foo.com/svn/trunk@ "
97 + workingDirectory.getAbsolutePath());
98 }
99
100
101
102
103
104 private void testCommandLine(ScmManager scmManager, String scmUrl, String revision, String commandLine)
105 throws Exception {
106 ScmRepository repository = scmManager.makeScmRepository(scmUrl);
107
108 SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
109
110 Commandline cl = SvnCheckOutCommand.createCommandLine(
111 svnRepository, workingDirectory, new ScmRevision(revision), svnRepository.getUrl(), recursive);
112
113 assertCommandLine(commandLine, workingDirectory.getParentFile(), cl);
114 }
115 }