View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.scm.provider.svn.svnexe.command.tag;
20  
21  import java.io.File;
22  
23  import org.apache.maven.scm.ScmTagParameters;
24  import org.apache.maven.scm.provider.svn.command.tag.SvnTagCommandTckTest;
25  import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
26  import org.apache.maven.scm.repository.ScmRepository;
27  import org.codehaus.plexus.util.cli.Commandline;
28  import org.junit.Test;
29  
30  import static org.apache.maven.scm.provider.svn.SvnScmTestUtils.SVN_COMMAND_LINE;
31  
32  /**
33   * This test tests the tag command.
34   *
35   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
36   *
37   */
38  public class SvnExeTagCommandTckTest extends SvnTagCommandTckTest {
39      @Override
40      public String getScmProviderCommand() {
41          return SVN_COMMAND_LINE;
42      }
43  
44      @Test
45      public void testTagUserNameSvnSsh() throws Exception {
46          File messageFile = File.createTempFile("maven-scm", "commit");
47          messageFile.deleteOnExit();
48  
49          testCommandLine(
50                  "scm:svn:svn+ssh://foo.com/svn/trunk",
51                  "svntag",
52                  messageFile,
53                  "user",
54                  "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath()
55                          + " --encoding UTF-8 --parents . svn+ssh://user@foo.com/svn/tags/svntag@",
56                  null);
57      }
58  
59      @Test
60      public void testTagRemoteTagHttps() throws Exception {
61          File messageFile = File.createTempFile("maven-scm", "commit");
62          messageFile.deleteOnExit();
63  
64          ScmTagParameters scmTagParameters = new ScmTagParameters();
65          scmTagParameters.setRemoteTagging(true);
66          scmTagParameters.setPinExternals(false);
67          testCommandLine(
68                  "scm:svn:https://foo.com/svn/trunk",
69                  "svntag",
70                  messageFile,
71                  "user",
72                  "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath()
73                          + " --encoding UTF-8 --parents https://foo.com/svn/trunk@ https://foo.com/svn/tags/svntag@",
74                  scmTagParameters);
75      }
76  
77      @Test
78      public void testTagRemoteTagHttpsWithPinExternals() throws Exception {
79          File messageFile = File.createTempFile("maven-scm", "commit");
80          messageFile.deleteOnExit();
81  
82          ScmTagParameters scmTagParameters = new ScmTagParameters();
83          scmTagParameters.setRemoteTagging(true);
84          scmTagParameters.setPinExternals(true);
85          testCommandLine(
86                  "scm:svn:https://foo.com/svn/trunk",
87                  "svntag",
88                  messageFile,
89                  "user",
90                  "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath()
91                          + " --encoding UTF-8 --parents --pin-externals https://foo.com/svn/trunk@ https://foo.com/svn/tags/svntag@",
92                  scmTagParameters);
93      }
94  
95      @Test
96      public void testTagRemoteTagHttpsWithRevision() throws Exception {
97          File messageFile = File.createTempFile("maven-scm", "commit");
98          messageFile.deleteOnExit();
99  
100         ScmTagParameters scmTagParameters = new ScmTagParameters();
101         scmTagParameters.setRemoteTagging(true);
102         scmTagParameters.setPinExternals(false);
103         scmTagParameters.setScmRevision("12");
104         testCommandLine(
105                 "scm:svn:https://foo.com/svn/trunk",
106                 "svntag",
107                 messageFile,
108                 "user",
109                 "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath()
110                         + " --encoding UTF-8 --parents --revision 12 https://foo.com/svn/trunk@ https://foo.com/svn/tags/svntag@",
111                 scmTagParameters);
112     }
113 
114     @Test
115     public void testTagRemoteTagHttpsWithRevisionAndPinExternals() throws Exception {
116         File messageFile = File.createTempFile("maven-scm", "commit");
117         messageFile.deleteOnExit();
118 
119         ScmTagParameters scmTagParameters = new ScmTagParameters();
120         scmTagParameters.setRemoteTagging(true);
121         scmTagParameters.setPinExternals(true);
122         scmTagParameters.setScmRevision("12");
123         testCommandLine(
124                 "scm:svn:https://foo.com/svn/trunk",
125                 "svntag",
126                 messageFile,
127                 "user",
128                 "svn --username user --no-auth-cache --non-interactive copy --file " + messageFile.getAbsolutePath()
129                         + " --encoding UTF-8 --parents --revision 12 --pin-externals https://foo.com/svn/trunk@ https://foo.com/svn/tags/svntag@",
130                 scmTagParameters);
131     }
132 
133     private void testCommandLine(
134             String scmUrl,
135             String tag,
136             File messageFile,
137             String user,
138             String commandLine,
139             ScmTagParameters scmTagParameters)
140             throws Exception {
141         File workingDirectory = getTestFile("target/svn-update-command-test");
142 
143         ScmRepository repository = getScmManager().makeScmRepository(scmUrl);
144 
145         SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
146 
147         svnRepository.setUser(user);
148 
149         Commandline cl = null;
150 
151         cl = SvnTagCommand.createCommandLine(svnRepository, workingDirectory, tag, messageFile, scmTagParameters);
152 
153         assertCommandLine(commandLine, workingDirectory, cl);
154     }
155 }