1 package org.apache.maven.scm.provider.svn.svnexe.command.branch;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.scm.ScmBranchParameters;
23 import org.apache.maven.scm.provider.svn.command.branch.SvnBranchCommandTckTest;
24 import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
25 import org.apache.maven.scm.repository.ScmRepository;
26 import org.codehaus.plexus.util.cli.Commandline;
27
28 import java.io.File;
29
30
31
32
33
34
35
36 public class SvnExeBranchCommandTckTest
37 extends SvnBranchCommandTckTest
38 {
39
40 public void testBranchUserNameSvnHttpsRemoteBranchingWithRev()
41 throws Exception
42 {
43 File messageFile = File.createTempFile( "maven-scm", "commit" );
44 messageFile.deleteOnExit();
45
46 ScmBranchParameters scmBranchParameters = new ScmBranchParameters();
47 scmBranchParameters.setRemoteBranching( true );
48 scmBranchParameters.setScmRevision( "2" );
49
50 testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svnbranch", messageFile, "user",
51 "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath()
52 + " --revision 2 https://foo.com/svn/trunk https://foo.com/svn/branches/svnbranch",
53 scmBranchParameters );
54 }
55
56 public void testBranchUserNameSvnHttpsRemoteBranchingNoRev()
57 throws Exception
58 {
59 File messageFile = File.createTempFile( "maven-scm", "commit" );
60 messageFile.deleteOnExit();
61
62 ScmBranchParameters scmBranchParameters = new ScmBranchParameters();
63 scmBranchParameters.setRemoteBranching( true );
64
65 testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svnbranch", messageFile, "user",
66 "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath()
67 + " https://foo.com/svn/trunk https://foo.com/svn/branches/svnbranch", scmBranchParameters );
68 }
69
70 public void testBranchUserNameSvnHttps()
71 throws Exception
72 {
73 File messageFile = File.createTempFile( "maven-scm", "commit" );
74 messageFile.deleteOnExit();
75
76 testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svnbranch", messageFile, "user",
77 "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath()
78 + " . https://foo.com/svn/branches/svnbranch", null );
79 }
80
81 public void testBranchUserNameSvnSsh()
82 throws Exception
83 {
84 File messageFile = File.createTempFile( "maven-scm", "commit" );
85 messageFile.deleteOnExit();
86
87 testCommandLine( "scm:svn:svn+ssh://foo.com/svn/trunk", "svnbranch", messageFile, "user",
88 "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath()
89 + " . svn+ssh://user@foo.com/svn/branches/svnbranch" );
90 }
91
92 private void testCommandLine( String scmUrl, String branch, File messageFile, String user, String commandLine,
93 ScmBranchParameters scmBranchParameters )
94 throws Exception
95 {
96 File workingDirectory = getTestFile( "target/svn-update-command-test" );
97
98 ScmRepository repository = getScmManager().makeScmRepository( scmUrl );
99
100 SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
101
102 svnRepository.setUser( user );
103
104 Commandline cl = null;
105 if ( scmBranchParameters == null )
106 {
107 cl = SvnBranchCommand.createCommandLine( svnRepository, workingDirectory, branch, messageFile );
108 }
109 else
110 {
111 cl = SvnBranchCommand.createCommandLine( svnRepository, workingDirectory, branch, messageFile,
112 scmBranchParameters );
113 }
114
115 assertCommandLine( commandLine, workingDirectory, cl );
116 }
117
118 private void testCommandLine( String scmUrl, String branch, File messageFile, String user, String commandLine )
119 throws Exception
120 {
121 testCommandLine( scmUrl, branch, messageFile, user, commandLine, null );
122 }
123 }