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