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.checkin;
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.provider.svn.util.SvnUtil;
27 import org.apache.maven.scm.repository.ScmRepository;
28 import org.codehaus.plexus.util.cli.Commandline;
29 import org.junit.Before;
30 import org.junit.Test;
31
32
33
34
35
36 public class SvnCheckInCommandTest extends ScmTestCase {
37 private File messageFile;
38
39 private String messageFileString;
40
41 @Before
42 @Override
43 public void setUp() throws Exception {
44 super.setUp();
45
46 messageFile = new File("commit-message");
47
48 String path = messageFile.getAbsolutePath();
49 if (path.indexOf(' ') >= 0) {
50 path = "\"" + path + "\"";
51 }
52 messageFileString = "--file " + path + " --encoding UTF-8";
53 }
54
55 @Test
56 public void testCommandLineWithEmptyTag() throws Exception {
57 testCommandLine("scm:svn:http://foo.com/svn/trunk", "svn --non-interactive commit " + messageFileString);
58 }
59
60 @Test
61 public void testCommandLineWithoutTag() throws Exception {
62 testCommandLine("scm:svn:http://foo.com/svn/trunk", "svn --non-interactive commit " + messageFileString);
63 }
64
65 @Test
66 public void testCommandLineTag() throws Exception {
67 testCommandLine(
68 "scm:svn:http://anonymous@foo.com/svn/trunk",
69 "svn --username anonymous --no-auth-cache --non-interactive commit " + messageFileString);
70 }
71
72 @Test
73 public void testCommandLineWithUsernameAndTag() throws Exception {
74 testCommandLine(
75 "scm:svn:http://anonymous@foo.com/svn/trunk",
76 "svn --username anonymous --no-auth-cache --non-interactive commit " + messageFileString);
77 }
78
79 @Test
80 public void testCommandLineWithUsernameWithoutNonInteractive() throws Exception {
81 try {
82 SvnUtil.setSettingsDirectory(getTestFile("src/test/resources/svn/checkin/macos"));
83 testCommandLine(
84 "scm:svn:http://anonymous@foo.com/svn/trunk",
85 "svn --username anonymous --no-auth-cache commit " + messageFileString);
86 } finally {
87
88 SvnUtil.setSettingsDirectory(SvnUtil.DEFAULT_SETTINGS_DIRECTORY);
89 }
90 }
91
92
93
94
95
96 private void testCommandLine(String scmUrl, String commandLine) throws Exception {
97 File workingDirectory = getTestFile("target/svn-checkin-command-test");
98
99 ScmRepository repository = getScmManager().makeScmRepository(scmUrl);
100
101 SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
102
103 Commandline cl =
104 SvnCheckInCommand.createCommandLine(svnRepository, new ScmFileSet(workingDirectory), messageFile);
105
106 assertCommandLine(commandLine, workingDirectory, cl);
107 }
108 }