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.setPinExternals( false );
49 scmBranchParameters.setScmRevision( "2" );
50
51 testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svnbranch", messageFile, "user",
52 "svn --username user --no-auth-cache --non-interactive copy --parents --file " + messageFile.getAbsolutePath()
53 + " --encoding UTF-8 --revision 2 https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@",
54 scmBranchParameters );
55 }
56
57 public void testBranchUserNameSvnHttpsRemoteBranchingWithRevWithPinExternals()
58 throws Exception
59 {
60 File messageFile = File.createTempFile( "maven-scm", "commit" );
61 messageFile.deleteOnExit();
62
63 ScmBranchParameters scmBranchParameters = new ScmBranchParameters();
64 scmBranchParameters.setRemoteBranching( true );
65 scmBranchParameters.setPinExternals( true );
66 scmBranchParameters.setScmRevision( "2" );
67
68 testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svnbranch", messageFile, "user",
69 "svn --username user --no-auth-cache --non-interactive copy --parents --file " + messageFile.getAbsolutePath()
70 + " --encoding UTF-8 --pin-externals --revision 2 https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@",
71 scmBranchParameters );
72 }
73
74 public void testBranchUserNameSvnHttpsRemoteBranchingNoRev()
75 throws Exception
76 {
77 File messageFile = File.createTempFile( "maven-scm", "commit" );
78 messageFile.deleteOnExit();
79
80 ScmBranchParameters scmBranchParameters = new ScmBranchParameters();
81 scmBranchParameters.setRemoteBranching( true );
82 scmBranchParameters.setPinExternals( false );
83
84 testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svnbranch", messageFile, "user",
85 "svn --username user --no-auth-cache --non-interactive copy --parents --file " + messageFile.getAbsolutePath()
86 + " --encoding UTF-8 https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@", scmBranchParameters );
87 }
88
89 public void testBranchUserNameSvnHttpsRemoteBranchingNoRevWithPinExternals()
90 throws Exception
91 {
92 File messageFile = File.createTempFile( "maven-scm", "commit" );
93 messageFile.deleteOnExit();
94
95 ScmBranchParameters scmBranchParameters = new ScmBranchParameters();
96 scmBranchParameters.setRemoteBranching( true );
97 scmBranchParameters.setPinExternals( true );
98
99 testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svnbranch", messageFile, "user",
100 "svn --username user --no-auth-cache --non-interactive copy --parents --file " + messageFile.getAbsolutePath()
101 + " --encoding UTF-8 --pin-externals https://foo.com/svn/trunk@ https://foo.com/svn/branches/svnbranch@", scmBranchParameters );
102 }
103
104 public void testBranchUserNameSvnHttps()
105 throws Exception
106 {
107 File messageFile = File.createTempFile( "maven-scm", "commit" );
108 messageFile.deleteOnExit();
109
110 testCommandLine( "scm:svn:https://foo.com/svn/trunk", "svnbranch", messageFile, "user",
111 "svn --username user --no-auth-cache --non-interactive copy --parents --file " + messageFile.getAbsolutePath()
112 + " --encoding UTF-8 . https://foo.com/svn/branches/svnbranch@", null );
113 }
114
115 public void testBranchUserNameSvnSsh()
116 throws Exception
117 {
118 File messageFile = File.createTempFile( "maven-scm", "commit" );
119 messageFile.deleteOnExit();
120
121 testCommandLine( "scm:svn:svn+ssh://foo.com/svn/trunk", "svnbranch", messageFile, "user",
122 "svn --username user --no-auth-cache --non-interactive copy --parents --file " + messageFile.getAbsolutePath()
123 + " --encoding UTF-8 . svn+ssh://user@foo.com/svn/branches/svnbranch@" );
124 }
125
126 private void testCommandLine( String scmUrl, String branch, File messageFile, String user, String commandLine,
127 ScmBranchParameters scmBranchParameters )
128 throws Exception
129 {
130 File workingDirectory = getTestFile( "target/svn-update-command-test" );
131
132 ScmRepository repository = getScmManager().makeScmRepository( scmUrl );
133
134 SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
135
136 svnRepository.setUser( user );
137
138 Commandline cl = null;
139 if ( scmBranchParameters == null )
140 {
141 cl = SvnBranchCommand.createCommandLine( svnRepository, workingDirectory, branch, messageFile );
142 }
143 else
144 {
145 cl = SvnBranchCommand.createCommandLine( svnRepository, workingDirectory, branch, messageFile,
146 scmBranchParameters );
147 }
148
149 assertCommandLine( commandLine, workingDirectory, cl );
150 }
151
152 private void testCommandLine( String scmUrl, String branch, File messageFile, String user, String commandLine )
153 throws Exception
154 {
155 testCommandLine( scmUrl, branch, messageFile, user, commandLine, null );
156 }
157 }