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.untag;
20  
21  import java.io.File;
22  
23  import org.apache.maven.scm.ScmFileSet;
24  import org.apache.maven.scm.provider.svn.command.untag.SvnUntagCommandTckTest;
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 untag command for Subversion.
34   *
35   */
36  public class SvnExeUntagCommandTckTest extends SvnUntagCommandTckTest {
37      @Override
38      public String getScmProviderCommand() {
39          return SVN_COMMAND_LINE;
40      }
41  
42      /**
43       * test against ssh repository with user
44       *
45       * @throws Exception in case of error
46       */
47      @Test
48      public void testUntagSsh() throws Exception {
49          File messageFile = File.createTempFile("maven-scm", "commit");
50          messageFile.deleteOnExit();
51  
52          ScmFileSet scmFileSet = new ScmFileSet(new File("target/svn-untag-command-test"));
53  
54          testCommandLine(
55                  "scm:svn:svn+ssh://foo.com/svn/trunk",
56                  scmFileSet,
57                  "svntag",
58                  messageFile,
59                  "user",
60                  "svn --username user --no-auth-cache --non-interactive --file " + messageFile.getAbsolutePath()
61                          + " remove svn+ssh://user@foo.com/svn/tags/svntag@");
62      }
63  
64      /**
65       * test against https repository with user
66       *
67       * @throws Exception in case of error
68       */
69      @Test
70      public void testUntagHttps() throws Exception {
71          File messageFile = File.createTempFile("maven-scm", "commit");
72          messageFile.deleteOnExit();
73  
74          ScmFileSet scmFileSet = new ScmFileSet(new File("target/svn-untag-command-test"));
75  
76          testCommandLine(
77                  "scm:svn:https://foo.com/svn/tags",
78                  scmFileSet,
79                  "svntag",
80                  messageFile,
81                  "user",
82                  "svn --username user --no-auth-cache --non-interactive --file " + messageFile.getAbsolutePath()
83                          + " remove https://foo.com/svn/tags/svntag@");
84      }
85  
86      /**
87       * test routine, build command line and assert
88       *
89       * @param scmUrl      url to svn repo
90       * @param scmFileSet  file set for local dir
91       * @param tag         tag to delete
92       * @param messageFile file containing commit message
93       * @param user        user to acces the repo with
94       * @param commandLine set command line for comparison
95       * @throws Exception  in case of error
96       */
97      private void testCommandLine(
98              String scmUrl, ScmFileSet scmFileSet, String tag, File messageFile, String user, String commandLine)
99              throws Exception {
100         File workingDirectory = getTestFile("target/svn-untag-command-test");
101 
102         ScmRepository repository = getScmManager().makeScmRepository(scmUrl);
103 
104         SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
105 
106         svnRepository.setUser(user);
107 
108         Commandline cl = new SvnUntagCommand().createCommandline(svnRepository, scmFileSet, tag, messageFile);
109 
110         assertCommandLine(commandLine, workingDirectory, cl);
111     }
112 }